summaryrefslogtreecommitdiff
path: root/gtests/mozpkix_gtest
diff options
context:
space:
mode:
authorDana Keeler <dkeeler@mozilla.com>2022-03-23 18:46:42 +0000
committerDana Keeler <dkeeler@mozilla.com>2022-03-23 18:46:42 +0000
commit40f92302ca27bc338fe056494d7d727eb6e18222 (patch)
tree599695675826bff16b9d85f7d69f5b4dac65f3bc /gtests/mozpkix_gtest
parentabb64a86f852793998bd67100aec58405fb4b9d7 (diff)
downloadnss-hg-40f92302ca27bc338fe056494d7d727eb6e18222.tar.gz
Bug 1005084 - support specific RSA-PSS parameters in mozilla::pkix r=jschanck
This patch adds support to mozilla::pkix for certificates signed with RSA-PSS using one of the following parameters permitted by the CA/Browser Forum Baseline Requirements 1.8.1: * SHA-256, MGF-1 with SHA-256, and a salt length of 32 bytes * SHA-384, MGF-1 with SHA-384, and a salt length of 48 bytes * SHA-512, MGF-1 with SHA-512, and a salt length of 64 bytes Differential Revision: https://phabricator.services.mozilla.com/D141539
Diffstat (limited to 'gtests/mozpkix_gtest')
-rw-r--r--gtests/mozpkix_gtest/pkixcheck_CheckSignatureAlgorithm_tests.cpp26
-rw-r--r--gtests/mozpkix_gtest/pkixder_pki_types_tests.cpp110
-rw-r--r--gtests/mozpkix_gtest/pkixgtest.h6
-rw-r--r--gtests/mozpkix_gtest/pkixnss_tests.cpp217
4 files changed, 344 insertions, 15 deletions
diff --git a/gtests/mozpkix_gtest/pkixcheck_CheckSignatureAlgorithm_tests.cpp b/gtests/mozpkix_gtest/pkixcheck_CheckSignatureAlgorithm_tests.cpp
index 90bd6d777..bd61ef2a4 100644
--- a/gtests/mozpkix_gtest/pkixcheck_CheckSignatureAlgorithm_tests.cpp
+++ b/gtests/mozpkix_gtest/pkixcheck_CheckSignatureAlgorithm_tests.cpp
@@ -81,6 +81,18 @@ static const uint8_t tlv_md5WithRSAEncryption[] = {
0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x04
};
+// CA/B Forum BR 1.8.1 Section 7.1.3.2.1
+// Params for RSA-PSS with SHA-256, MGF-1 with SHA-256, and a salt length
+// of 32 bytes:
+static const uint8_t rsaPSSWithSHA256[] = {
+ 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0a, 0x30,
+ 0x34, 0xa0, 0x0f, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65,
+ 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0xa1, 0x1c, 0x30, 0x1a, 0x06, 0x09,
+ 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x08, 0x30, 0x0d, 0x06,
+ 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00,
+ 0xa2, 0x03, 0x02, 0x01, 0x20
+};
+
static const CheckSignatureAlgorithmTestParams
CHECKSIGNATUREALGORITHM_TEST_PARAMS[] =
{
@@ -191,6 +203,20 @@ static const CheckSignatureAlgorithmTestParams
(2048 / 8) - 1,
Success
},
+ {
+ // signatureAlgorithm and signature are RSA-PSS
+ BS(rsaPSSWithSHA256),
+ BS(rsaPSSWithSHA256),
+ 2048 / 8,
+ Success
+ },
+ {
+ // signatureAlgorithm is RSA-PSS, signature is RSA PKCS#1v1.5
+ BS(rsaPSSWithSHA256),
+ BS(tlv_sha256WithRSAEncryption),
+ 2048 / 8,
+ Result::ERROR_SIGNATURE_ALGORITHM_MISMATCH
+ },
};
class pkixcheck_CheckSignatureAlgorithm
diff --git a/gtests/mozpkix_gtest/pkixder_pki_types_tests.cpp b/gtests/mozpkix_gtest/pkixder_pki_types_tests.cpp
index bdde10ebb..fa5c55123 100644
--- a/gtests/mozpkix_gtest/pkixder_pki_types_tests.cpp
+++ b/gtests/mozpkix_gtest/pkixder_pki_types_tests.cpp
@@ -189,7 +189,7 @@ TEST_F(pkixder_pki_types_tests, OptionalVersionMissing)
ASSERT_EQ(der::Version::v1, version);
}
-static const size_t MAX_ALGORITHM_OID_DER_LENGTH = 13;
+static const size_t MAX_ALGORITHM_OID_DER_LENGTH = 65;
struct InvalidAlgorithmIdentifierTestInfo
{
@@ -312,6 +312,7 @@ struct ValidSignatureAlgorithmIdentifierValueTestInfo
DigestAlgorithm digestAlg;
uint8_t der[MAX_ALGORITHM_OID_DER_LENGTH];
size_t derLength;
+ bool explicitNullAllowed;
};
static const ValidSignatureAlgorithmIdentifierValueTestInfo
@@ -323,44 +324,51 @@ static const ValidSignatureAlgorithmIdentifierValueTestInfo
{ 0x06, 0x08,
0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x04 },
10,
+ true,
},
{ PublicKeyAlgorithm::ECDSA,
DigestAlgorithm::sha384,
{ 0x06, 0x08,
0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x03 },
10,
+ true,
},
{ PublicKeyAlgorithm::ECDSA,
DigestAlgorithm::sha256,
{ 0x06, 0x08,
0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02 },
10,
+ true,
},
{ PublicKeyAlgorithm::ECDSA,
DigestAlgorithm::sha1,
{ 0x06, 0x07,
0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x01 },
9,
+ true,
},
- // RSA
+ // RSA PKCS#1 1.5
{ PublicKeyAlgorithm::RSA_PKCS1,
DigestAlgorithm::sha512,
{ 0x06, 0x09,
0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0d },
11,
+ true,
},
{ PublicKeyAlgorithm::RSA_PKCS1,
DigestAlgorithm::sha384,
{ 0x06, 0x09,
0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0c },
11,
+ true,
},
{ PublicKeyAlgorithm::RSA_PKCS1,
DigestAlgorithm::sha256,
{ 0x06, 0x09,
0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b },
11,
+ true,
},
{ PublicKeyAlgorithm::RSA_PKCS1,
DigestAlgorithm::sha1,
@@ -368,6 +376,7 @@ static const ValidSignatureAlgorithmIdentifierValueTestInfo
{ 0x06, 0x09,
0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05 },
11,
+ true,
},
{ PublicKeyAlgorithm::RSA_PKCS1,
DigestAlgorithm::sha1,
@@ -375,6 +384,44 @@ static const ValidSignatureAlgorithmIdentifierValueTestInfo
{ 0x06, 0x05,
0x2b, 0x0e, 0x03, 0x02, 0x1d },
7,
+ true,
+ },
+
+ // RSA-PSS
+ { PublicKeyAlgorithm::RSA_PSS,
+ DigestAlgorithm::sha256,
+ { 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0a, 0x30,
+ 0x34, 0xa0, 0x0f, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65,
+ 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0xa1, 0x1c, 0x30, 0x1a, 0x06, 0x09,
+ 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x08, 0x30, 0x0d, 0x06,
+ 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00,
+ 0xa2, 0x03, 0x02, 0x01, 0x20 },
+ 65,
+ false,
+ },
+
+ { PublicKeyAlgorithm::RSA_PSS,
+ DigestAlgorithm::sha384,
+ { 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0a, 0x30,
+ 0x34, 0xa0, 0x0f, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65,
+ 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0xa1, 0x1c, 0x30, 0x1a, 0x06, 0x09,
+ 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x08, 0x30, 0x0d, 0x06,
+ 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00,
+ 0xa2, 0x03, 0x02, 0x01, 0x30 },
+ 65,
+ false,
+ },
+
+ { PublicKeyAlgorithm::RSA_PSS,
+ DigestAlgorithm::sha512,
+ { 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0a, 0x30,
+ 0x34, 0xa0, 0x0f, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65,
+ 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0xa1, 0x1c, 0x30, 0x1a, 0x06, 0x09,
+ 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x08, 0x30, 0x0d, 0x06,
+ 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00,
+ 0xa2, 0x03, 0x02, 0x01, 0x40 },
+ 65,
+ false,
},
};
@@ -403,20 +450,22 @@ TEST_P(pkixder_SignatureAlgorithmIdentifierValue_Valid, Valid)
ASSERT_EQ(Success, End(reader));
}
- {
- uint8_t derWithNullParam[MAX_ALGORITHM_OID_DER_LENGTH + 2];
- memcpy(derWithNullParam, param.der, param.derLength);
- derWithNullParam[param.derLength] = 0x05; // NULL tag
- derWithNullParam[param.derLength + 1] = 0x00; // length zero
+ uint8_t derWithNullParam[MAX_ALGORITHM_OID_DER_LENGTH + 2];
+ memcpy(derWithNullParam, param.der, param.derLength);
+ derWithNullParam[param.derLength] = 0x05; // NULL tag
+ derWithNullParam[param.derLength + 1] = 0x00; // length zero
- Input input;
- ASSERT_EQ(Success, input.Init(derWithNullParam, param.derLength + 2));
- Reader reader(input);
- PublicKeyAlgorithm publicKeyAlg;
- DigestAlgorithm digestAlg;
- ASSERT_EQ(Success,
- SignatureAlgorithmIdentifierValue(reader, publicKeyAlg,
- digestAlg));
+ Input input;
+ ASSERT_EQ(Success, input.Init(derWithNullParam, param.derLength + 2));
+ Reader reader(input);
+ PublicKeyAlgorithm publicKeyAlg;
+ DigestAlgorithm digestAlg;
+ ASSERT_EQ(param.explicitNullAllowed
+ ? Success
+ : Result::ERROR_CERT_SIGNATURE_ALGORITHM_DISABLED,
+ SignatureAlgorithmIdentifierValue(reader, publicKeyAlg,
+ digestAlg));
+ if (param.explicitNullAllowed) {
ASSERT_EQ(param.publicKeyAlg, publicKeyAlg);
ASSERT_EQ(param.digestAlg, digestAlg);
ASSERT_EQ(Success, End(reader));
@@ -455,6 +504,37 @@ static const InvalidAlgorithmIdentifierTestInfo
0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01 },
11,
},
+
+ // RSA-PSS with SHA-256, MGF-1 with SHA-256, and a salt length of 48 bytes
+ { { 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0a, 0x30,
+ 0x34, 0xa0, 0x0f, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65,
+ 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0xa1, 0x1c, 0x30, 0x1a, 0x06, 0x09,
+ 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x08, 0x30, 0x0d, 0x06,
+ 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00,
+ 0xa2, 0x03, 0x02, 0x01, 0x30 },
+ 65,
+ },
+
+ // RSA-PSS with SHA-512, MGF-1 with SHA-256, and a salt length of 32 bytes
+ { { 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0a, 0x30,
+ 0x34, 0xa0, 0x0f, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65,
+ 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0xa1, 0x1c, 0x30, 0x1a, 0x06, 0x09,
+ 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x08, 0x30, 0x0d, 0x06,
+ 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00,
+ 0xa2, 0x03, 0x02, 0x01, 0x20 },
+ 65,
+ },
+
+ // RSA-PSS with omitted parameters
+ { { 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0a },
+ 11,
+ },
+
+ // RSA-PSS with NULL parameters
+ { { 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0a,
+ 0x05, 0x00 },
+ 13,
+ },
};
class pkixder_SignatureAlgorithmIdentifier_Invalid
diff --git a/gtests/mozpkix_gtest/pkixgtest.h b/gtests/mozpkix_gtest/pkixgtest.h
index 92f69350f..16b7b4983 100644
--- a/gtests/mozpkix_gtest/pkixgtest.h
+++ b/gtests/mozpkix_gtest/pkixgtest.h
@@ -155,6 +155,12 @@ class EverythingFailsByDefaultTrustDomain : public TrustDomain {
Result::FATAL_ERROR_LIBRARY_FAILURE);
}
+ Result VerifyRSAPSSSignedData(Input, DigestAlgorithm, Input, Input) override {
+ ADD_FAILURE();
+ return NotReached("VerifyRSAPSSSignedData should not be called",
+ Result::FATAL_ERROR_LIBRARY_FAILURE);
+ }
+
Result CheckValidityIsAcceptable(Time, Time, EndEntityOrCA,
KeyPurposeId) override {
ADD_FAILURE();
diff --git a/gtests/mozpkix_gtest/pkixnss_tests.cpp b/gtests/mozpkix_gtest/pkixnss_tests.cpp
index 7a556284a..ba14fa9c3 100644
--- a/gtests/mozpkix_gtest/pkixnss_tests.cpp
+++ b/gtests/mozpkix_gtest/pkixnss_tests.cpp
@@ -189,6 +189,140 @@ static const uint8_t kRsaPkcs1Sha512Signature[] = {
0xc2, 0xe9, 0x62, 0x07
};
+static const uint8_t kRsaPssSubj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e7, 0x32, 0xf3, 0xd2,
+ 0x55, 0x6c, 0x8f, 0x38, 0xb8, 0x1b, 0x38, 0x08, 0x4c, 0x1f, 0x41, 0x74,
+ 0x35, 0x9e, 0x2d, 0x29, 0xed, 0x72, 0xe3, 0xda, 0x18, 0x01, 0xf4, 0x5f,
+ 0x8d, 0x9d, 0x72, 0x13, 0x18, 0x09, 0x1f, 0xbe, 0xb0, 0x20, 0x90, 0xc4,
+ 0x3d, 0x2c, 0x4f, 0xf2, 0xdc, 0x99, 0x8a, 0xae, 0x02, 0xd6, 0xef, 0x5a,
+ 0x88, 0x08, 0x15, 0x85, 0xdd, 0xaa, 0xce, 0xe4, 0x4b, 0x3f, 0xe9, 0xf4,
+ 0xfa, 0x54, 0xde, 0xb0, 0x30, 0xdf, 0x8f, 0x14, 0x2c, 0x49, 0x69, 0x24,
+ 0xe4, 0xa9, 0xeb, 0x62, 0x15, 0xf8, 0x8a, 0xd8, 0xe4, 0x8a, 0x99, 0x2b,
+ 0xdb, 0x68, 0x8b, 0x2a, 0x61, 0xbd, 0xc0, 0x57, 0xff, 0x5f, 0xee, 0xe9,
+ 0xac, 0x06, 0x77, 0x13, 0x7b, 0x2e, 0xd1, 0x76, 0x6c, 0xe8, 0x6c, 0x73,
+ 0x1f, 0x02, 0x03, 0x01, 0x00, 0x01
+};
+
+// Use `openssl dgst -binary -sha1` to obtain the hash of the data, and then
+// `openssl pkeyutl` with `-pkeyopt rsa_padding_mode:pss`, `-pkeyopt
+// digest:sha1`, and `-pkeyopt rsa_pss_saltlen:-1` to create the signature.
+static const uint8_t kRsaPssSha1Signature[] = {
+ 0xa9, 0xd9, 0x36, 0x19, 0x90, 0x3d, 0x58, 0xa6, 0x66, 0xae, 0x8e, 0xab,
+ 0xb5, 0x7d, 0xe7, 0x8c, 0xcf, 0x3c, 0x69, 0xd8, 0xba, 0x22, 0xe1, 0x35,
+ 0x9a, 0x88, 0xfd, 0xf1, 0x01, 0x75, 0x71, 0x05, 0x60, 0xcf,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b8, 0x9d, 0xb2, 0x58, 0x8f, 0x55, 0xbd,
+ 0x2f, 0xf6, 0xce, 0x05, 0xd3, 0xc5, 0x6b, 0x84, 0x6c, 0x1b, 0x77, 0x00,
+ 0x7e, 0xfb, 0xa4, 0x01, 0x0f, 0xf5, 0x9d, 0x9a, 0xc7, 0xe3, 0xa4, 0xdb,
+ 0xac, 0x87, 0x3b, 0x50, 0x66, 0xd2, 0xf5, 0xaf, 0x51, 0x28, 0xb4, 0x5e,
+ 0x6e, 0xca, 0x74, 0xaa
+};
+
+// As above, but with sha256.
+static const uint8_t kRsaPssSha256Signature[] = {
+ 0x34, 0x01, 0x2e, 0x0b, 0xba, 0x00, 0x2a, 0x66, 0x50, 0x5a, 0x6c, 0xf8,
+ 0x3b, 0x7f, 0xda, 0x43, 0xd1, 0x56, 0x75, 0xc8, 0xa9, 0x7a, 0xa9, 0x53,
+ 0xc8, 0xb3, 0xca, 0x92, 0x68, 0x8d, 0x68, 0x90, 0x93, 0xf3, 0xfd, 0xb3,
+ 0x66, 0x3d, 0x81, 0xe4, 0x6e, 0x7d, 0x46, 0x57, 0x86, 0x0d, 0xd5, 0x58,
+ 0x46, 0x27, 0x4f, 0xae, 0xab, 0x55, 0x1f, 0x25, 0xdd, 0x43, 0xac, 0x72,
+ 0x50, 0x0c, 0x24, 0x87, 0xbb, 0xf9, 0x08, 0x4a, 0x47, 0x43, 0xff, 0x7a,
+ 0x40, 0x8a, 0xd6, 0x69, 0x99, 0xe8, 0x65, 0x66, 0x4d, 0x73, 0x9f, 0xc5,
+ 0x43, 0x60, 0x44, 0xc6, 0xf8, 0x8a, 0xbd, 0xf2, 0x8a, 0xfc, 0x9f, 0x22,
+ 0xa6, 0x10, 0x4a, 0xa4, 0x8b, 0x70, 0x5b, 0xa1, 0x7c, 0x8c, 0x1a, 0xc3,
+ 0xf2, 0x84, 0xde, 0x03, 0x41, 0x7d, 0xe1, 0x38, 0x09, 0xa2, 0x78, 0x14,
+ 0xf4, 0x2c, 0xa6, 0xf6, 0x8a, 0x1e, 0xcc, 0x91, 0xbf, 0x6c, 0x14, 0xe4,
+ 0xc1, 0x65, 0xc7, 0x74, 0x89, 0x49, 0x24, 0x5c, 0xc6, 0x85, 0x58, 0x35,
+ 0x76, 0x9b, 0x9c, 0xa1, 0x3e, 0xef, 0xf7, 0x57, 0xc7, 0x18, 0x70, 0x98,
+ 0x1b, 0xa1, 0x12, 0xae, 0x69, 0x85, 0x1d, 0x0d, 0xa6, 0xec, 0x94, 0x7f,
+ 0xab, 0x77, 0x08, 0xfc, 0x89, 0x69, 0x9c, 0x51, 0xa1, 0x01, 0xd6, 0xc8,
+ 0xc2, 0xbf, 0xc7, 0x63, 0xa3, 0xce, 0xca, 0xc9, 0x11, 0xfd, 0x78, 0x62,
+ 0x5d, 0x80, 0x15, 0x10, 0x75, 0xcd, 0xd8, 0xc9, 0x7f, 0xd2, 0xcb, 0x32,
+ 0x35, 0x0d, 0xc0, 0x56, 0x0e, 0xa4, 0xa5, 0x2d, 0xe3, 0xeb, 0x1e, 0x30,
+ 0x60, 0x35, 0x1d, 0xe8, 0xb5, 0x27, 0xa1, 0x46, 0x61, 0x74, 0xb7, 0xf6,
+ 0x2c, 0x50, 0x4f, 0x23, 0xb3, 0xb0, 0x6b, 0xaf, 0x8d, 0x1a, 0x74, 0x27,
+ 0x58, 0x58, 0x25, 0xc9, 0x45, 0x84, 0xd8, 0x5d, 0xe8, 0x7e, 0xc6, 0x3e,
+ 0xd4, 0xf2, 0xb1, 0x3f
+};
+
+// As above, but with sha384.
+static const uint8_t kRsaPssSha384Signature[] = {
+ 0x42, 0xd1, 0x90, 0xb2, 0x78, 0x76, 0x97, 0x5f, 0xf1, 0x4c, 0xab, 0x1b,
+ 0xe0, 0x80, 0xd6, 0x32, 0xac, 0x57, 0x93, 0x2e, 0x03, 0xb7, 0xec, 0x9f,
+ 0x48, 0x72, 0x91, 0x12, 0xb7, 0x2b, 0xaf, 0x69, 0xc6, 0x2d, 0xde, 0x6a,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 0x19, 0x38, 0x00, 0x99, 0xfe, 0xcb, 0xfb, 0x41, 0xda,
+ 0xce, 0x45, 0xf2, 0x65, 0x5b, 0x3b, 0x9d, 0x34, 0x7e, 0x48, 0x40, 0x63,
+ 0x67, 0xfa, 0xbe, 0x34, 0xaf, 0xf5, 0x69, 0xa3, 0x40, 0x8d, 0x1b, 0xae,
+ 0x84, 0x0f, 0x3b, 0x1f, 0xc4, 0x00, 0x8b, 0x8a, 0x64, 0x9f, 0xca, 0xfc,
+ 0x0c, 0x58, 0x6e, 0xfd, 0x8a, 0xb5, 0x11, 0x3d, 0x2b, 0x7d, 0xf1, 0xdd,
+ 0x08, 0xe9, 0x1d, 0x27, 0x18, 0x1e, 0x31, 0xc1, 0xec, 0x10, 0xe6, 0x5b,
+ 0x39, 0xcc, 0x9f, 0x2e, 0x9c, 0x41, 0x4c, 0x47, 0x77, 0x36, 0x5f, 0x2c,
+ 0x5b, 0x8c, 0x16, 0x96, 0x7f, 0x1f, 0xa8, 0x30, 0x3b, 0x34, 0x2f, 0xa2,
+ 0x44, 0x41, 0x49, 0x68, 0x3a, 0x75, 0xa5, 0xb4, 0xde, 0xd2, 0x89, 0x72,
+ 0x7c, 0x6e, 0x83, 0x54, 0x30, 0x9c, 0x1e, 0x9b, 0x58, 0xb0, 0xa3, 0x2c,
+ 0xdf, 0x3d, 0x69, 0xff, 0xe1, 0x4c, 0x28, 0x4a, 0x19, 0xec, 0x0b, 0x4c,
+ 0x0a, 0x7e, 0xb7, 0xd4
+};
+
static const uint8_t kEC256SubjectPublicKeyInfo[] = {
0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03,
@@ -311,6 +445,39 @@ static const VerifySignedDataNSSTestParams
BS(kRsaSubjectPublicKeyInfo),
Success,
},
+ // SHA-1 is not allowed for RSA-PSS
+ {
+ BS(kData),
+ DigestAlgorithm::sha1,
+ BS(kRsaPssSha1Signature),
+ PublicKeyAlgorithm::RSA_PSS,
+ BS(kRsaPssSubjectPublicKeyInfo),
+ Result::ERROR_CERT_SIGNATURE_ALGORITHM_DISABLED,
+ },
+ {
+ BS(kData),
+ DigestAlgorithm::sha256,
+ BS(kRsaPssSha256Signature),
+ PublicKeyAlgorithm::RSA_PSS,
+ BS(kRsaPssSubjectPublicKeyInfo),
+ Success,
+ },
+ {
+ BS(kData),
+ DigestAlgorithm::sha384,
+ BS(kRsaPssSha384Signature),
+ PublicKeyAlgorithm::RSA_PSS,
+ BS(kRsaPssSubjectPublicKeyInfo),
+ Success,
+ },
+ {
+ BS(kData),
+ DigestAlgorithm::sha512,
+ BS(kRsaPssSha512Signature),
+ PublicKeyAlgorithm::RSA_PSS,
+ BS(kRsaPssSubjectPublicKeyInfo),
+ Success,
+ },
{
BS(kData),
DigestAlgorithm::sha1,
@@ -352,6 +519,15 @@ static const VerifySignedDataNSSTestParams
BS(kRsaSubjectPublicKeyInfo),
Result::ERROR_BAD_SIGNATURE,
},
+ // Wrong digest algorithm - RSA PSS
+ {
+ BS(kData),
+ DigestAlgorithm::sha512,
+ BS(kRsaPssSha384Signature),
+ PublicKeyAlgorithm::RSA_PSS,
+ BS(kRsaPssSubjectPublicKeyInfo),
+ Result::ERROR_BAD_SIGNATURE,
+ },
// Wrong digest algorithm - ECDSA
{
BS(kData),
@@ -379,6 +555,42 @@ static const VerifySignedDataNSSTestParams
BS(kRsaSubjectPublicKeyInfo),
Result::ERROR_BAD_SIGNATURE,
},
+ // RSA PKCS#1 key for RSA PSS signature
+ {
+ BS(kData),
+ DigestAlgorithm::sha256,
+ BS(kRsaPssSha256Signature),
+ PublicKeyAlgorithm::RSA_PKCS1,
+ BS(kRsaSubjectPublicKeyInfo),
+ Result::ERROR_BAD_SIGNATURE,
+ },
+ // RSA PSS key for RSA PKCS#1 signature
+ {
+ BS(kData),
+ DigestAlgorithm::sha256,
+ BS(kRsaPkcs1Sha256Signature),
+ PublicKeyAlgorithm::RSA_PSS,
+ BS(kRsaPssSubjectPublicKeyInfo),
+ Result::ERROR_BAD_SIGNATURE,
+ },
+ // ECDSA key for RSA PSS signature
+ {
+ BS(kData),
+ DigestAlgorithm::sha256,
+ BS(kRsaPssSha256Signature),
+ PublicKeyAlgorithm::ECDSA,
+ BS(kEC256SubjectPublicKeyInfo),
+ Result::ERROR_BAD_SIGNATURE,
+ },
+ // RSA PSS key for ECDSA signature
+ {
+ BS(kData),
+ DigestAlgorithm::sha256,
+ BS(kEC256Signature),
+ PublicKeyAlgorithm::RSA_PSS,
+ BS(kRsaPssSubjectPublicKeyInfo),
+ Result::ERROR_BAD_SIGNATURE,
+ },
// Wrong data.
{
BS(kRsaSubjectPublicKeyInfo),
@@ -406,6 +618,11 @@ void CheckVerifySignedData(PublicKeyAlgorithm publicKeyAlgorithm, Input data,
VerifyRSAPKCS1SignedDataNSS(data, digestAlgorithm, signature,
subjectPublicKeyInfo, nullptr));
break;
+ case PublicKeyAlgorithm::RSA_PSS:
+ ASSERT_EQ(expectedResult,
+ VerifyRSAPSSSignedDataNSS(data, digestAlgorithm, signature,
+ subjectPublicKeyInfo, nullptr));
+ break;
case PublicKeyAlgorithm::ECDSA:
ASSERT_EQ(expectedResult,
VerifyECDSASignedDataNSS(data, digestAlgorithm, signature,