aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/xor_buf.cpp
blob: df4e62db967924ab98d7716831c10589a8215daf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* XOR operations
* (C) 1999-2008 Jack Lloyd
*/

#include <botan/xor_buf.h>
#include <botan/loadstor.h>

namespace Botan {

/**
* Xor values into buffer
*/
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;
   }

}