diff --git a/test/default/box_easy2.c b/test/default/box_easy2.c index c7035138..8ee3cea3 100644 --- a/test/default/box_easy2.c +++ b/test/default/box_easy2.c @@ -5,18 +5,24 @@ unsigned char m[10000]; unsigned char m2[10000]; unsigned char c[crypto_box_MACBYTES + 10000]; -unsigned char nonce[crypto_box_NONCEBYTES]; -unsigned char alicepk[crypto_box_PUBLICKEYBYTES]; -unsigned char alicesk[crypto_box_SECRETKEYBYTES]; -unsigned char bobpk[crypto_box_PUBLICKEYBYTES]; -unsigned char bobsk[crypto_box_SECRETKEYBYTES]; -unsigned char mac[crypto_box_MACBYTES]; int main(void) { - size_t mlen; - size_t i; + unsigned char *alicepk; + unsigned char *alicesk; + unsigned char *bobpk; + unsigned char *bobsk; + unsigned char *mac; + unsigned char *nonce; + size_t mlen; + size_t i; + alicepk = sodium_malloc(crypto_box_PUBLICKEYBYTES); + alicesk = sodium_malloc(crypto_box_SECRETKEYBYTES); + bobpk = sodium_malloc(crypto_box_PUBLICKEYBYTES); + bobsk = sodium_malloc(crypto_box_SECRETKEYBYTES); + mac = sodium_malloc(crypto_box_MACBYTES); + nonce = sodium_malloc(crypto_box_NONCEBYTES); crypto_box_keypair(alicepk, alicesk); crypto_box_keypair(bobpk, bobsk); mlen = (size_t) randombytes_uniform((uint32_t)sizeof m); @@ -53,7 +59,14 @@ int main(void) nonce, bobsk, alicepk); crypto_box_open_detached(m2, c, mac, (unsigned long long) mlen, nonce, alicepk, bobsk); - printf("%d\n", memcmp(m, m2, mlen)); + printf("%d\n", memcmp(m, m2, mlen)); + sodium_free(alicepk); + sodium_free(alicesk); + sodium_free(bobpk); + sodium_free(bobsk); + sodium_free(mac); + sodium_free(nonce); + printf("OK\n"); return 0; } diff --git a/test/default/box_easy2.exp b/test/default/box_easy2.exp index 44e0be8e..524cb98e 100644 --- a/test/default/box_easy2.exp +++ b/test/default/box_easy2.exp @@ -2,3 +2,4 @@ 0 0 0 +OK