]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add a test for an all 0 RSA key
authorMatt Caswell <matt@openssl.org>
Fri, 24 Jun 2022 10:02:22 +0000 (11:02 +0100)
committerTomas Mraz <tomas@openssl.org>
Tue, 28 Jun 2022 15:05:10 +0000 (17:05 +0200)
Testing a key with all values set to 0.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18651)

test/evp_extra_test.c

index b68de52dd776d0913f7c75db6bdd7dc57c72e96e..dfcd317773019ea898fea2f4ebef21a0383b51d4 100644 (file)
@@ -244,6 +244,16 @@ static const unsigned char kExampleBadRSAKeyDER[] = {
     0x8c, 0x95, 0xba, 0xf6, 0x04, 0xb3, 0x0a, 0xf4, 0xcb, 0xf0, 0xce,
 };
 
+/*
+ * kExampleBad2RSAKeyDER is an RSA private key in ASN.1, DER format. All
+ * values are 0.
+ */
+static const unsigned char kExampleBad2RSAKeyDER[] = {
+    0x30, 0x1b, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x02,
+    0x01, 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x02,
+    0x01, 0x00, 0x02, 0x01, 0x00
+};
+
 static const unsigned char kMsg[] = { 1, 2, 3, 4 };
 
 static const unsigned char kSignature[] = {
@@ -556,6 +566,8 @@ static APK_DATA keycheckdata[] = {
      0},
     {kExampleBadRSAKeyDER, sizeof(kExampleBadRSAKeyDER), "RSA", EVP_PKEY_RSA,
      0, 1, 1, 0},
+    {kExampleBad2RSAKeyDER, sizeof(kExampleBad2RSAKeyDER), "RSA", EVP_PKEY_RSA,
+     0, 0, 1 /* Since there are no "params" in an RSA key this passes */, 0},
 #ifndef OPENSSL_NO_EC
     {kExampleECKeyDER, sizeof(kExampleECKeyDER), "EC", EVP_PKEY_EC, 1, 1, 1, 0},
     /* group is also associated in our pub key */