Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Unified Diff: net/cert/internal/signature_algorithm_unittest.cc

Issue 2728953003: Add support for MD2, MD4, and MD5 to SignatureAlgorithm. (Closed)
Patch Set: wow. dumb Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cert/internal/signature_algorithm.cc ('k') | net/cert/internal/signature_policy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/internal/signature_algorithm_unittest.cc
diff --git a/net/cert/internal/signature_algorithm_unittest.cc b/net/cert/internal/signature_algorithm_unittest.cc
index 2c124ada0d6e00e5c6cd331dcea626f52a815937..6e7c47318b98dca68e809e3df73a748fb97c0d73 100644
--- a/net/cert/internal/signature_algorithm_unittest.cc
+++ b/net/cert/internal/signature_algorithm_unittest.cc
@@ -1064,6 +1064,69 @@ TEST(SignatureAlgorithmTest, ParseDerRsaPssNonDefaultHashAndMaskGenAndSalt) {
EXPECT_EQ(10u, params->salt_length());
}
+// Parses a md5WithRSAEncryption which contains a NULL parameters field.
+//
+// SEQUENCE (2 elem)
+// OBJECT IDENTIFIER 1.2.840.113549.1.1.4
+// NULL
+TEST(SignatureAlgorithmTest, ParseDerMd5WithRsaEncryptionNullParams) {
+ // clang-format off
+ const uint8_t kData[] = {
+ 0x30, 0x0D, // SEQUENCE (13 bytes)
+ 0x06, 0x09, // OBJECT IDENTIFIER (9 bytes)
+ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x04,
+ 0x05, 0x00, // NULL (0 bytes)
+ };
+ // clang-format on
+ std::unique_ptr<SignatureAlgorithm> algorithm;
+ ASSERT_TRUE(ParseDer(kData, &algorithm));
+
+ EXPECT_EQ(SignatureAlgorithmId::RsaPkcs1, algorithm->algorithm());
+ EXPECT_EQ(DigestAlgorithm::Md5, algorithm->digest());
+}
+
+// Parses a md4WithRSAEncryption which contains a NULL parameters field.
+//
+// SEQUENCE (2 elem)
+// OBJECT IDENTIFIER 1.2.840.113549.1.1.3
+// NULL
+TEST(SignatureAlgorithmTest, ParseDerMd4WithRsaEncryptionNullParams) {
+ // clang-format off
+ const uint8_t kData[] = {
+ 0x30, 0x0D, // SEQUENCE (13 bytes)
+ 0x06, 0x09, // OBJECT IDENTIFIER (9 bytes)
+ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x03,
+ 0x05, 0x00, // NULL (0 bytes)
+ };
+ // clang-format on
+ std::unique_ptr<SignatureAlgorithm> algorithm;
+ ASSERT_TRUE(ParseDer(kData, &algorithm));
+
+ EXPECT_EQ(SignatureAlgorithmId::RsaPkcs1, algorithm->algorithm());
+ EXPECT_EQ(DigestAlgorithm::Md4, algorithm->digest());
+}
+
+// Parses a md2WithRSAEncryption which contains a NULL parameters field.
+//
+// SEQUENCE (2 elem)
+// OBJECT IDENTIFIER 1.2.840.113549.1.1.2
+// NULL
+TEST(SignatureAlgorithmTest, ParseDerMd2WithRsaEncryptionNullParams) {
+ // clang-format off
+ const uint8_t kData[] = {
+ 0x30, 0x0D, // SEQUENCE (13 bytes)
+ 0x06, 0x09, // OBJECT IDENTIFIER (9 bytes)
+ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x02,
+ 0x05, 0x00, // NULL (0 bytes)
+ };
+ // clang-format on
+ std::unique_ptr<SignatureAlgorithm> algorithm;
+ ASSERT_TRUE(ParseDer(kData, &algorithm));
+
+ EXPECT_EQ(SignatureAlgorithmId::RsaPkcs1, algorithm->algorithm());
+ EXPECT_EQ(DigestAlgorithm::Md2, algorithm->digest());
+}
+
} // namespace
} // namespace net
« no previous file with comments | « net/cert/internal/signature_algorithm.cc ('k') | net/cert/internal/signature_policy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698