]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
ecp_s390x_nistp.c: Reject negative digest length to prevent size_t underflow
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Tue, 31 Mar 2026 15:53:47 +0000 (23:53 +0800)
committerNorbert Pocs <norbertp@openssl.org>
Wed, 15 Apr 2026 11:00:57 +0000 (13:00 +0200)
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
MergeDate: Wed Apr 15 11:01:20 2026
(Merged from https://github.com/openssl/openssl/pull/30648)

crypto/ec/ecp_s390x_nistp.c

index d940e9106b89224804ed53c1899923a744bc6a9a..4b3fbb2f79680c324a0eb4f0e234e5c17ffc70eb 100644 (file)
@@ -145,6 +145,11 @@ static ECDSA_SIG *ecdsa_s390x_nistp_sign_sig(const unsigned char *dgst,
 #endif
     int off;
 
+    if (dgstlen < 0) {
+        ERR_raise(ERR_LIB_EC, EC_R_INVALID_LENGTH);
+        return NULL;
+    }
+
     group = EC_KEY_get0_group(eckey);
     order = EC_GROUP_get0_order(group);
     privkey = EC_KEY_get0_private_key(eckey);
@@ -285,6 +290,11 @@ static int ecdsa_s390x_nistp_verify_sig(const unsigned char *dgst, int dgstlen,
     const EC_POINT *pubkey;
     int off;
 
+    if (dgstlen < 0) {
+        ERR_raise(ERR_LIB_EC, EC_R_INVALID_LENGTH);
+        return -1;
+    }
+
     group = EC_KEY_get0_group(eckey);
     pubkey = EC_KEY_get0_public_key(eckey);
     if (eckey == NULL || group == NULL || pubkey == NULL || sig == NULL) {