OLD | NEW |
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/parse_certificate.h" | 5 #include "net/cert/internal/parse_certificate.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "net/cert/internal/cert_errors.h" | 8 #include "net/cert/internal/cert_errors.h" |
9 #include "net/cert/internal/test_helpers.h" | 9 #include "net/cert/internal/test_helpers.h" |
10 #include "net/der/input.h" | 10 #include "net/der/input.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // Parsing the certificate. | 55 // Parsing the certificate. |
56 der::Input tbs_certificate_tlv; | 56 der::Input tbs_certificate_tlv; |
57 der::Input signature_algorithm_tlv; | 57 der::Input signature_algorithm_tlv; |
58 der::BitString signature_value; | 58 der::BitString signature_value; |
59 CertErrors errors; | 59 CertErrors errors; |
60 bool actual_result = | 60 bool actual_result = |
61 ParseCertificate(der::Input(&data), &tbs_certificate_tlv, | 61 ParseCertificate(der::Input(&data), &tbs_certificate_tlv, |
62 &signature_algorithm_tlv, &signature_value, &errors); | 62 &signature_algorithm_tlv, &signature_value, &errors); |
63 | 63 |
64 EXPECT_EQ(expected_result, actual_result); | 64 EXPECT_EQ(expected_result, actual_result); |
65 EXPECT_EQ(expected_errors, errors.ToDebugString()) << "Test file: " | 65 VerifyCertErrors(expected_errors, errors, test_file_path); |
66 << test_file_path; | |
67 | 66 |
68 // Ensure that the parsed certificate matches expectations. | 67 // Ensure that the parsed certificate matches expectations. |
69 if (expected_result && actual_result) { | 68 if (expected_result && actual_result) { |
70 EXPECT_EQ(0, signature_value.unused_bits()); | 69 EXPECT_EQ(0, signature_value.unused_bits()); |
71 EXPECT_EQ(der::Input(&expected_signature), signature_value.bytes()); | 70 EXPECT_EQ(der::Input(&expected_signature), signature_value.bytes()); |
72 EXPECT_EQ(der::Input(&expected_signature_algorithm), | 71 EXPECT_EQ(der::Input(&expected_signature_algorithm), |
73 signature_algorithm_tlv); | 72 signature_algorithm_tlv); |
74 EXPECT_EQ(der::Input(&expected_tbs_certificate), tbs_certificate_tlv); | 73 EXPECT_EQ(der::Input(&expected_tbs_certificate), tbs_certificate_tlv); |
75 } | 74 } |
76 } | 75 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 ASSERT_TRUE(ReadTestDataFromPemFile(test_file_path, mappings)); | 158 ASSERT_TRUE(ReadTestDataFromPemFile(test_file_path, mappings)); |
160 | 159 |
161 bool expected_result = !expected_spki.empty(); | 160 bool expected_result = !expected_spki.empty(); |
162 | 161 |
163 ParsedTbsCertificate parsed; | 162 ParsedTbsCertificate parsed; |
164 CertErrors errors; | 163 CertErrors errors; |
165 bool actual_result = | 164 bool actual_result = |
166 ParseTbsCertificate(der::Input(&data), {}, &parsed, &errors); | 165 ParseTbsCertificate(der::Input(&data), {}, &parsed, &errors); |
167 | 166 |
168 EXPECT_EQ(expected_result, actual_result); | 167 EXPECT_EQ(expected_result, actual_result); |
169 EXPECT_EQ(expected_errors, errors.ToDebugString()) << "Test file: " | 168 VerifyCertErrors(expected_errors, errors, test_file_path); |
170 << test_file_path; | |
171 | 169 |
172 if (!expected_result || !actual_result) | 170 if (!expected_result || !actual_result) |
173 return; | 171 return; |
174 | 172 |
175 // Ensure that the ParsedTbsCertificate matches expectations. | 173 // Ensure that the ParsedTbsCertificate matches expectations. |
176 EXPECT_EQ(expected_version, parsed.version); | 174 EXPECT_EQ(expected_version, parsed.version); |
177 | 175 |
178 EXPECT_EQ(der::Input(&expected_serial_number), parsed.serial_number); | 176 EXPECT_EQ(der::Input(&expected_serial_number), parsed.serial_number); |
179 EXPECT_EQ(der::Input(&expected_signature_algorithm), | 177 EXPECT_EQ(der::Input(&expected_signature_algorithm), |
180 parsed.signature_algorithm_tlv); | 178 parsed.signature_algorithm_tlv); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 0x00, // Number of unused bits | 403 0x00, // Number of unused bits |
406 }; | 404 }; |
407 | 405 |
408 der::BitString key_usage; | 406 der::BitString key_usage; |
409 ASSERT_FALSE(ParseKeyUsage(der::Input(der), &key_usage)); | 407 ASSERT_FALSE(ParseKeyUsage(der::Input(der), &key_usage)); |
410 } | 408 } |
411 | 409 |
412 } // namespace | 410 } // namespace |
413 | 411 |
414 } // namespace net | 412 } // namespace net |
OLD | NEW |