Merge pull request #3072 from kaleb-himes/SANITY_CHECKS

ed25519 and ed448 check sigLen against expected
pull/3084/head
Sean Parkinson 2020-06-26 08:31:55 +10:00 committed by GitHub
commit f6d26b4e81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View File

@ -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) {

View File

@ -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 */

View File

@ -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;
}
}