Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(634)

Side by Side Diff: chrome/browser/extensions/api/networking_private/crypto_verify_impl.cc

Issue 792353002: Refactoring of Cast-related crypto code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed typo from https://codereview.chromium.org/747223002 Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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, decoded_signed_data, credentials.unsigned_data, 41 credentials.certificate, credentials.intermediate_certificates,
42 credentials.device_bssid); 42 decoded_signed_data, credentials.unsigned_data, 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
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;
161 signed_data = properties.signed_data; 163 signed_data = properties.signed_data;
162 164
163 std::vector<std::string> data_parts; 165 std::vector<std::string> data_parts;
164 data_parts.push_back(properties.device_ssid); 166 data_parts.push_back(properties.device_ssid);
165 data_parts.push_back(properties.device_serial); 167 data_parts.push_back(properties.device_serial);
166 data_parts.push_back(properties.device_bssid); 168 data_parts.push_back(properties.device_bssid);
167 data_parts.push_back(properties.public_key); 169 data_parts.push_back(properties.public_key);
168 data_parts.push_back(properties.nonce); 170 data_parts.push_back(properties.nonce);
169 unsigned_data = JoinString(data_parts, ","); 171 unsigned_data = JoinString(data_parts, ",");
170 172
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 228 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
227 Credentials credentials(verification_properties); 229 Credentials credentials(verification_properties);
228 base::PostTaskAndReplyWithResult( 230 base::PostTaskAndReplyWithResult(
229 blocking_pool_task_runner_.get(), FROM_HERE, 231 blocking_pool_task_runner_.get(), FROM_HERE,
230 base::Bind(&DoVerifyAndEncryptData, credentials, data), 232 base::Bind(&DoVerifyAndEncryptData, credentials, data),
231 base::Bind(&VerifyAndEncryptDataCompleted, success_callback, 233 base::Bind(&VerifyAndEncryptDataCompleted, success_callback,
232 failure_callback)); 234 failure_callback));
233 } 235 }
234 236
235 } // namespace extensions 237 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698