| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "extensions/common/cast/cast_cert_validator.h" | |
| 6 | |
| 7 #include "extensions/common/cast/cast_cert_validator_test_helpers.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 | |
| 10 namespace extensions { | |
| 11 | |
| 12 namespace api { | |
| 13 | |
| 14 namespace cast_crypto { | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 // Creates an std::string given a uint8_t array. | |
| 19 template <size_t N> | |
| 20 std::string CreateString(const uint8_t (&data)[N]) { | |
| 21 return std::string(reinterpret_cast<const char*>(data), N); | |
| 22 } | |
| 23 | |
| 24 // Indicates the expected result of test verification. | |
| 25 enum TestResult { | |
| 26 RESULT_SUCCESS, | |
| 27 RESULT_FAIL, | |
| 28 }; | |
| 29 | |
| 30 // Reads a test chain from |certs_file_name|, and asserts that verifying it as | |
| 31 // a Cast device certificate yields |expected_result|. | |
| 32 // | |
| 33 // RunTest() also checks that the resulting CertVerificationContext does not | |
| 34 // incorrectly verify invalid signatures. | |
| 35 // | |
| 36 // * |expected_policy| - The policy that should have been identified for the | |
| 37 // device certificate. | |
| 38 // * |time| - The timestamp to use when verifying the certificate. | |
| 39 // * |optional_signed_data_file_name| - optional path to a PEM file containing | |
| 40 // a valid signature generated by the device certificate. | |
| 41 // | |
| 42 void RunTest(TestResult expected_result, | |
| 43 const std::string& expected_common_name, | |
| 44 CastDeviceCertPolicy expected_policy, | |
| 45 const std::string& certs_file_name, | |
| 46 const base::Time::Exploded& time, | |
| 47 const std::string& optional_signed_data_file_name) { | |
| 48 auto certs = cast_test_helpers::ReadCertificateChainFromFile(certs_file_name); | |
| 49 | |
| 50 std::unique_ptr<CertVerificationContext> context; | |
| 51 CastDeviceCertPolicy policy; | |
| 52 bool result = VerifyDeviceCert(certs, time, &context, &policy); | |
| 53 | |
| 54 if (expected_result == RESULT_FAIL) { | |
| 55 ASSERT_FALSE(result); | |
| 56 return; | |
| 57 } | |
| 58 | |
| 59 ASSERT_TRUE(result); | |
| 60 EXPECT_EQ(expected_policy, policy); | |
| 61 ASSERT_TRUE(context.get()); | |
| 62 | |
| 63 // Test that the context is good. | |
| 64 EXPECT_EQ(expected_common_name, context->GetCommonName()); | |
| 65 | |
| 66 ASSERT_TRUE(context); | |
| 67 | |
| 68 // Test verification of some invalid signatures. | |
| 69 EXPECT_FALSE( | |
| 70 context->VerifySignatureOverData("bogus signature", "bogus data")); | |
| 71 EXPECT_FALSE(context->VerifySignatureOverData("", "bogus data")); | |
| 72 EXPECT_FALSE(context->VerifySignatureOverData("", "")); | |
| 73 | |
| 74 // If valid signatures are known for this device certificate, test them. | |
| 75 if (!optional_signed_data_file_name.empty()) { | |
| 76 auto signature_data = cast_test_helpers::ReadSignatureTestData( | |
| 77 optional_signed_data_file_name); | |
| 78 | |
| 79 // Test verification of a valid SHA1 signature. | |
| 80 EXPECT_TRUE(context->VerifySignatureOverData(signature_data.signature_sha1, | |
| 81 signature_data.message)); | |
| 82 | |
| 83 // Test verification of a valid SHA256 | |
| 84 // | |
| 85 // TODO(eroman): This fails because there isn't currently support | |
| 86 // for specifying a signature algorithm other than RSASSA PKCS#1 v1.5 with | |
| 87 // SHA1. Once support for different algorithms is added to the API this | |
| 88 // should be changed to expect success. | |
| 89 EXPECT_FALSE(context->VerifySignatureOverData( | |
| 90 signature_data.signature_sha256, signature_data.message)); | |
| 91 } | |
| 92 } | |
| 93 | |
| 94 // Creates a time in UTC at midnight. | |
| 95 base::Time::Exploded CreateDate(int year, int month, int day) { | |
| 96 base::Time::Exploded time = {0}; | |
| 97 time.year = year; | |
| 98 time.month = month; | |
| 99 time.day_of_month = day; | |
| 100 return time; | |
| 101 } | |
| 102 | |
| 103 // Returns 2016-04-01 00:00:00 UTC. | |
| 104 // | |
| 105 // This is a time when most of the test certificate paths are | |
| 106 // valid. | |
| 107 base::Time::Exploded AprilFirst2016() { | |
| 108 return CreateDate(2016, 4, 1); | |
| 109 } | |
| 110 | |
| 111 // Returns 2015-01-01 00:00:00 UTC. | |
| 112 base::Time::Exploded JanuaryFirst2015() { | |
| 113 return CreateDate(2015, 1, 1); | |
| 114 } | |
| 115 | |
| 116 // Returns 2040-03-01 00:00:00 UTC. | |
| 117 // | |
| 118 // This is so far in the future that the test chains in this unit-test | |
| 119 // should all be invalid. | |
| 120 base::Time::Exploded MarchFirst2040() { | |
| 121 return CreateDate(2040, 3, 1); | |
| 122 } | |
| 123 | |
| 124 // Tests verifying a valid certificate chain of length 2: | |
| 125 // | |
| 126 // 0: 2ZZBG9 FA8FCA3EF91A | |
| 127 // 1: Eureka Gen1 ICA | |
| 128 // | |
| 129 // Chains to trust anchor: | |
| 130 // Eureka Root CA (not included) | |
| 131 TEST(VerifyCastDeviceCertTest, ChromecastGen1) { | |
| 132 RunTest(RESULT_SUCCESS, "2ZZBG9 FA8FCA3EF91A", CastDeviceCertPolicy::NONE, | |
| 133 "cast_certificates/chromecast_gen1.pem", AprilFirst2016(), | |
| 134 "cast_signeddata/2ZZBG9_FA8FCA3EF91A.pem"); | |
| 135 } | |
| 136 | |
| 137 // Tests verifying a valid certificate chain of length 2: | |
| 138 // | |
| 139 // 0: 2ZZBG9 FA8FCA3EF91A | |
| 140 // 1: Eureka Gen1 ICA | |
| 141 // | |
| 142 // Chains to trust anchor: | |
| 143 // Cast Root CA (not included) | |
| 144 TEST(VerifyCastDeviceCertTest, ChromecastGen1Reissue) { | |
| 145 RunTest(RESULT_SUCCESS, "2ZZBG9 FA8FCA3EF91A", CastDeviceCertPolicy::NONE, | |
| 146 "cast_certificates/chromecast_gen1_reissue.pem", AprilFirst2016(), | |
| 147 "cast_signeddata/2ZZBG9_FA8FCA3EF91A.pem"); | |
| 148 } | |
| 149 | |
| 150 // Tests verifying a valid certificate chain of length 2: | |
| 151 // | |
| 152 // 0: 3ZZAK6 FA8FCA3F0D35 | |
| 153 // 1: Chromecast ICA 3 | |
| 154 // | |
| 155 // Chains to trust anchor: | |
| 156 // Cast Root CA (not included) | |
| 157 TEST(VerifyCastDeviceCertTest, ChromecastGen2) { | |
| 158 RunTest(RESULT_SUCCESS, "3ZZAK6 FA8FCA3F0D35", CastDeviceCertPolicy::NONE, | |
| 159 "cast_certificates/chromecast_gen2.pem", AprilFirst2016(), ""); | |
| 160 } | |
| 161 | |
| 162 // Tests verifying a valid certificate chain of length 3: | |
| 163 // | |
| 164 // 0: -6394818897508095075 | |
| 165 // 1: Asus fugu Cast ICA | |
| 166 // 2: Widevine Cast Subroot | |
| 167 // | |
| 168 // Chains to trust anchor: | |
| 169 // Cast Root CA (not included) | |
| 170 TEST(VerifyCastDeviceCertTest, Fugu) { | |
| 171 RunTest(RESULT_SUCCESS, "-6394818897508095075", CastDeviceCertPolicy::NONE, | |
| 172 "cast_certificates/fugu.pem", AprilFirst2016(), ""); | |
| 173 } | |
| 174 | |
| 175 // Tests verifying an invalid certificate chain of length 1: | |
| 176 // | |
| 177 // 0: Cast Test Untrusted Device | |
| 178 // | |
| 179 // Chains to: | |
| 180 // Cast Test Untrusted ICA (not included) | |
| 181 // | |
| 182 // This is invalid because it does not chain to a trust anchor. | |
| 183 TEST(VerifyCastDeviceCertTest, Unchained) { | |
| 184 RunTest(RESULT_FAIL, "", CastDeviceCertPolicy::NONE, | |
| 185 "cast_certificates/unchained.pem", AprilFirst2016(), ""); | |
| 186 } | |
| 187 | |
| 188 // Tests verifying one of the self-signed trust anchors (chain of length 1): | |
| 189 // | |
| 190 // 0: Cast Root CA | |
| 191 // | |
| 192 // Chains to trust anchor: | |
| 193 // Cast Root CA | |
| 194 // | |
| 195 // Although this is a valid and trusted certificate (it is one of the | |
| 196 // trust anchors after all) it fails the test as it is not a *device | |
| 197 // certificate*. | |
| 198 TEST(VerifyCastDeviceCertTest, CastRootCa) { | |
| 199 RunTest(RESULT_FAIL, "", CastDeviceCertPolicy::NONE, | |
| 200 "cast_certificates/cast_root_ca.pem", AprilFirst2016(), ""); | |
| 201 } | |
| 202 | |
| 203 // Tests verifying a valid certificate chain of length 2: | |
| 204 // | |
| 205 // 0: 4ZZDZJ FA8FCA7EFE3C | |
| 206 // 1: Chromecast ICA 4 (Audio) | |
| 207 // | |
| 208 // Chains to trust anchor: | |
| 209 // Cast Root CA (not included) | |
| 210 // | |
| 211 // This device certificate has a policy that means it is valid only for audio | |
| 212 // devices. | |
| 213 TEST(VerifyCastDeviceCertTest, ChromecastAudio) { | |
| 214 RunTest(RESULT_SUCCESS, "4ZZDZJ FA8FCA7EFE3C", | |
| 215 CastDeviceCertPolicy::AUDIO_ONLY, | |
| 216 "cast_certificates/chromecast_audio.pem", AprilFirst2016(), ""); | |
| 217 } | |
| 218 | |
| 219 // Tests verifying a valid certificate chain of length 3: | |
| 220 // | |
| 221 // 0: MediaTek Audio Dev Test | |
| 222 // 1: MediaTek Audio Dev Model | |
| 223 // 2: Cast Audio Dev Root CA | |
| 224 // | |
| 225 // Chains to trust anchor: | |
| 226 // Cast Root CA (not included) | |
| 227 // | |
| 228 // This device certificate has a policy that means it is valid only for audio | |
| 229 // devices. | |
| 230 TEST(VerifyCastDeviceCertTest, MtkAudioDev) { | |
| 231 RunTest(RESULT_SUCCESS, "MediaTek Audio Dev Test", | |
| 232 CastDeviceCertPolicy::AUDIO_ONLY, | |
| 233 "cast_certificates/mtk_audio_dev.pem", JanuaryFirst2015(), ""); | |
| 234 } | |
| 235 | |
| 236 // Tests verifying a valid certificate chain of length 2: | |
| 237 // | |
| 238 // 0: 9V0000VB FA8FCA784D01 | |
| 239 // 1: Cast TV ICA (Vizio) | |
| 240 // | |
| 241 // Chains to trust anchor: | |
| 242 // Cast Root CA (not included) | |
| 243 TEST(VerifyCastDeviceCertTest, Vizio) { | |
| 244 RunTest(RESULT_SUCCESS, "9V0000VB FA8FCA784D01", CastDeviceCertPolicy::NONE, | |
| 245 "cast_certificates/vizio.pem", AprilFirst2016(), ""); | |
| 246 } | |
| 247 | |
| 248 // Tests verifying a valid certificate chain of length 2 using expired | |
| 249 // time points. | |
| 250 TEST(VerifyCastDeviceCertTest, ChromecastGen2InvalidTime) { | |
| 251 const char* kCertsFile = "cast_certificates/chromecast_gen2.pem"; | |
| 252 | |
| 253 // Control test - certificate should be valid at some time otherwise | |
| 254 // this test is pointless. | |
| 255 RunTest(RESULT_SUCCESS, "3ZZAK6 FA8FCA3F0D35", CastDeviceCertPolicy::NONE, | |
| 256 kCertsFile, AprilFirst2016(), ""); | |
| 257 | |
| 258 // Use a time before notBefore. | |
| 259 RunTest(RESULT_FAIL, "", CastDeviceCertPolicy::NONE, kCertsFile, | |
| 260 JanuaryFirst2015(), ""); | |
| 261 | |
| 262 // Use a time after notAfter. | |
| 263 RunTest(RESULT_FAIL, "", CastDeviceCertPolicy::NONE, kCertsFile, | |
| 264 MarchFirst2040(), ""); | |
| 265 } | |
| 266 | |
| 267 // Tests verifying a valid certificate chain of length 3: | |
| 268 // | |
| 269 // 0: Audio Reference Dev Test | |
| 270 // 1: Audio Reference Dev Model | |
| 271 // 2: Cast Audio Dev Root CA | |
| 272 // | |
| 273 // Chains to trust anchor: | |
| 274 // Cast Root CA (not included) | |
| 275 // | |
| 276 // This device certificate has a policy that means it is valid only for audio | |
| 277 // devices. | |
| 278 TEST(VerifyCastDeviceCertTest, AudioRefDevTestChain3) { | |
| 279 RunTest(RESULT_SUCCESS, "Audio Reference Dev Test", | |
| 280 CastDeviceCertPolicy::AUDIO_ONLY, | |
| 281 "cast_certificates/audio_ref_dev_test_chain_3.pem", AprilFirst2016(), | |
| 282 "cast_signeddata/AudioReferenceDevTest.pem"); | |
| 283 } | |
| 284 | |
| 285 // ------------------------------------------------------ | |
| 286 // Valid signature using 1024-bit RSA key | |
| 287 // ------------------------------------------------------ | |
| 288 | |
| 289 // This test vector comes from the NIST test vectors (pkcs1v15sign-vectors.txt), | |
| 290 // PKCS#1 v1.5 Signature Example 1.2. | |
| 291 // | |
| 292 // It is a valid signature using a 1024 bit key and SHA-1. | |
| 293 | |
| 294 const uint8_t kEx1Message[] = { | |
| 295 0x85, 0x13, 0x84, 0xcd, 0xfe, 0x81, 0x9c, 0x22, 0xed, 0x6c, 0x4c, | |
| 296 0xcb, 0x30, 0xda, 0xeb, 0x5c, 0xf0, 0x59, 0xbc, 0x8e, 0x11, 0x66, | |
| 297 0xb7, 0xe3, 0x53, 0x0c, 0x4c, 0x23, 0x3e, 0x2b, 0x5f, 0x8f, 0x71, | |
| 298 0xa1, 0xcc, 0xa5, 0x82, 0xd4, 0x3e, 0xcc, 0x72, 0xb1, 0xbc, 0xa1, | |
| 299 0x6d, 0xfc, 0x70, 0x13, 0x22, 0x6b, 0x9e, | |
| 300 }; | |
| 301 | |
| 302 const uint8_t kEx1Signature[] = { | |
| 303 0x84, 0xfd, 0x2c, 0xe7, 0x34, 0xec, 0x1d, 0xa8, 0x28, 0xd0, 0xf1, 0x5b, | |
| 304 0xf4, 0x9a, 0x87, 0x07, 0xc1, 0x5d, 0x05, 0x94, 0x81, 0x36, 0xde, 0x53, | |
| 305 0x7a, 0x3d, 0xb4, 0x21, 0x38, 0x41, 0x67, 0xc8, 0x6f, 0xae, 0x02, 0x25, | |
| 306 0x87, 0xee, 0x9e, 0x13, 0x7d, 0xae, 0xe7, 0x54, 0x73, 0x82, 0x62, 0x93, | |
| 307 0x2d, 0x27, 0x1c, 0x74, 0x4c, 0x6d, 0x3a, 0x18, 0x9a, 0xd4, 0x31, 0x1b, | |
| 308 0xdb, 0x02, 0x04, 0x92, 0xe3, 0x22, 0xfb, 0xdd, 0xc4, 0x04, 0x06, 0xea, | |
| 309 0x86, 0x0d, 0x4e, 0x8e, 0xa2, 0xa4, 0x08, 0x4a, 0xa9, 0x8b, 0x96, 0x22, | |
| 310 0xa4, 0x46, 0x75, 0x6f, 0xdb, 0x74, 0x0d, 0xdb, 0x3d, 0x91, 0xdb, 0x76, | |
| 311 0x70, 0xe2, 0x11, 0x66, 0x1b, 0xbf, 0x87, 0x09, 0xb1, 0x1c, 0x08, 0xa7, | |
| 312 0x07, 0x71, 0x42, 0x2d, 0x1a, 0x12, 0xde, 0xf2, 0x9f, 0x06, 0x88, 0xa1, | |
| 313 0x92, 0xae, 0xbd, 0x89, 0xe0, 0xf8, 0x96, 0xf8, | |
| 314 }; | |
| 315 | |
| 316 const uint8_t kEx1PublicKeySpki[] = { | |
| 317 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, | |
| 318 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, | |
| 319 0x89, 0x02, 0x81, 0x81, 0x00, 0xa5, 0x6e, 0x4a, 0x0e, 0x70, 0x10, 0x17, | |
| 320 0x58, 0x9a, 0x51, 0x87, 0xdc, 0x7e, 0xa8, 0x41, 0xd1, 0x56, 0xf2, 0xec, | |
| 321 0x0e, 0x36, 0xad, 0x52, 0xa4, 0x4d, 0xfe, 0xb1, 0xe6, 0x1f, 0x7a, 0xd9, | |
| 322 0x91, 0xd8, 0xc5, 0x10, 0x56, 0xff, 0xed, 0xb1, 0x62, 0xb4, 0xc0, 0xf2, | |
| 323 0x83, 0xa1, 0x2a, 0x88, 0xa3, 0x94, 0xdf, 0xf5, 0x26, 0xab, 0x72, 0x91, | |
| 324 0xcb, 0xb3, 0x07, 0xce, 0xab, 0xfc, 0xe0, 0xb1, 0xdf, 0xd5, 0xcd, 0x95, | |
| 325 0x08, 0x09, 0x6d, 0x5b, 0x2b, 0x8b, 0x6d, 0xf5, 0xd6, 0x71, 0xef, 0x63, | |
| 326 0x77, 0xc0, 0x92, 0x1c, 0xb2, 0x3c, 0x27, 0x0a, 0x70, 0xe2, 0x59, 0x8e, | |
| 327 0x6f, 0xf8, 0x9d, 0x19, 0xf1, 0x05, 0xac, 0xc2, 0xd3, 0xf0, 0xcb, 0x35, | |
| 328 0xf2, 0x92, 0x80, 0xe1, 0x38, 0x6b, 0x6f, 0x64, 0xc4, 0xef, 0x22, 0xe1, | |
| 329 0xe1, 0xf2, 0x0d, 0x0c, 0xe8, 0xcf, 0xfb, 0x22, 0x49, 0xbd, 0x9a, 0x21, | |
| 330 0x37, 0x02, 0x03, 0x01, 0x00, 0x01, | |
| 331 }; | |
| 332 | |
| 333 // Tests that a valid signature fails, because it uses a 1024-bit RSA key (too | |
| 334 // weak). | |
| 335 TEST(VerifyCastDeviceCertTest, VerifySignature1024BitRsa) { | |
| 336 auto context = | |
| 337 CertVerificationContextImplForTest(CreateString(kEx1PublicKeySpki)); | |
| 338 | |
| 339 EXPECT_FALSE(context->VerifySignatureOverData(CreateString(kEx1Signature), | |
| 340 CreateString(kEx1Message))); | |
| 341 } | |
| 342 | |
| 343 // ------------------------------------------------------ | |
| 344 // Valid signature using 2048-bit RSA key | |
| 345 // ------------------------------------------------------ | |
| 346 | |
| 347 // This test vector was generated (using WebCrypto). It is a valid signature | |
| 348 // using a 2048-bit RSA key, RSASSA PKCS#1 v1.5 with SHA-1. | |
| 349 | |
| 350 const uint8_t kEx2Message[] = { | |
| 351 // "hello" | |
| 352 0x68, 0x65, 0x6c, 0x6c, 0x6f, | |
| 353 }; | |
| 354 | |
| 355 const uint8_t kEx2Signature[] = { | |
| 356 0xc1, 0x21, 0x84, 0xe1, 0x62, 0x0e, 0x59, 0x52, 0x5b, 0xa4, 0x10, 0x1e, | |
| 357 0x11, 0x80, 0x5b, 0x9e, 0xcb, 0xa0, 0x20, 0x78, 0x29, 0xfc, 0xc0, 0x9a, | |
| 358 0xd9, 0x48, 0x90, 0x81, 0x03, 0xa9, 0xc0, 0x2f, 0x0a, 0xc4, 0x20, 0x34, | |
| 359 0xb5, 0xdb, 0x19, 0x04, 0xec, 0x94, 0x9b, 0xba, 0x48, 0x43, 0xf3, 0x5a, | |
| 360 0x15, 0x56, 0xfc, 0x4a, 0x87, 0x79, 0xf8, 0x50, 0xff, 0x5d, 0x66, 0x25, | |
| 361 0xdc, 0xa5, 0xd8, 0xe8, 0x9f, 0x5a, 0x73, 0x79, 0x6f, 0x5d, 0x99, 0xe0, | |
| 362 0xd5, 0xa5, 0x84, 0x49, 0x20, 0x3c, 0xe2, 0xa3, 0xd0, 0x69, 0x31, 0x2c, | |
| 363 0x13, 0xaf, 0x15, 0xd9, 0x10, 0x0d, 0x6f, 0xdd, 0x9d, 0x62, 0x5d, 0x7b, | |
| 364 0xe1, 0x1a, 0x48, 0x59, 0xaf, 0xf7, 0xbe, 0x87, 0x92, 0x60, 0x5d, 0x1a, | |
| 365 0xb5, 0xfe, 0x27, 0x38, 0x02, 0x20, 0xe9, 0xaf, 0x04, 0x57, 0xd3, 0x3b, | |
| 366 0x70, 0x04, 0x63, 0x5b, 0xc6, 0x5d, 0x83, 0xe2, 0xaf, 0x02, 0xb4, 0xef, | |
| 367 0x1c, 0x33, 0x54, 0x38, 0xf8, 0xb5, 0x19, 0xa8, 0x88, 0xdd, 0x1d, 0x96, | |
| 368 0x1c, 0x5e, 0x54, 0x80, 0xde, 0x7b, 0xb6, 0x29, 0xb8, 0x6b, 0xea, 0x47, | |
| 369 0xe5, 0xf1, 0x7e, 0xed, 0xe1, 0x91, 0xc8, 0xb8, 0x54, 0xd9, 0x1e, 0xfd, | |
| 370 0x07, 0x10, 0xbd, 0xa9, 0xd4, 0x93, 0x5e, 0x65, 0x8b, 0x6b, 0x46, 0x93, | |
| 371 0x4b, 0x60, 0x2a, 0x26, 0xf0, 0x1b, 0x4e, 0xca, 0x04, 0x82, 0xc0, 0x8d, | |
| 372 0xb1, 0xa5, 0xa8, 0x70, 0xdd, 0x66, 0x68, 0x95, 0x09, 0xb4, 0x85, 0x62, | |
| 373 0xf5, 0x17, 0x04, 0x48, 0xb4, 0x9d, 0x66, 0x2b, 0x25, 0x82, 0x7e, 0x99, | |
| 374 0x3e, 0xa1, 0x11, 0x63, 0xc3, 0xdf, 0x10, 0x20, 0x52, 0x56, 0x32, 0x35, | |
| 375 0xa9, 0x36, 0xde, 0x2a, 0xac, 0x10, 0x0d, 0x75, 0x21, 0xed, 0x5b, 0x38, | |
| 376 0xb6, 0xb5, 0x1e, 0xb5, 0x5b, 0x9a, 0x72, 0xd5, 0xf8, 0x1a, 0xd3, 0x91, | |
| 377 0xb8, 0x29, 0x0e, 0x58, | |
| 378 }; | |
| 379 | |
| 380 const uint8_t kEx2PublicKeySpki[] = { | |
| 381 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, | |
| 382 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, | |
| 383 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xcf, 0xde, 0xa5, | |
| 384 0x2e, 0x9d, 0x38, 0x62, 0x72, 0x47, 0x84, 0x8f, 0x2e, 0xa5, 0xe3, 0xd6, | |
| 385 0x34, 0xb0, 0xf9, 0x79, 0xa9, 0x10, 0x63, 0xa9, 0x93, 0x5a, 0xa1, 0xb9, | |
| 386 0xa3, 0x03, 0xd3, 0xcd, 0x9d, 0x84, 0x7d, 0xb6, 0x92, 0x47, 0xb4, 0x7d, | |
| 387 0x4a, 0xe8, 0x3a, 0x4b, 0xc5, 0xf6, 0x35, 0x6f, 0x18, 0x72, 0xf3, 0xbc, | |
| 388 0xd2, 0x1c, 0x7a, 0xd2, 0xe5, 0xdf, 0xcf, 0xb9, 0xac, 0x28, 0xd3, 0x49, | |
| 389 0x2a, 0x4f, 0x08, 0x62, 0xb9, 0xf1, 0xaa, 0x3d, 0x76, 0xe3, 0xa9, 0x96, | |
| 390 0x32, 0x24, 0x94, 0x9e, 0x88, 0xf8, 0x5e, 0xc3, 0x3c, 0x14, 0x32, 0x86, | |
| 391 0x72, 0xa2, 0x34, 0x3d, 0x41, 0xd0, 0xb2, 0x01, 0x99, 0x01, 0xf3, 0x93, | |
| 392 0xa3, 0x76, 0x5a, 0xff, 0x42, 0x28, 0x54, 0xe0, 0xcc, 0x4c, 0xcd, 0x2d, | |
| 393 0x3b, 0x0b, 0x47, 0xcc, 0xc2, 0x75, 0x02, 0xc1, 0xb7, 0x0b, 0x37, 0x65, | |
| 394 0xe6, 0x0d, 0xe4, 0xc3, 0x85, 0x86, 0x29, 0x3c, 0x77, 0xce, 0xb0, 0x34, | |
| 395 0xa9, 0x03, 0xe9, 0x13, 0xbe, 0x97, 0x1e, 0xfd, 0xeb, 0x0d, 0x60, 0xc2, | |
| 396 0xb3, 0x19, 0xa1, 0x75, 0x72, 0x57, 0x3f, 0x5d, 0x0e, 0x75, 0xac, 0x10, | |
| 397 0x96, 0xad, 0x95, 0x67, 0x9f, 0xa2, 0x84, 0x15, 0x6a, 0x61, 0xb1, 0x47, | |
| 398 0xd1, 0x24, 0x78, 0xb4, 0x40, 0x2b, 0xc3, 0x5c, 0x73, 0xd4, 0xc1, 0x8d, | |
| 399 0x12, 0xf1, 0x3f, 0xb4, 0x93, 0x17, 0xfe, 0x5d, 0xbf, 0x39, 0xf2, 0x45, | |
| 400 0xf9, 0xcf, 0x38, 0x44, 0x40, 0x5b, 0x47, 0x2a, 0xbf, 0xb9, 0xac, 0xa6, | |
| 401 0x14, 0xb6, 0x1b, 0xe3, 0xa8, 0x14, 0xf8, 0xfe, 0x47, 0x67, 0xea, 0x90, | |
| 402 0x51, 0x12, 0xcf, 0x5e, 0x28, 0xec, 0x92, 0x83, 0x7c, 0xc6, 0x29, 0x9f, | |
| 403 0x12, 0x29, 0x88, 0x49, 0xf7, 0xb7, 0xed, 0x5e, 0x3a, 0x78, 0xd6, 0x8a, | |
| 404 0xba, 0x42, 0x6e, 0x0a, 0xf4, 0x0d, 0xc1, 0xc0, 0x8f, 0xdb, 0x26, 0x41, | |
| 405 0x57, 0x02, 0x03, 0x01, 0x00, 0x01, | |
| 406 }; | |
| 407 | |
| 408 // Tests that a valid signature using 2048-bit key succeeds. | |
| 409 TEST(VerifyCastDeviceCertTest, VerifySignature2048BitRsa) { | |
| 410 auto context = | |
| 411 CertVerificationContextImplForTest(CreateString(kEx2PublicKeySpki)); | |
| 412 | |
| 413 EXPECT_TRUE(context->VerifySignatureOverData(CreateString(kEx2Signature), | |
| 414 CreateString(kEx2Message))); | |
| 415 } | |
| 416 | |
| 417 } // namespace | |
| 418 | |
| 419 } // namespace cast_crypto | |
| 420 | |
| 421 } // namespace api | |
| 422 | |
| 423 } // namespace extensions | |
| OLD | NEW |