| 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/verify_signed_data.h" | 5 #include "net/cert/internal/verify_signed_data.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "net/cert/internal/cert_errors.h" | 10 #include "net/cert/internal/cert_errors.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 SignatureAlgorithm::Create(der::Input(&algorithm), &algorithm_errors); | 60 SignatureAlgorithm::Create(der::Input(&algorithm), &algorithm_errors); |
| 61 ASSERT_TRUE(signature_algorithm) << algorithm_errors.ToDebugString(); | 61 ASSERT_TRUE(signature_algorithm) << algorithm_errors.ToDebugString(); |
| 62 | 62 |
| 63 der::BitString signature_value_bit_string; | 63 der::BitString signature_value_bit_string; |
| 64 der::Parser signature_value_parser((der::Input(&signature_value))); | 64 der::Parser signature_value_parser((der::Input(&signature_value))); |
| 65 ASSERT_TRUE(signature_value_parser.ReadBitString(&signature_value_bit_string)) | 65 ASSERT_TRUE(signature_value_parser.ReadBitString(&signature_value_bit_string)) |
| 66 << "The signature value is not a valid BIT STRING"; | 66 << "The signature value is not a valid BIT STRING"; |
| 67 | 67 |
| 68 bool expected_result_bool = expected_result == SUCCESS; | 68 bool expected_result_bool = expected_result == SUCCESS; |
| 69 | 69 |
| 70 CertErrors verify_errors; |
| 71 bool result = |
| 72 VerifySignedData(*signature_algorithm, der::Input(&signed_data), |
| 73 signature_value_bit_string, der::Input(&public_key), |
| 74 policy, &verify_errors); |
| 75 EXPECT_EQ(expected_result_bool, result); |
| 70 // TODO(crbug.com/634443): Verify the returned errors. | 76 // TODO(crbug.com/634443): Verify the returned errors. |
| 71 CertErrors verify_errors; | 77 // if (!result) |
| 72 EXPECT_EQ(expected_result_bool, | 78 // EXPECT_FALSE(verify_errors.empty()); |
| 73 VerifySignedData(*signature_algorithm, der::Input(&signed_data), | |
| 74 signature_value_bit_string, | |
| 75 der::Input(&public_key), policy, &verify_errors)); | |
| 76 } | 79 } |
| 77 | 80 |
| 78 // RunTestCase() is the same as RunTestCaseUsingPolicy(), only it uses a | 81 // RunTestCase() is the same as RunTestCaseUsingPolicy(), only it uses a |
| 79 // default policy. This policy will accept a basic profile of signature | 82 // default policy. This policy will accept a basic profile of signature |
| 80 // algorithms (including ANY sized RSA key >= 1024). | 83 // algorithms (including ANY sized RSA key >= 1024). |
| 81 void RunTestCase(VerifyResult expected_result, const char* file_name) { | 84 void RunTestCase(VerifyResult expected_result, const char* file_name) { |
| 82 SimpleSignaturePolicy policy(1024); | 85 SimpleSignaturePolicy policy(1024); |
| 83 return RunTestCaseUsingPolicy(expected_result, file_name, &policy); | 86 return RunTestCaseUsingPolicy(expected_result, file_name, &policy); |
| 84 } | 87 } |
| 85 | 88 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 RunTestCaseUsingPolicy(SUCCESS, "ecdsa-secp384r1-sha256.pem", &policy); | 296 RunTestCaseUsingPolicy(SUCCESS, "ecdsa-secp384r1-sha256.pem", &policy); |
| 294 RunTestCaseUsingPolicy(SUCCESS, "rsa-pkcs1-sha256.pem", &policy); | 297 RunTestCaseUsingPolicy(SUCCESS, "rsa-pkcs1-sha256.pem", &policy); |
| 295 RunTestCaseUsingPolicy(SUCCESS, "rsa-pss-sha256-salt10.pem", &policy); | 298 RunTestCaseUsingPolicy(SUCCESS, "rsa-pss-sha256-salt10.pem", &policy); |
| 296 RunTestCaseUsingPolicy(FAILURE, "rsa-pss-sha256-mgf1-sha512-salt33.pem", | 299 RunTestCaseUsingPolicy(FAILURE, "rsa-pss-sha256-mgf1-sha512-salt33.pem", |
| 297 &policy); | 300 &policy); |
| 298 } | 301 } |
| 299 | 302 |
| 300 } // namespace | 303 } // namespace |
| 301 | 304 |
| 302 } // namespace net | 305 } // namespace net |
| OLD | NEW |