Home | History | Annotate | Line # | Download | only in default
      1  1.1  riastrad 
      2  1.1  riastrad #define TEST_NAME "stream2"
      3  1.1  riastrad #include "cmptest.h"
      4  1.1  riastrad 
      5  1.1  riastrad static unsigned char secondkey[32] = { 0xdc, 0x90, 0x8d, 0xda, 0x0b, 0x93, 0x44,
      6  1.1  riastrad                                        0xa9, 0x53, 0x62, 0x9b, 0x73, 0x38, 0x20,
      7  1.1  riastrad                                        0x77, 0x88, 0x80, 0xf3, 0xce, 0xb4, 0x21,
      8  1.1  riastrad                                        0xbb, 0x61, 0xb9, 0x1c, 0xbd, 0x4c, 0x3e,
      9  1.1  riastrad                                        0x66, 0x25, 0x6c, 0xe4 };
     10  1.1  riastrad 
     11  1.1  riastrad static unsigned char noncesuffix[8] = { 0x82, 0x19, 0xe0, 0x03,
     12  1.1  riastrad                                         0x6b, 0x7a, 0x0b, 0x37 };
     13  1.1  riastrad 
     14  1.1  riastrad static unsigned char output[4194304];
     15  1.1  riastrad 
     16  1.1  riastrad static unsigned char h[32];
     17  1.1  riastrad 
     18  1.1  riastrad int
     19  1.1  riastrad main(void)
     20  1.1  riastrad {
     21  1.1  riastrad     int i;
     22  1.1  riastrad     crypto_stream_salsa20(output, sizeof output, noncesuffix, secondkey);
     23  1.1  riastrad     crypto_hash_sha256(h, output, sizeof output);
     24  1.1  riastrad     for (i = 0; i < 32; ++i)
     25  1.1  riastrad         printf("%02x", h[i]);
     26  1.1  riastrad     printf("\n");
     27  1.1  riastrad 
     28  1.1  riastrad     assert(sizeof output > 4000);
     29  1.1  riastrad 
     30  1.1  riastrad     crypto_stream_salsa20_xor_ic(output, output, 4000, noncesuffix, 0U,
     31  1.1  riastrad                                  secondkey);
     32  1.1  riastrad     for (i = 0; i < 4000; ++i)
     33  1.1  riastrad         assert(output[i] == 0);
     34  1.1  riastrad 
     35  1.1  riastrad     crypto_stream_salsa20_xor_ic(output, output, 4000, noncesuffix, 1U,
     36  1.1  riastrad                                  secondkey);
     37  1.1  riastrad     crypto_hash_sha256(h, output, sizeof output);
     38  1.1  riastrad     for (i = 0; i < 32; ++i)
     39  1.1  riastrad         printf("%02x", h[i]);
     40  1.1  riastrad     printf("\n");
     41  1.1  riastrad 
     42  1.1  riastrad     assert(crypto_stream_salsa20_keybytes() > 0U);
     43  1.1  riastrad     assert(crypto_stream_salsa20_noncebytes() > 0U);
     44  1.1  riastrad     assert(crypto_stream_salsa20_messagebytes_max() > 0U);
     45  1.1  riastrad 
     46  1.1  riastrad     return 0;
     47  1.1  riastrad }
     48