aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-11-23 17:57:42 +0000
committerlloyd <[email protected]>2008-11-23 17:57:42 +0000
commit7156bf573d68f01c9846191353934b8b7a5633d9 (patch)
treeab8f4b0904fa8290cace12cadd04f6663cdf7216
parent79cacfe8e928887e03ab7992ffd64ff8340adcd7 (diff)
Add xor_into_buf. Add Doxygen comments for xor_buf
-rw-r--r--src/utils/xor_buf.h42
1 files changed, 32 insertions, 10 deletions
diff --git a/src/utils/xor_buf.h b/src/utils/xor_buf.h
index 0a71aef3e..975ad0af6 100644
--- a/src/utils/xor_buf.h
+++ b/src/utils/xor_buf.h
@@ -1,7 +1,7 @@
-/*************************************************
-* Xor Operations Header File *
-* (C) 1999-2008 Jack Lloyd *
-*************************************************/
+/**
+* XOR operations
+* (C) 1999-2008 Jack Lloyd
+*/
#ifndef BOTAN_XOR_BUF_H__
#define BOTAN_XOR_BUF_H__
@@ -10,9 +10,12 @@
namespace Botan {
-/*************************************************
-* XOR Arrays *
-*************************************************/
+/**
+* XOR arrays. Postcondition out[i] = in[i] ^ out[i] forall i = 0...length
+* @param out the input/output buffer
+* @param in the read-only input buffer
+* @param length the length of the buffers
+*/
inline void xor_buf(byte out[], const byte in[], u32bit length)
{
while(length >= 8)
@@ -32,9 +35,13 @@ inline void xor_buf(byte out[], const byte in[], u32bit length)
out[j] ^= in[j];
}
-/*************************************************
-* XOR Arrays *
-*************************************************/
+/**
+* XOR arrays. Postcondition out[i] = in[i] ^ in2[i] forall i = 0...length
+* @param out the output buffer
+* @param in the first input buffer
+* @param in2 the second output buffer
+* @param length the length of the three buffers
+*/
inline void xor_buf(byte out[],
const byte in[],
const byte in2[],
@@ -60,6 +67,21 @@ inline void xor_buf(byte out[],
out[j] = in[j] ^ in2[j];
}
+/**
+* Xor values into buffer
+*/
+inline u32bit xor_into_buf(byte buf[], u32bit buf_i, u32bit length,
+ const void* in_void, u32bit in_len)
+ {
+ const byte* in = static_cast<const byte*>(in_void);
+ for(u32bit i = 0; i != in_len; ++i)
+ {
+ buf[buf_i] ^= in[i];
+ buf_i = (buf_i + 1) % length;
+ }
+ return buf_i;
+ }
+
}
#endif