xref: /freebsd/sys/contrib/libsodium/test/default/core1.c (revision 3611ec604864a7d4dcc9a3ea898c80eb35eef8a0)
1*0ac341f1SConrad Meyer 
2*0ac341f1SConrad Meyer #define TEST_NAME "core1"
3*0ac341f1SConrad Meyer #include "cmptest.h"
4*0ac341f1SConrad Meyer 
5*0ac341f1SConrad Meyer static unsigned char shared[32] = { 0x4a, 0x5d, 0x9d, 0x5b, 0xa4, 0xce, 0x2d,
6*0ac341f1SConrad Meyer                                     0xe1, 0x72, 0x8e, 0x3b, 0xf4, 0x80, 0x35,
7*0ac341f1SConrad Meyer                                     0x0f, 0x25, 0xe0, 0x7e, 0x21, 0xc9, 0x47,
8*0ac341f1SConrad Meyer                                     0xd1, 0x9e, 0x33, 0x76, 0xf0, 0x9b, 0x3c,
9*0ac341f1SConrad Meyer                                     0x1e, 0x16, 0x17, 0x42 };
10*0ac341f1SConrad Meyer 
11*0ac341f1SConrad Meyer static unsigned char zero[32];
12*0ac341f1SConrad Meyer 
13*0ac341f1SConrad Meyer static unsigned char c[16] = { 0x65, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x20, 0x33,
14*0ac341f1SConrad Meyer                                0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20, 0x6b };
15*0ac341f1SConrad Meyer 
16*0ac341f1SConrad Meyer static unsigned char firstkey[32];
17*0ac341f1SConrad Meyer 
18*0ac341f1SConrad Meyer int
main(void)19*0ac341f1SConrad Meyer main(void)
20*0ac341f1SConrad Meyer {
21*0ac341f1SConrad Meyer     int i;
22*0ac341f1SConrad Meyer 
23*0ac341f1SConrad Meyer     crypto_core_hsalsa20(firstkey, zero, shared, c);
24*0ac341f1SConrad Meyer     for (i = 0; i < 32; ++i) {
25*0ac341f1SConrad Meyer         if (i > 0) {
26*0ac341f1SConrad Meyer             printf(",");
27*0ac341f1SConrad Meyer         } else {
28*0ac341f1SConrad Meyer             printf(" ");
29*0ac341f1SConrad Meyer         }
30*0ac341f1SConrad Meyer         printf("0x%02x", (unsigned int) firstkey[i]);
31*0ac341f1SConrad Meyer         if (i % 8 == 7) {
32*0ac341f1SConrad Meyer             printf("\n");
33*0ac341f1SConrad Meyer         }
34*0ac341f1SConrad Meyer     }
35*0ac341f1SConrad Meyer     assert(crypto_core_hsalsa20_outputbytes() > 0U);
36*0ac341f1SConrad Meyer     assert(crypto_core_hsalsa20_inputbytes() > 0U);
37*0ac341f1SConrad Meyer     assert(crypto_core_hsalsa20_keybytes() > 0U);
38*0ac341f1SConrad Meyer     assert(crypto_core_hsalsa20_constbytes() > 0U);
39*0ac341f1SConrad Meyer 
40*0ac341f1SConrad Meyer     return 0;
41*0ac341f1SConrad Meyer }
42