From 478a8bb0599da737a1c5513e8f25b48c38d184af Mon Sep 17 00:00:00 2001 From: toddouska Date: Thu, 19 Mar 2015 12:48:32 -0700 Subject: [PATCH] adjust ./configure format, change ed sign/verify to msg from hash --- configure.ac | 2 +- wolfcrypt/benchmark/benchmark.c | 5 +++-- wolfcrypt/src/ed25519.c | 18 +++++++++--------- wolfcrypt/test/test.c | 13 ++++++------- wolfssl/wolfcrypt/ed25519.h | 8 ++++---- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/configure.ac b/configure.ac index d6af10bbf..e34baaf5a 100644 --- a/configure.ac +++ b/configure.ac @@ -653,7 +653,7 @@ AM_CONDITIONAL([BUILD_ECC25519], [test "x$ENABLED_ECC25519" = "xyes"]) # ED25519 AC_ARG_ENABLE([ed25519], - [ AS_HELP_STRING(--enable-ed25519 Enable ED25519 (default: disabled))], + [AS_HELP_STRING([--enable-ed25519],[Enable ED25519 (default: disabled)])], [ ENABLED_ED25519=$enableval ], [ ENABLED_ED25519=no ] ) diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 38a778202..20b727a21 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -1773,7 +1773,7 @@ void bench_ed25519KeySign(void) for(i = 0; i < agreeTimes; i++) { x = sizeof(sig); - ret = wc_ed25519_sign_hash(digest, sizeof(digest), sig, &x, &genKey); + ret = wc_ed25519_sign_msg(digest, sizeof(digest), sig, &x, &genKey); if (ret != 0) { printf("ed25519_sign_hash failed\n"); return; @@ -1790,7 +1790,8 @@ void bench_ed25519KeySign(void) for(i = 0; i < agreeTimes; i++) { int verify = 0; - ret = wc_ed25519_verify_hash(sig, x, digest, sizeof(digest), &verify, &genKey); + ret = wc_ed25519_verify_msg(sig, x, digest, sizeof(digest), &verify, + &genKey); if (ret != 0 || verify != 1) { printf("ed25519_verify_hash failed\n"); return; diff --git a/wolfcrypt/src/ed25519.c b/wolfcrypt/src/ed25519.c index bc1df7df5..54dc25b97 100644 --- a/wolfcrypt/src/ed25519.c +++ b/wolfcrypt/src/ed25519.c @@ -710,8 +710,8 @@ int wc_ed25519_make_key(RNG* rng, int keySz, ed25519_key* key) key is the ed25519 key to use when signing return 0 on success */ -int wc_ed25519_sign_hash(const byte* in, word32 inlen, byte* out, - word32 *outlen, ed25519_key* key) +int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out, + word32 *outlen, ed25519_key* key) { int ret = 0; byte nonce[64]; @@ -761,12 +761,12 @@ int wc_ed25519_sign_hash(const byte* in, word32 inlen, byte* out, /* sig is array of bytes containing the signature siglen is the length of sig byte array - hash the array of bytes containing the message - hashlen length of hash array + msg the array of bytes containing the message + msglen length of msg array stat will be 1 on successful verify and 0 on unsuccessful */ -int wc_ed25519_verify_hash(byte* sig, word32 siglen, const byte* hash, - word32 hashlen, int* stat, ed25519_key* key) +int wc_ed25519_verify_msg(byte* sig, word32 siglen, const byte* msg, + word32 msglen, int* stat, ed25519_key* key) { int ret; word32 sigSz; @@ -777,7 +777,7 @@ int wc_ed25519_verify_hash(byte* sig, word32 siglen, const byte* hash, ge_p2 R; /* sanity check on arguments */ - if (sig == NULL || hash == NULL || stat == NULL || key == NULL) + if (sig == NULL || msg == NULL || stat == NULL || key == NULL) return BAD_FUNC_ARG; ret = 0; @@ -796,7 +796,7 @@ int wc_ed25519_verify_hash(byte* sig, word32 siglen, const byte* hash, ret |= wc_InitSha512(&sha); ret |= wc_Sha512Update(&sha, sig, 32); ret |= wc_Sha512Update(&sha, key->p, 32); - ret |= wc_Sha512Update(&sha, hash, hashlen); + ret |= wc_Sha512Update(&sha, msg, msglen); ret |= wc_Sha512Final(&sha, h); sc_reduce(h); @@ -818,7 +818,7 @@ int wc_ed25519_init(ed25519_key* key) if (key == NULL) return BAD_FUNC_ARG; - ForceZero(key, sizeof(ed25519_key)); + XMEMSET(key, 0, sizeof(ed25519_key)); return 0; } diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index c31ebb6e0..f79ecf0d5 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -5691,7 +5691,7 @@ int ed25519_test(void) pKeySz[i], &key) != 0) return -1021; - if (wc_ed25519_sign_hash(msgs[i], msgSz[i], out, &outlen, &key) + if (wc_ed25519_sign_msg(msgs[i], msgSz[i], out, &outlen, &key) != 0) return -1022; @@ -5699,13 +5699,13 @@ int ed25519_test(void) return -1023; /* test verify on good msg */ - if (wc_ed25519_verify_hash(out, outlen, msgs[i], msgSz[i], &verify, + if (wc_ed25519_verify_msg(out, outlen, msgs[i], msgSz[i], &verify, &key) != 0 || verify != 1) return -1024; /* test verify on bad msg */ out[outlen-1] = out[outlen-1] + 1; - if (wc_ed25519_verify_hash(out, outlen, msgs[i], msgSz[i], &verify, + if (wc_ed25519_verify_msg(out, outlen, msgs[i], msgSz[i], &verify, &key) == 0 || verify == 1) return -1025; @@ -5728,12 +5728,11 @@ int ed25519_test(void) /* clear "out" buffer and test sign with imported keys */ outlen = sizeof(out); XMEMSET(out, 0, sizeof(out)); - if (wc_ed25519_sign_hash(msgs[i], msgSz[i], out, &outlen, &key2) - != 0) + if (wc_ed25519_sign_msg(msgs[i], msgSz[i], out, &outlen, &key2) != 0) return -1030; - if (wc_ed25519_verify_hash(out, outlen, msgs[i], msgSz[i], &verify, - &key2) != 0 || verify != 1) + if (wc_ed25519_verify_msg(out, outlen, msgs[i], msgSz[i], &verify, + &key2) != 0 || verify != 1) return -1031; if (XMEMCMP(out, sigs[i], 64)) diff --git a/wolfssl/wolfcrypt/ed25519.h b/wolfssl/wolfcrypt/ed25519.h index 4446ae8e8..6f9a19989 100644 --- a/wolfssl/wolfcrypt/ed25519.h +++ b/wolfssl/wolfcrypt/ed25519.h @@ -60,11 +60,11 @@ typedef struct { WOLFSSL_API int wc_ed25519_make_key(RNG* rng, int keysize, ed25519_key* key); WOLFSSL_API -int wc_ed25519_sign_hash(const byte* in, word32 inlen, byte* out, - word32 *outlen, ed25519_key* key); +int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out, + word32 *outlen, ed25519_key* key); WOLFSSL_API -int wc_ed25519_verify_hash(byte* sig, word32 siglen, const byte* hash, - word32 hashlen, int* stat, ed25519_key* key); +int wc_ed25519_verify_msg(byte* sig, word32 siglen, const byte* msg, + word32 msglen, int* stat, ed25519_key* key); WOLFSSL_API int wc_ed25519_init(ed25519_key* key); WOLFSSL_API