From 2f1cec73520d66c861d279c961d6cea7aff32bc4 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Fri, 25 Dec 2015 02:00:01 +0100 Subject: [PATCH] Test crypto_box_beforenm() with a small order pk --- test/default/box.c | 2 +- test/default/box_easy2.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/test/default/box.c b/test/default/box.c index b5878de9..9ed686e2 100644 --- a/test/default/box.c +++ b/test/default/box.c @@ -12,7 +12,7 @@ static const unsigned char bobpk[32] 0xc2, 0xec, 0xe4, 0x35, 0x37, 0x3f, 0x83, 0x43, 0xc8, 0x5b, 0x78, 0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f }; -static const unsigned char small_order_p[crypto_scalarmult_BYTES] +static const unsigned char small_order_p[crypto_box_PUBLICKEYBYTES] = { 0xe0, 0xeb, 0x7a, 0x7c, 0x3b, 0x41, 0xb8, 0xae, 0x16, 0x56, 0xe3, 0xfa, 0xf1, 0x9f, 0xc4, 0x6a, 0xda, 0x09, 0x8d, 0xeb, 0x9c, 0x32, 0xb1, 0xfd, 0x86, 0x62, 0x05, 0x16, 0x5f, 0x49, 0xb8, 0x00 }; diff --git a/test/default/box_easy2.c b/test/default/box_easy2.c index 9293d783..67478d52 100644 --- a/test/default/box_easy2.c +++ b/test/default/box_easy2.c @@ -2,6 +2,11 @@ #define TEST_NAME "box_easy2" #include "cmptest.h" +static const unsigned char small_order_p[crypto_box_PUBLICKEYBYTES] + = { 0xe0, 0xeb, 0x7a, 0x7c, 0x3b, 0x41, 0xb8, 0xae, 0x16, 0x56, 0xe3, + 0xfa, 0xf1, 0x9f, 0xc4, 0x6a, 0xda, 0x09, 0x8d, 0xeb, 0x9c, 0x32, + 0xb1, 0xfd, 0x86, 0x62, 0x05, 0x16, 0x5f, 0x49, 0xb8, 0x00 }; + int main(void) { unsigned char *alicepk; @@ -68,6 +73,11 @@ int main(void) printf("crypto_box_open_easy() failed\n"); } + ret = crypto_box_beforenm(k1, small_order_p, bobsk); + assert(ret == -1); + ret = crypto_box_beforenm(k2, small_order_p, alicesk); + assert(ret == -1); + ret = crypto_box_beforenm(k1, alicepk, bobsk); assert(ret == 0); ret = crypto_box_beforenm(k2, bobpk, alicesk);