OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_auth_ica.h" | 5 #include "extensions/browser/api/cast_channel/cast_auth_ica.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "base/base64.h" | 9 #include "base/base64.h" |
8 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
9 #include "crypto/signature_verifier.h" | 11 #include "crypto/signature_verifier.h" |
10 #include "extensions/browser/api/cast_channel/cast_auth_util.h" | 12 #include "extensions/browser/api/cast_channel/cast_auth_util.h" |
11 #include "extensions/common/api/cast_channel/authority_keys.pb.h" | 13 #include "extensions/common/api/cast_channel/authority_keys.pb.h" |
12 #include "net/base/hash_value.h" | 14 #include "net/base/hash_value.h" |
13 #include "net/cert/x509_certificate.h" | 15 #include "net/cert/x509_certificate.h" |
14 | 16 |
15 namespace extensions { | 17 namespace extensions { |
16 namespace api { | 18 namespace api { |
17 namespace cast_channel { | 19 namespace cast_channel { |
18 namespace { | 20 namespace { |
19 | 21 |
20 // Fingerprint of the default ICA. | 22 // Fingerprint of the default ICA. |
21 static const net::SHA256HashValue kDefaultFingerprintICA = { { | 23 static const net::SHA256HashValue kDefaultFingerprintICA = { { |
22 0x52, 0x9D, 0x9C, 0xD6, 0x7F, 0xE5, 0xEB, 0x69, 0x8E, 0x70, 0xDD, 0x26, | 24 0x52, 0x9D, 0x9C, 0xD6, 0x7F, 0xE5, 0xEB, 0x69, 0x8E, 0x70, 0xDD, 0x26, |
23 0xD7, 0xD8, 0xF1, 0x26, 0x59, 0xF1, 0xE6, 0xE5, 0x23, 0x48, 0xBF, 0x6A, | 25 0xD7, 0xD8, 0xF1, 0x26, 0x59, 0xF1, 0xE6, 0xE5, 0x23, 0x48, 0xBF, 0x6A, |
24 0x5C, 0xF7, 0x16, 0xE1, 0x3F, 0x41, 0x0E, 0x73 | 26 0x5C, 0xF7, 0x16, 0xE1, 0x3F, 0x41, 0x0E, 0x73 |
25 } }; | 27 } }; |
26 | 28 |
27 // Built in public key for verifying trusted authorities data. | 29 // Built in public key for verifying trusted authorities data. |
28 const uint8 kPublicKey[] = { | 30 const uint8_t kPublicKey[] = { |
29 0x30, 0x82, 0x01, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, | 31 0x30, 0x82, 0x01, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, |
30 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00, | 32 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00, |
31 0x30, 0x82, 0x01, 0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xC3, 0x8D, 0xEC, | 33 0x30, 0x82, 0x01, 0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xC3, 0x8D, 0xEC, |
32 0xF5, 0x94, 0x4C, 0x66, 0x90, 0xFC, 0x08, 0xED, 0x6E, 0x7D, 0xD0, 0xD6, | 34 0xF5, 0x94, 0x4C, 0x66, 0x90, 0xFC, 0x08, 0xED, 0x6E, 0x7D, 0xD0, 0xD6, |
33 0x93, 0x62, 0x94, 0x86, 0xFB, 0xBA, 0x6F, 0x06, 0xD5, 0x26, 0xAD, 0x52, | 35 0x93, 0x62, 0x94, 0x86, 0xFB, 0xBA, 0x6F, 0x06, 0xD5, 0x26, 0xAD, 0x52, |
34 0x84, 0x5A, 0x68, 0x52, 0xF1, 0xA9, 0x46, 0x04, 0x78, 0xC0, 0xA1, 0x0F, | 36 0x84, 0x5A, 0x68, 0x52, 0xF1, 0xA9, 0x46, 0x04, 0x78, 0xC0, 0xA1, 0x0F, |
35 0x72, 0xCE, 0x1C, 0xB3, 0xD2, 0x34, 0xFA, 0x28, 0xD0, 0xA6, 0x2D, 0xDF, | 37 0x72, 0xCE, 0x1C, 0xB3, 0xD2, 0x34, 0xFA, 0x28, 0xD0, 0xA6, 0x2D, 0xDF, |
36 0xDF, 0x0C, 0x6C, 0x30, 0xCF, 0xF3, 0x67, 0x0E, 0xCE, 0xDD, 0x2D, 0x02, | 38 0xDF, 0x0C, 0x6C, 0x30, 0xCF, 0xF3, 0x67, 0x0E, 0xCE, 0xDD, 0x2D, 0x02, |
37 0x20, 0x05, 0x7D, 0x7F, 0x81, 0x19, 0xBC, 0x42, 0x74, 0xC0, 0x11, 0xC4, | 39 0x20, 0x05, 0x7D, 0x7F, 0x81, 0x19, 0xBC, 0x42, 0x74, 0xC0, 0x11, 0xC4, |
38 0x7F, 0x31, 0x0B, 0x63, 0xE7, 0x2E, 0xFE, 0xA4, 0x20, 0xE5, 0xD8, 0x19, | 40 0x7F, 0x31, 0x0B, 0x63, 0xE7, 0x2E, 0xFE, 0xA4, 0x20, 0xE5, 0xD8, 0x19, |
(...skipping 18 matching lines...) Expand all Loading... |
57 if (signature.size() != 256) | 59 if (signature.size() != 256) |
58 return false; | 60 return false; |
59 | 61 |
60 crypto::SignatureVerifier verifier; | 62 crypto::SignatureVerifier verifier; |
61 crypto::SignatureVerifier::HashAlgorithm hash_alg = | 63 crypto::SignatureVerifier::HashAlgorithm hash_alg = |
62 crypto::SignatureVerifier::SHA256; | 64 crypto::SignatureVerifier::SHA256; |
63 crypto::SignatureVerifier::HashAlgorithm mask_hash_alg = hash_alg; | 65 crypto::SignatureVerifier::HashAlgorithm mask_hash_alg = hash_alg; |
64 unsigned int hash_len = 32; | 66 unsigned int hash_len = 32; |
65 | 67 |
66 if (!verifier.VerifyInitRSAPSS( | 68 if (!verifier.VerifyInitRSAPSS( |
67 hash_alg, | 69 hash_alg, mask_hash_alg, hash_len, |
68 mask_hash_alg, | 70 reinterpret_cast<const uint8_t*>(signature.data()), signature.size(), |
69 hash_len, | 71 kPublicKey, sizeof(kPublicKey))) { |
70 reinterpret_cast<const uint8*>(signature.data()), | |
71 signature.size(), | |
72 kPublicKey, | |
73 sizeof(kPublicKey))) { | |
74 return false; | 72 return false; |
75 } | 73 } |
76 | 74 |
77 verifier.VerifyUpdate(reinterpret_cast<const uint8*>(data.data()), | 75 verifier.VerifyUpdate(reinterpret_cast<const uint8_t*>(data.data()), |
78 data.size()); | 76 data.size()); |
79 | 77 |
80 return verifier.VerifyFinal(); | 78 return verifier.VerifyFinal(); |
81 } | 79 } |
82 | 80 |
83 } // namespace | 81 } // namespace |
84 | 82 |
85 AuthorityKeyStore::AuthorityKeyStore() { | 83 AuthorityKeyStore::AuthorityKeyStore() { |
86 } | 84 } |
87 | 85 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 155 } |
158 | 156 |
159 base::StringPiece GetDefaultTrustedICAPublicKey() { | 157 base::StringPiece GetDefaultTrustedICAPublicKey() { |
160 AuthorityKeyStore& authority_keys_store = g_authority_keys_store.Get(); | 158 AuthorityKeyStore& authority_keys_store = g_authority_keys_store.Get(); |
161 return authority_keys_store.GetDefaultICAPublicKey(); | 159 return authority_keys_store.GetDefaultICAPublicKey(); |
162 } | 160 } |
163 | 161 |
164 } // namespace cast_channel | 162 } // namespace cast_channel |
165 } // namespace api | 163 } // namespace api |
166 } // namespace extensions | 164 } // namespace extensions |
OLD | NEW |