2 #define TEST_NAME "box8"
5 static unsigned char alicesk
[crypto_box_SECRETKEYBYTES
];
6 static unsigned char alicepk
[crypto_box_PUBLICKEYBYTES
];
7 static unsigned char bobsk
[crypto_box_SECRETKEYBYTES
];
8 static unsigned char bobpk
[crypto_box_PUBLICKEYBYTES
];
9 static unsigned char n
[crypto_box_NONCEBYTES
];
17 size_t mlen_max
= 1000;
22 m
= (unsigned char *) sodium_malloc(mlen_max
);
23 c
= (unsigned char *) sodium_malloc(mlen_max
);
24 m2
= (unsigned char *) sodium_malloc(mlen_max
);
25 crypto_box_keypair(alicepk
, alicesk
);
26 crypto_box_keypair(bobpk
, bobsk
);
27 for (mlen
= 0; mlen
+ crypto_box_ZEROBYTES
<= mlen_max
; mlen
++) {
28 randombytes_buf(n
, crypto_box_NONCEBYTES
);
29 randombytes_buf(m
+ crypto_box_ZEROBYTES
, mlen
);
30 ret
= crypto_box(c
, m
, mlen
+ crypto_box_ZEROBYTES
, n
, bobpk
, alicesk
);
38 c
[rand() % (mlen
+ crypto_box_ZEROBYTES
)] = rand();
39 if (crypto_box_open(m2
, c
, mlen
+ crypto_box_ZEROBYTES
, n
, alicepk
,
41 for (i
= 0; i
< mlen
+ crypto_box_ZEROBYTES
; ++i
) {