xref: /freebsd/sys/contrib/libsodium/test/default/core2.c (revision 3611ec604864a7d4dcc9a3ea898c80eb35eef8a0)
1*0ac341f1SConrad Meyer 
2*0ac341f1SConrad Meyer #define TEST_NAME "core2"
3*0ac341f1SConrad Meyer #include "cmptest.h"
4*0ac341f1SConrad Meyer 
5*0ac341f1SConrad Meyer static unsigned char firstkey[32] = { 0x1b, 0x27, 0x55, 0x64, 0x73, 0xe9, 0x85,
6*0ac341f1SConrad Meyer                                       0xd4, 0x62, 0xcd, 0x51, 0x19, 0x7a, 0x9a,
7*0ac341f1SConrad Meyer                                       0x46, 0xc7, 0x60, 0x09, 0x54, 0x9e, 0xac,
8*0ac341f1SConrad Meyer                                       0x64, 0x74, 0xf2, 0x06, 0xc4, 0xee, 0x08,
9*0ac341f1SConrad Meyer                                       0x44, 0xf6, 0x83, 0x89 };
10*0ac341f1SConrad Meyer 
11*0ac341f1SConrad Meyer static unsigned char nonceprefix[16] = { 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6,
12*0ac341f1SConrad Meyer                                          0x2b, 0x73, 0xcd, 0x62, 0xbd, 0xa8,
13*0ac341f1SConrad Meyer                                          0x75, 0xfc, 0x73, 0xd6 };
14*0ac341f1SConrad Meyer 
15*0ac341f1SConrad Meyer static unsigned char c[16] = { 0x65, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x20, 0x33,
16*0ac341f1SConrad Meyer                                0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20, 0x6b };
17*0ac341f1SConrad Meyer 
18*0ac341f1SConrad Meyer static unsigned char secondkey[32];
19*0ac341f1SConrad Meyer 
20*0ac341f1SConrad Meyer int
main(void)21*0ac341f1SConrad Meyer main(void)
22*0ac341f1SConrad Meyer {
23*0ac341f1SConrad Meyer     int i;
24*0ac341f1SConrad Meyer 
25*0ac341f1SConrad Meyer     crypto_core_hsalsa20(secondkey, nonceprefix, firstkey, c);
26*0ac341f1SConrad Meyer     for (i = 0; i < 32; ++i) {
27*0ac341f1SConrad Meyer         if (i > 0) {
28*0ac341f1SConrad Meyer             printf(",");
29*0ac341f1SConrad Meyer         } else {
30*0ac341f1SConrad Meyer             printf(" ");
31*0ac341f1SConrad Meyer         }
32*0ac341f1SConrad Meyer         printf("0x%02x", (unsigned int) secondkey[i]);
33*0ac341f1SConrad Meyer         if (i % 8 == 7) {
34*0ac341f1SConrad Meyer             printf("\n");
35*0ac341f1SConrad Meyer         }
36*0ac341f1SConrad Meyer     }
37*0ac341f1SConrad Meyer     return 0;
38*0ac341f1SConrad Meyer }
39