summaryrefslogtreecommitdiff
path: root/nacl/crypto_stream/xsalsa20/ref/xor.c
diff options
context:
space:
mode:
Diffstat (limited to 'nacl/crypto_stream/xsalsa20/ref/xor.c')
-rw-r--r--nacl/crypto_stream/xsalsa20/ref/xor.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/nacl/crypto_stream/xsalsa20/ref/xor.c b/nacl/crypto_stream/xsalsa20/ref/xor.c
new file mode 100644
index 00000000..13f3134a
--- /dev/null
+++ b/nacl/crypto_stream/xsalsa20/ref/xor.c
@@ -0,0 +1,23 @@
1/*
2version 20080913
3D. J. Bernstein
4Public domain.
5*/
6
7#include "crypto_core_hsalsa20.h"
8#include "crypto_stream_salsa20.h"
9#include "crypto_stream.h"
10
11static const unsigned char sigma[16] = "expand 32-byte k";
12
13int crypto_stream_xor(
14 unsigned char *c,
15 const unsigned char *m,unsigned long long mlen,
16 const unsigned char *n,
17 const unsigned char *k
18)
19{
20 unsigned char subkey[32];
21 crypto_core_hsalsa20(subkey,n,k,sigma);
22 return crypto_stream_salsa20_xor(c,m,mlen,n + 16,subkey);
23}