| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/cast_certificate/cast_cert_validator.h" | 5 #include "components/cast_certificate/cast_cert_validator.h" |
| 6 | 6 |
| 7 #include "components/cast_certificate/cast_cert_validator_test_helpers.h" | 7 #include "components/cast_certificate/cast_cert_validator_test_helpers.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace cast_certificate { | 10 namespace cast_certificate { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // | 81 // |
| 82 // TODO(eroman): This fails because there isn't currently support | 82 // TODO(eroman): This fails because there isn't currently support |
| 83 // for specifying a signature algorithm other than RSASSA PKCS#1 v1.5 with | 83 // for specifying a signature algorithm other than RSASSA PKCS#1 v1.5 with |
| 84 // SHA1. Once support for different algorithms is added to the API this | 84 // SHA1. Once support for different algorithms is added to the API this |
| 85 // should be changed to expect success. | 85 // should be changed to expect success. |
| 86 EXPECT_FALSE(context->VerifySignatureOverData( | 86 EXPECT_FALSE(context->VerifySignatureOverData( |
| 87 signature_data.signature_sha256, signature_data.message)); | 87 signature_data.signature_sha256, signature_data.message)); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 // Creates a time in UTC at midnight. | |
| 92 base::Time::Exploded CreateDate(int year, int month, int day) { | |
| 93 base::Time::Exploded time = {0}; | |
| 94 time.year = year; | |
| 95 time.month = month; | |
| 96 time.day_of_month = day; | |
| 97 return time; | |
| 98 } | |
| 99 | |
| 100 // Returns 2016-04-01 00:00:00 UTC. | 91 // Returns 2016-04-01 00:00:00 UTC. |
| 101 // | 92 // |
| 102 // This is a time when most of the test certificate paths are | 93 // This is a time when most of the test certificate paths are |
| 103 // valid. | 94 // valid. |
| 104 base::Time::Exploded AprilFirst2016() { | 95 base::Time::Exploded AprilFirst2016() { |
| 105 return CreateDate(2016, 4, 1); | 96 return cast_certificate::testing::CreateDate(2016, 4, 1); |
| 106 } | 97 } |
| 107 | 98 |
| 108 // Returns 2015-01-01 00:00:00 UTC. | 99 // Returns 2015-01-01 00:00:00 UTC. |
| 109 base::Time::Exploded JanuaryFirst2015() { | 100 base::Time::Exploded JanuaryFirst2015() { |
| 110 return CreateDate(2015, 1, 1); | 101 return cast_certificate::testing::CreateDate(2015, 1, 1); |
| 111 } | 102 } |
| 112 | 103 |
| 113 // Returns 2040-03-01 00:00:00 UTC. | 104 // Returns 2040-03-01 00:00:00 UTC. |
| 114 // | 105 // |
| 115 // This is so far in the future that the test chains in this unit-test | 106 // This is so far in the future that the test chains in this unit-test |
| 116 // should all be invalid. | 107 // should all be invalid. |
| 117 base::Time::Exploded MarchFirst2040() { | 108 base::Time::Exploded MarchFirst2040() { |
| 118 return CreateDate(2040, 3, 1); | 109 return cast_certificate::testing::CreateDate(2040, 3, 1); |
| 119 } | 110 } |
| 120 | 111 |
| 121 // Tests verifying a valid certificate chain of length 2: | 112 // Tests verifying a valid certificate chain of length 2: |
| 122 // | 113 // |
| 123 // 0: 2ZZBG9 FA8FCA3EF91A | 114 // 0: 2ZZBG9 FA8FCA3EF91A |
| 124 // 1: Eureka Gen1 ICA | 115 // 1: Eureka Gen1 ICA |
| 125 // | 116 // |
| 126 // Chains to trust anchor: | 117 // Chains to trust anchor: |
| 127 // Eureka Root CA (not included) | 118 // Eureka Root CA (not included) |
| 128 TEST(VerifyCastDeviceCertTest, ChromecastGen1) { | 119 TEST(VerifyCastDeviceCertTest, ChromecastGen1) { |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 auto context = | 398 auto context = |
| 408 CertVerificationContextImplForTest(CreateString(kEx2PublicKeySpki)); | 399 CertVerificationContextImplForTest(CreateString(kEx2PublicKeySpki)); |
| 409 | 400 |
| 410 EXPECT_TRUE(context->VerifySignatureOverData(CreateString(kEx2Signature), | 401 EXPECT_TRUE(context->VerifySignatureOverData(CreateString(kEx2Signature), |
| 411 CreateString(kEx2Message))); | 402 CreateString(kEx2Message))); |
| 412 } | 403 } |
| 413 | 404 |
| 414 } // namespace | 405 } // namespace |
| 415 | 406 |
| 416 } // namespace cast_certificate | 407 } // namespace cast_certificate |
| OLD | NEW |