libsodium 1.0.8
[tomato.git] / release / src / router / libsodium / test / default / stream2.c
blob75c1e3dfafce0db8c5c76ef1f4409010fd839db3
2 #define TEST_NAME "stream2"
3 #include "cmptest.h"
5 static unsigned char secondkey[32]
6 = { 0xdc, 0x90, 0x8d, 0xda, 0x0b, 0x93, 0x44, 0xa9, 0x53, 0x62, 0x9b,
7 0x73, 0x38, 0x20, 0x77, 0x88, 0x80, 0xf3, 0xce, 0xb4, 0x21, 0xbb,
8 0x61, 0xb9, 0x1c, 0xbd, 0x4c, 0x3e, 0x66, 0x25, 0x6c, 0xe4 };
10 static unsigned char noncesuffix[8]
11 = { 0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
13 static unsigned char output[4194304];
15 static unsigned char h[32];
17 int main(void)
19 int i;
20 crypto_stream_salsa20(output, sizeof output, noncesuffix, secondkey);
21 crypto_hash_sha256(h, output, sizeof output);
22 for (i = 0; i < 32; ++i)
23 printf("%02x", h[i]);
24 printf("\n");
26 assert(sizeof output > 4000);
28 crypto_stream_salsa20_xor_ic(output, output, 4000, noncesuffix, 0U, secondkey);
29 for (i = 0; i < 4000; ++i)
30 assert(output[i] == 0);
32 crypto_stream_salsa20_xor_ic(output, output, 4000, noncesuffix, 1U, secondkey);
33 crypto_hash_sha256(h, output, sizeof output);
34 for (i = 0; i < 32; ++i)
35 printf("%02x", h[i]);
36 printf("\n");
38 assert(crypto_stream_salsa20_keybytes() > 0U);
39 assert(crypto_stream_salsa20_noncebytes() > 0U);
41 return 0;