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

Side by Side Diff: net/cert/internal/signature_algorithm_unittest.cc

Issue 1223763002: Recognize the legacy OID 1.3.14.3.2.29 (sha1WithRSASignature) as equivalent to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sign_parse_alg
Patch Set: rebase Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « net/cert/internal/signature_algorithm.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/cert/internal/signature_algorithm.h" 5 #include "net/cert/internal/signature_algorithm.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "net/base/test_data_directory.h" 9 #include "net/base/test_data_directory.h"
10 #include "net/cert/pem_tokenizer.h" 10 #include "net/cert/pem_tokenizer.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 0x30, 0x0E, // SEQUENCE (14 bytes) 87 0x30, 0x0E, // SEQUENCE (14 bytes)
88 0x06, 0x09, // OBJECT IDENTIFIER (9 bytes) 88 0x06, 0x09, // OBJECT IDENTIFIER (9 bytes)
89 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05, 89 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05,
90 0x02, 0x01, 0x00, // INTEGER (1 byte) 90 0x02, 0x01, 0x00, // INTEGER (1 byte)
91 }; 91 };
92 // clang-format on 92 // clang-format on
93 scoped_ptr<SignatureAlgorithm> algorithm; 93 scoped_ptr<SignatureAlgorithm> algorithm;
94 ASSERT_FALSE(ParseDer(kData, &algorithm)); 94 ASSERT_FALSE(ParseDer(kData, &algorithm));
95 } 95 }
96 96
97 // Parses a sha1WithRSASignature which contains a NULL parameters field.
98 //
99 // SEQUENCE (2 elem)
100 // OBJECT IDENTIFIER 1.3.14.3.2.29
101 // NULL
102 TEST(SignatureAlgorithmTest, ParseDer_sha1WithRSASignature_NullParams) {
103 // clang-format off
104 const uint8_t kData[] = {
105 0x30, 0x09, // SEQUENCE (9 bytes)
106 0x06, 0x05, // OBJECT IDENTIFIER (5 bytes)
107 0x2b, 0x0e, 0x03, 0x02, 0x1d,
108 0x05, 0x00, // NULL (0 bytes)
109 };
110 // clang-format on
111 scoped_ptr<SignatureAlgorithm> algorithm;
112 ASSERT_TRUE(ParseDer(kData, &algorithm));
113
114 EXPECT_EQ(SignatureAlgorithmId::RsaPkcs1, algorithm->algorithm());
115 EXPECT_EQ(DigestAlgorithm::Sha1, algorithm->digest());
116 }
117
118 // Parses a sha1WithRSASignature which contains no parameters field.
119 //
120 // SEQUENCE (1 elem)
121 // OBJECT IDENTIFIER 1.3.14.3.2.29
122 TEST(SignatureAlgorithmTest, ParseDer_sha1WithRSASignature_NoParams) {
123 // clang-format off
124 const uint8_t kData[] = {
125 0x30, 0x07, // SEQUENCE (7 bytes)
126 0x06, 0x05, // OBJECT IDENTIFIER (5 bytes)
127 0x2b, 0x0e, 0x03, 0x02, 0x1d,
128 };
129 // clang-format on
130 scoped_ptr<SignatureAlgorithm> algorithm;
131 ASSERT_FALSE(ParseDer(kData, &algorithm));
132 }
133
97 // Parses a sha1WithRSAEncryption which contains values after the sequence. 134 // Parses a sha1WithRSAEncryption which contains values after the sequence.
98 // 135 //
99 // SEQUENCE (2 elem) 136 // SEQUENCE (2 elem)
100 // OBJECT IDENTIFIER 1.2.840.113549.1.1.5 137 // OBJECT IDENTIFIER 1.2.840.113549.1.1.5
101 // NULL 138 // NULL
102 // INTEGER 0 139 // INTEGER 0
103 TEST(SignatureAlgorithmTest, ParseDer_sha1WithRsaEncryption_DataAfterSequence) { 140 TEST(SignatureAlgorithmTest, ParseDer_sha1WithRsaEncryption_DataAfterSequence) {
104 // clang-format off 141 // clang-format off
105 const uint8_t kData[] = { 142 const uint8_t kData[] = {
106 0x30, 0x0D, // SEQUENCE (13 bytes) 143 0x30, 0x0D, // SEQUENCE (13 bytes)
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 TEST(SignatureAlgorithmTest, ParamsAreNullForWrongType_RsaPkcs1) { 599 TEST(SignatureAlgorithmTest, ParamsAreNullForWrongType_RsaPkcs1) {
563 scoped_ptr<SignatureAlgorithm> alg1 = 600 scoped_ptr<SignatureAlgorithm> alg1 =
564 SignatureAlgorithm::CreateRsaPkcs1(DigestAlgorithm::Sha1); 601 SignatureAlgorithm::CreateRsaPkcs1(DigestAlgorithm::Sha1);
565 602
566 EXPECT_FALSE(alg1->ParamsForRsaPss()); 603 EXPECT_FALSE(alg1->ParamsForRsaPss());
567 } 604 }
568 605
569 } // namespace 606 } // namespace
570 607
571 } // namespace net 608 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/signature_algorithm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698