9 #include "crypto_core_salsa20.h"
10 #include "crypto_stream_salsa20.h"
13 #ifndef HAVE_AMD64_ASM
15 int crypto_stream_salsa20_xor_ic(
17 const unsigned char *m
,unsigned long long mlen
,
18 const unsigned char *n
, uint64_t ic
,
19 const unsigned char *k
23 unsigned char block
[64];
24 unsigned char kcopy
[32];
30 for (i
= 0;i
< 32;++i
) kcopy
[i
] = k
[i
];
31 for (i
= 0;i
< 8;++i
) in
[i
] = n
[i
];
32 for (i
= 8;i
< 16;++i
) {
33 in
[i
] = (unsigned char) (ic
& 0xff);
38 crypto_core_salsa20(block
,in
,kcopy
,NULL
);
39 for (i
= 0;i
< 64;++i
) c
[i
] = m
[i
] ^ block
[i
];
42 for (i
= 8;i
< 16;++i
) {
43 u
+= (unsigned int) in
[i
];
54 crypto_core_salsa20(block
,in
,kcopy
,NULL
);
55 for (i
= 0;i
< (unsigned int) mlen
;++i
) c
[i
] = m
[i
] ^ block
[i
];
57 sodium_memzero(block
, sizeof block
);
58 sodium_memzero(kcopy
, sizeof kcopy
);