mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-10-24 04:09:07 +03:00
Fix CVE-2026-5194 in ecc.c
This commit is contained in:
committed by
Daniel Pouzzner
parent
836be9d8fc
commit
3d0d20e38e
@@ -123,6 +123,7 @@ ECC Curve Sizes:
|
||||
|
||||
#include <wolfssl/wolfcrypt/ecc.h>
|
||||
#include <wolfssl/wolfcrypt/asn.h>
|
||||
#include <wolfssl/wolfcrypt/hash.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
#include <wolfssl/wolfcrypt/types.h>
|
||||
@@ -136,9 +137,6 @@ ECC Curve Sizes:
|
||||
#include <wolfssl/wolfcrypt/aes.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_X963_KDF
|
||||
#include <wolfssl/wolfcrypt/hash.h>
|
||||
#endif
|
||||
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
#include <wolfssl/wolfcrypt/cryptocb.h>
|
||||
@@ -5381,6 +5379,11 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
|
||||
if (in == NULL || out == NULL || outlen == NULL || key == NULL) {
|
||||
return ECC_BAD_ARG_E;
|
||||
}
|
||||
if ((inlen > WC_MAX_DIGEST_SIZE) ||
|
||||
(inlen < WC_MIN_DIGEST_SIZE))
|
||||
{
|
||||
return BAD_LENGTH_E;
|
||||
}
|
||||
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
if (key->devId != INVALID_DEVID) {
|
||||
@@ -5698,6 +5701,11 @@ int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
|
||||
if (in == NULL || r == NULL || s == NULL || key == NULL || rng == NULL) {
|
||||
return ECC_BAD_ARG_E;
|
||||
}
|
||||
if ((inlen > WC_MAX_DIGEST_SIZE) ||
|
||||
(inlen < WC_MIN_DIGEST_SIZE))
|
||||
{
|
||||
return BAD_LENGTH_E;
|
||||
}
|
||||
|
||||
/* is this a private key? */
|
||||
if (key->type != ECC_PRIVATEKEY && key->type != ECC_PRIVATEKEY_ONLY) {
|
||||
@@ -6879,6 +6887,12 @@ int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
|
||||
return ECC_BAD_ARG_E;
|
||||
}
|
||||
|
||||
/* Check hash length */
|
||||
if ((hashlen > WC_MAX_DIGEST_SIZE) ||
|
||||
(hashlen < WC_MIN_DIGEST_SIZE)) {
|
||||
return BAD_LENGTH_E;
|
||||
}
|
||||
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
if (key->devId != INVALID_DEVID) {
|
||||
err = wc_CryptoCb_EccVerify(sig, siglen, hash, hashlen, res, key);
|
||||
@@ -7084,6 +7098,12 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
||||
if (r == NULL || s == NULL || hash == NULL || res == NULL || key == NULL)
|
||||
return ECC_BAD_ARG_E;
|
||||
|
||||
/* Check hash length */
|
||||
if ((hashlen > WC_MAX_DIGEST_SIZE) ||
|
||||
(hashlen < WC_MIN_DIGEST_SIZE)) {
|
||||
return BAD_LENGTH_E;
|
||||
}
|
||||
|
||||
/* default to invalid signature */
|
||||
*res = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user