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

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

Issue 1573243011: Refactor der::Input helper methods into new constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nits Created 4 years, 11 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/verify_certificate_chain_unittest.cc ('k') | net/der/input.h » ('j') | 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/verify_signed_data.h" 5 #include "net/cert/internal/verify_signed_data.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "net/cert/internal/signature_algorithm.h" 9 #include "net/cert/internal/signature_algorithm.h"
10 #include "net/cert/internal/signature_policy.h" 10 #include "net/cert/internal/signature_policy.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 const PemBlockMapping mappings[] = { 54 const PemBlockMapping mappings[] = {
55 {"PUBLIC KEY", &public_key}, 55 {"PUBLIC KEY", &public_key},
56 {"ALGORITHM", &algorithm}, 56 {"ALGORITHM", &algorithm},
57 {"DATA", &signed_data}, 57 {"DATA", &signed_data},
58 {"SIGNATURE", &signature_value}, 58 {"SIGNATURE", &signature_value},
59 }; 59 };
60 60
61 ASSERT_TRUE(ReadTestDataFromPemFile(path, mappings)); 61 ASSERT_TRUE(ReadTestDataFromPemFile(path, mappings));
62 62
63 scoped_ptr<SignatureAlgorithm> signature_algorithm = 63 scoped_ptr<SignatureAlgorithm> signature_algorithm =
64 SignatureAlgorithm::CreateFromDer(InputFromString(&algorithm)); 64 SignatureAlgorithm::CreateFromDer(der::Input(&algorithm));
65 ASSERT_TRUE(signature_algorithm); 65 ASSERT_TRUE(signature_algorithm);
66 66
67 der::BitString signature_value_bit_string; 67 der::BitString signature_value_bit_string;
68 der::Parser signature_value_parser(InputFromString(&signature_value)); 68 der::Parser signature_value_parser((der::Input(&signature_value)));
69 ASSERT_TRUE(signature_value_parser.ReadBitString(&signature_value_bit_string)) 69 ASSERT_TRUE(signature_value_parser.ReadBitString(&signature_value_bit_string))
70 << "The signature value is not a valid BIT STRING"; 70 << "The signature value is not a valid BIT STRING";
71 71
72 bool expected_result_bool = expected_result == SUCCESS; 72 bool expected_result_bool = expected_result == SUCCESS;
73 73
74 EXPECT_EQ( 74 EXPECT_EQ(expected_result_bool,
75 expected_result_bool, 75 VerifySignedData(*signature_algorithm, der::Input(&signed_data),
76 VerifySignedData(*signature_algorithm, InputFromString(&signed_data), 76 signature_value_bit_string,
77 signature_value_bit_string, InputFromString(&public_key), 77 der::Input(&public_key), policy));
78 policy));
79 } 78 }
80 79
81 // RunTestCase() is the same as RunTestCaseUsingPolicy(), only it uses a 80 // RunTestCase() is the same as RunTestCaseUsingPolicy(), only it uses a
82 // default policy. This policy will accept a basic profile of signature 81 // default policy. This policy will accept a basic profile of signature
83 // algorithms (including ANY sized RSA key >= 1024). 82 // algorithms (including ANY sized RSA key >= 1024).
84 void RunTestCase(VerifyResult expected_result, const char* file_name) { 83 void RunTestCase(VerifyResult expected_result, const char* file_name) {
85 SimpleSignaturePolicy policy(1024); 84 SimpleSignaturePolicy policy(1024);
86 return RunTestCaseUsingPolicy(expected_result, file_name, &policy); 85 return RunTestCaseUsingPolicy(expected_result, file_name, &policy);
87 } 86 }
88 87
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 RunTestCaseUsingPolicy(SUCCESS, "ecdsa-secp384r1-sha256.pem", &policy); 304 RunTestCaseUsingPolicy(SUCCESS, "ecdsa-secp384r1-sha256.pem", &policy);
306 RunTestCaseUsingPolicy(SUCCESS, "rsa-pkcs1-sha256.pem", &policy); 305 RunTestCaseUsingPolicy(SUCCESS, "rsa-pkcs1-sha256.pem", &policy);
307 RunTestCaseUsingPolicy(SUCCESS, "rsa-pss-sha256-salt10.pem", &policy); 306 RunTestCaseUsingPolicy(SUCCESS, "rsa-pss-sha256-salt10.pem", &policy);
308 RunTestCaseUsingPolicy(FAILURE, "rsa-pss-sha256-mgf1-sha512-salt33.pem", 307 RunTestCaseUsingPolicy(FAILURE, "rsa-pss-sha256-mgf1-sha512-salt33.pem",
309 &policy); 308 &policy);
310 } 309 }
311 310
312 } // namespace 311 } // namespace
313 312
314 } // namespace net 313 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/verify_certificate_chain_unittest.cc ('k') | net/der/input.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698