diff --git a/tests/api.c b/tests/api.c index 015ed7802..a55a30c87 100644 --- a/tests/api.c +++ b/tests/api.c @@ -14798,6 +14798,13 @@ static int test_wc_ed25519_sign_msg (void) /* Test bad args. */ if (ret == 0) { + AssertIntEQ(wc_ed25519_verify_msg(sig, siglen - 1, msg, + msglen, &verify_ok, &key), + BAD_FUNC_ARG); + AssertIntEQ(wc_ed25519_verify_msg(sig, siglen + 1, msg, + msglen, &verify_ok, &key), + BAD_FUNC_ARG); + ret = wc_ed25519_verify_msg(NULL, siglen, msg, msglen, &verify_ok, &key); if (ret == BAD_FUNC_ARG) { @@ -15547,6 +15554,15 @@ static int test_wc_ed448_sign_msg (void) /* Test bad args. */ if (ret == 0) { + AssertIntEQ(wc_ed448_verify_msg(sig, siglen - 1, msg, + msglen, &verify_ok, &key, + NULL, 0), + BAD_FUNC_ARG); + AssertIntEQ(wc_ed448_verify_msg(sig, siglen + 1, msg, + msglen, &verify_ok, &key, + NULL, 0), + BAD_FUNC_ARG); + ret = wc_ed448_verify_msg(NULL, siglen, msg, msglen, &verify_ok, &key, NULL, 0); if (ret == BAD_FUNC_ARG) { diff --git a/wolfcrypt/src/ed25519.c b/wolfcrypt/src/ed25519.c index b78732d5e..64aee3389 100644 --- a/wolfcrypt/src/ed25519.c +++ b/wolfcrypt/src/ed25519.c @@ -365,7 +365,7 @@ static int ed25519_verify_msg(const byte* sig, word32 sigLen, const byte* msg, *res = 0; /* check on basics needed to verify signature */ - if (sigLen < ED25519_SIG_SIZE || (sig[ED25519_SIG_SIZE-1] & 224)) + if (sigLen != ED25519_SIG_SIZE || (sig[ED25519_SIG_SIZE-1] & 224)) return BAD_FUNC_ARG; /* uncompress A (public key), test if valid, and negate it */ diff --git a/wolfcrypt/src/ed448.c b/wolfcrypt/src/ed448.c index edeec0707..a25fc5bcc 100644 --- a/wolfcrypt/src/ed448.c +++ b/wolfcrypt/src/ed448.c @@ -379,7 +379,7 @@ static int ed448_verify_msg(const byte* sig, word32 sigLen, const byte* msg, *res = 0; /* check on basics needed to verify signature */ - if (sigLen < ED448_SIG_SIZE) { + if (sigLen != ED448_SIG_SIZE) { ret = BAD_FUNC_ARG; } }