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

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: 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
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 0x30, 0x0E, // SEQUENCE (14 bytes) 81 0x30, 0x0E, // SEQUENCE (14 bytes)
82 0x06, 0x09, // OBJECT IDENTIFIER (9 bytes) 82 0x06, 0x09, // OBJECT IDENTIFIER (9 bytes)
83 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05, 83 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05,
84 0x02, 0x01, 0x00, // INTEGER (1 byte) 84 0x02, 0x01, 0x00, // INTEGER (1 byte)
85 }; 85 };
86 // clang-format on 86 // clang-format on
87 SignatureAlgorithm algorithm; 87 SignatureAlgorithm algorithm;
88 ASSERT_FALSE(algorithm.ParseDer(der::Input(kData))); 88 ASSERT_FALSE(algorithm.ParseDer(der::Input(kData)));
89 } 89 }
90 90
91 // Parses a sha1WithRSASignature which contains a NULL parameters field.
92 //
93 // SEQUENCE (2 elem)
94 // OBJECT IDENTIFIER 1.3.14.3.2.29
95 // NULL
96 TEST(SignatureAlgorithmTest, ParseDer_sha1WithRSASignature_NullParams) {
97 // clang-format off
98 const uint8_t kData[] = {
99 0x30, 0x09, // SEQUENCE (9 bytes)
100 0x06, 0x05, // OBJECT IDENTIFIER (5 bytes)
101 0x2b, 0x0e, 0x03, 0x02, 0x1d,
102 0x05, 0x00, // NULL (0 bytes)
103 };
104 // clang-format on
105 SignatureAlgorithm algorithm;
106 ASSERT_TRUE(algorithm.ParseDer(der::Input(kData)));
107
108 EXPECT_EQ(SignatureAlgorithmId::RsaPkcs1, algorithm.algorithm());
109 EXPECT_EQ(DigestAlgorithm::Sha1, algorithm.digest());
110 }
111
91 // Parses a sha-1WithRSAEncryption which contains values after the sequence. 112 // Parses a sha-1WithRSAEncryption which contains values after the sequence.
92 // 113 //
93 // SEQUENCE (1 elem) 114 // SEQUENCE (1 elem)
94 // OBJECT IDENTIFIER 1.2.840.113549.1.1.5 115 // OBJECT IDENTIFIER 1.2.840.113549.1.1.5
95 // INTEGER 0 116 // INTEGER 0
96 TEST(SignatureAlgorithmTest, ParseDer_DataAfterSequence) { 117 TEST(SignatureAlgorithmTest, ParseDer_DataAfterSequence) {
97 // clang-format off 118 // clang-format off
98 const uint8_t kData[] = { 119 const uint8_t kData[] = {
99 0x30, 0x0B, // SEQUENCE (11 bytes) 120 0x30, 0x0B, // SEQUENCE (11 bytes)
100 0x06, 0x09, // OBJECT IDENTIFIER (9 bytes) 121 0x06, 0x09, // OBJECT IDENTIFIER (9 bytes)
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 // Tests that the parmeters returned for an invalid algorithm are null. 473 // Tests that the parmeters returned for an invalid algorithm are null.
453 TEST(SignatureAlgorithmTest, ParamsAreNullForWrongType_Invalid) { 474 TEST(SignatureAlgorithmTest, ParamsAreNullForWrongType_Invalid) {
454 SignatureAlgorithm alg1; 475 SignatureAlgorithm alg1;
455 476
456 EXPECT_FALSE(alg1.ParamsForRsaPss()); 477 EXPECT_FALSE(alg1.ParamsForRsaPss());
457 } 478 }
458 479
459 } // namespace 480 } // namespace
460 481
461 } // namespace net 482 } // namespace net
OLDNEW
« net/cert/internal/signature_algorithm.cc ('K') | « net/cert/internal/signature_algorithm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698