The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/libsodium/test/default/stream2.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

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

Cache object: a2d830bb8bbf1a1e20a9347fce7cd708


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.