From 06e089ef6a18ba1d461fe7dcfc82b72b8b16e43d Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Mon, 9 Jun 2014 18:43:54 -0700 Subject: [PATCH] Make crypto_sign() test code more explicit. crypto_sign() doesn't just need the secret key. The public key has to follow. Which is why the test vectors are laid out in this order. But this can confuse static analysis, as well as people looking at the test in order to better understand how crypto_sign() works. So, just copy the sk and the pk into a dedicated buffer, for clarity. --- test/default/sign.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/default/sign.c b/test/default/sign.c index b711027b..bb5ca988 100644 --- a/test/default/sign.c +++ b/test/default/sign.c @@ -1054,6 +1054,8 @@ int main(void) { unsigned char sm[1024 + crypto_sign_BYTES]; unsigned char m[1024]; + unsigned char skpk[crypto_sign_SECRETKEYBYTES + + crypto_sign_PUBLICKEYBYTES]; unsigned char pk[crypto_sign_PUBLICKEYBYTES]; unsigned char sk[crypto_sign_SECRETKEYBYTES]; char pk_hex[crypto_sign_PUBLICKEYBYTES * 2 + 1]; @@ -1063,9 +1065,11 @@ int main(void) unsigned int i; for (i = 0U; i < (sizeof test_data) / (sizeof test_data[0]); i++) { + memcpy(skpk, test_data[i].sk, crypto_sign_SECRETKEYBYTES_WITHOUT_PK); + memcpy(skpk + crypto_sign_SECRETKEYBYTES_WITHOUT_PK, + test_data[i].pk, crypto_sign_PUBLICKEYBYTES); if (crypto_sign(sm, &smlen, - (const unsigned char *) test_data[i].m, i, - test_data[i].sk) != 0) { + (const unsigned char *) test_data[i].m, i, skpk) != 0) { printf("crypto_sign() failure: [%u]\n", i); continue; }