1*0ac341f1SConrad Meyer
2*0ac341f1SConrad Meyer #define TEST_NAME "scalarmult6"
3*0ac341f1SConrad Meyer #include "cmptest.h"
4*0ac341f1SConrad Meyer
5*0ac341f1SConrad Meyer static unsigned char bobsk_[crypto_scalarmult_SCALARBYTES] = {
6*0ac341f1SConrad Meyer 0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b, 0x79, 0xe1, 0x7f,
7*0ac341f1SConrad Meyer 0x8b, 0x83, 0x80, 0x0e, 0xe6, 0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18,
8*0ac341f1SConrad Meyer 0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb
9*0ac341f1SConrad Meyer };
10*0ac341f1SConrad Meyer
11*0ac341f1SConrad Meyer static unsigned char alicepk_[crypto_scalarmult_SCALARBYTES] = {
12*0ac341f1SConrad Meyer 0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d,
13*0ac341f1SConrad Meyer 0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38,
14*0ac341f1SConrad Meyer 0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a
15*0ac341f1SConrad Meyer };
16*0ac341f1SConrad Meyer
17*0ac341f1SConrad Meyer int
main(void)18*0ac341f1SConrad Meyer main(void)
19*0ac341f1SConrad Meyer {
20*0ac341f1SConrad Meyer unsigned char *k;
21*0ac341f1SConrad Meyer unsigned char *bobsk;
22*0ac341f1SConrad Meyer unsigned char *alicepk;
23*0ac341f1SConrad Meyer int i;
24*0ac341f1SConrad Meyer int ret;
25*0ac341f1SConrad Meyer
26*0ac341f1SConrad Meyer k = (unsigned char *) sodium_malloc(crypto_scalarmult_BYTES);
27*0ac341f1SConrad Meyer bobsk = (unsigned char *) sodium_malloc(crypto_scalarmult_SCALARBYTES);
28*0ac341f1SConrad Meyer alicepk = (unsigned char *) sodium_malloc(crypto_scalarmult_SCALARBYTES);
29*0ac341f1SConrad Meyer assert(k != NULL && bobsk != NULL && alicepk != NULL);
30*0ac341f1SConrad Meyer
31*0ac341f1SConrad Meyer memcpy(bobsk, bobsk_, crypto_scalarmult_SCALARBYTES);
32*0ac341f1SConrad Meyer memcpy(alicepk, alicepk_, crypto_scalarmult_SCALARBYTES);
33*0ac341f1SConrad Meyer
34*0ac341f1SConrad Meyer ret = crypto_scalarmult(k, bobsk, alicepk);
35*0ac341f1SConrad Meyer assert(ret == 0);
36*0ac341f1SConrad Meyer
37*0ac341f1SConrad Meyer sodium_free(alicepk);
38*0ac341f1SConrad Meyer sodium_free(bobsk);
39*0ac341f1SConrad Meyer
40*0ac341f1SConrad Meyer for (i = 0; i < 32; ++i) {
41*0ac341f1SConrad Meyer if (i > 0) {
42*0ac341f1SConrad Meyer printf(",");
43*0ac341f1SConrad Meyer } else {
44*0ac341f1SConrad Meyer printf(" ");
45*0ac341f1SConrad Meyer }
46*0ac341f1SConrad Meyer printf("0x%02x", (unsigned int) k[i]);
47*0ac341f1SConrad Meyer if (i % 8 == 7) {
48*0ac341f1SConrad Meyer printf("\n");
49*0ac341f1SConrad Meyer }
50*0ac341f1SConrad Meyer }
51*0ac341f1SConrad Meyer sodium_free(k);
52*0ac341f1SConrad Meyer
53*0ac341f1SConrad Meyer return 0;
54*0ac341f1SConrad Meyer }
55