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 "chrome/browser/extensions/api/networking_private/crypto_verify_impl.h" | 5 #include "chrome/browser/extensions/api/networking_private/crypto_verify_impl.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 bool DecodeAndVerifyCredentials( | 31 bool DecodeAndVerifyCredentials( |
32 const CryptoVerifyImpl::Credentials& credentials, | 32 const CryptoVerifyImpl::Credentials& credentials, |
33 bool* verified) { | 33 bool* verified) { |
34 std::string decoded_signed_data; | 34 std::string decoded_signed_data; |
35 if (!base::Base64Decode(credentials.signed_data, &decoded_signed_data)) { | 35 if (!base::Base64Decode(credentials.signed_data, &decoded_signed_data)) { |
36 LOG(ERROR) << "Failed to decode signed data"; | 36 LOG(ERROR) << "Failed to decode signed data"; |
37 *verified = false; | 37 *verified = false; |
38 return false; | 38 return false; |
39 } | 39 } |
40 *verified = networking_private_crypto::VerifyCredentials( | 40 *verified = networking_private_crypto::VerifyCredentials( |
41 credentials.certificate, credentials.intermediate_certificates, | 41 credentials.certificate, decoded_signed_data, credentials.unsigned_data, |
42 decoded_signed_data, credentials.unsigned_data, credentials.device_bssid); | 42 credentials.device_bssid); |
43 return true; | 43 return true; |
44 } | 44 } |
45 | 45 |
46 void VerifyDestinationCompleted( | 46 void VerifyDestinationCompleted( |
47 const CryptoVerifyImpl::BoolCallback& success_callback, | 47 const CryptoVerifyImpl::BoolCallback& success_callback, |
48 const CryptoVerifyImpl::FailureCallback& failure_callback, | 48 const CryptoVerifyImpl::FailureCallback& failure_callback, |
49 bool* verified, | 49 bool* verified, |
50 bool success) { | 50 bool success) { |
51 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 51 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
52 if (!success) | 52 if (!success) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 if (succeeded) | 151 if (succeeded) |
152 return; | 152 return; |
153 failure_callback.Run(networking_private::kErrorEncryptionError); | 153 failure_callback.Run(networking_private::kErrorEncryptionError); |
154 } | 154 } |
155 | 155 |
156 } // namespace | 156 } // namespace |
157 | 157 |
158 CryptoVerifyImpl::Credentials::Credentials( | 158 CryptoVerifyImpl::Credentials::Credentials( |
159 const VerificationProperties& properties) { | 159 const VerificationProperties& properties) { |
160 certificate = properties.certificate; | 160 certificate = properties.certificate; |
161 if (properties.intermediate_certificates.get()) | |
162 intermediate_certificates = *properties.intermediate_certificates; | |
163 signed_data = properties.signed_data; | 161 signed_data = properties.signed_data; |
164 | 162 |
165 std::vector<std::string> data_parts; | 163 std::vector<std::string> data_parts; |
166 data_parts.push_back(properties.device_ssid); | 164 data_parts.push_back(properties.device_ssid); |
167 data_parts.push_back(properties.device_serial); | 165 data_parts.push_back(properties.device_serial); |
168 data_parts.push_back(properties.device_bssid); | 166 data_parts.push_back(properties.device_bssid); |
169 data_parts.push_back(properties.public_key); | 167 data_parts.push_back(properties.public_key); |
170 data_parts.push_back(properties.nonce); | 168 data_parts.push_back(properties.nonce); |
171 unsigned_data = JoinString(data_parts, ","); | 169 unsigned_data = JoinString(data_parts, ","); |
172 | 170 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 226 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
229 Credentials credentials(verification_properties); | 227 Credentials credentials(verification_properties); |
230 base::PostTaskAndReplyWithResult( | 228 base::PostTaskAndReplyWithResult( |
231 blocking_pool_task_runner_.get(), FROM_HERE, | 229 blocking_pool_task_runner_.get(), FROM_HERE, |
232 base::Bind(&DoVerifyAndEncryptData, credentials, data), | 230 base::Bind(&DoVerifyAndEncryptData, credentials, data), |
233 base::Bind(&VerifyAndEncryptDataCompleted, success_callback, | 231 base::Bind(&VerifyAndEncryptDataCompleted, success_callback, |
234 failure_callback)); | 232 failure_callback)); |
235 } | 233 } |
236 | 234 |
237 } // namespace extensions | 235 } // namespace extensions |
OLD | NEW |