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

Side by Side Diff: chrome/browser/chromeos/login/easy_unlock/easy_unlock_challenge_wrapper.cc

Issue 1494153002: This CL replaces e-mail with AccountId in easy signin code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bugfix in original easy unlock code' Created 5 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/chromeos/login/easy_unlock/easy_unlock_challenge_wrappe r.h" 5 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_challenge_wrappe r.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h" 8 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h"
9 #include "components/proximity_auth/cryptauth/proto/securemessage.pb.h" 9 #include "components/proximity_auth/cryptauth/proto/securemessage.pb.h"
10 #include "components/proximity_auth/logging/logging.h" 10 #include "components/proximity_auth/logging/logging.h"
11 11
12 namespace chromeos { 12 namespace chromeos {
13 13
14 namespace { 14 namespace {
15 15
16 // Salt added to a SecureMessage. 16 // Salt added to a SecureMessage.
17 const char kSalt[] = 17 const char kSalt[] =
18 "\xbf\x9d\x2a\x53\xc6\x36\x16\xd7\x5d\xb0\xa7\x16\x5b\x91\xc1\xef\x73\xe5" 18 "\xbf\x9d\x2a\x53\xc6\x36\x16\xd7\x5d\xb0\xa7\x16\x5b\x91\xc1\xef\x73\xe5"
19 "\x37\xf2\x42\x74\x05\xfa\x23\x61\x0a\x4b\xe6\x57\x64\x2e"; 19 "\x37\xf2\x42\x74\x05\xfa\x23\x61\x0a\x4b\xe6\x57\x64\x2e";
20 20
21 } // namespace 21 } // namespace
22 22
23 EasyUnlockChallengeWrapper::EasyUnlockChallengeWrapper( 23 EasyUnlockChallengeWrapper::EasyUnlockChallengeWrapper(
24 const std::string& challenge, 24 const std::string& challenge,
25 const std::string& channel_binding_data, 25 const std::string& channel_binding_data,
26 const std::string& user_id, 26 const AccountId& account_id,
27 EasyUnlockTpmKeyManager* key_manager) 27 EasyUnlockTpmKeyManager* key_manager)
28 : challenge_(challenge), 28 : challenge_(challenge),
29 channel_binding_data_(channel_binding_data), 29 channel_binding_data_(channel_binding_data),
30 user_id_(user_id), 30 account_id_(account_id),
31 key_manager_(key_manager), 31 key_manager_(key_manager),
32 weak_ptr_factory_(this) {} 32 weak_ptr_factory_(this) {}
33 33
34 EasyUnlockChallengeWrapper::~EasyUnlockChallengeWrapper() {} 34 EasyUnlockChallengeWrapper::~EasyUnlockChallengeWrapper() {}
35 35
36 void EasyUnlockChallengeWrapper::WrapChallenge( 36 void EasyUnlockChallengeWrapper::WrapChallenge(
37 const WrappedChallengeCallback& callback) { 37 const WrappedChallengeCallback& callback) {
38 callback_ = callback; 38 callback_ = callback;
39 39
40 // Because the TPM is used to sign the channel binding data, we need to 40 // Because the TPM is used to sign the channel binding data, we need to
(...skipping 14 matching lines...) Expand all
55 55
56 SignUsingTpmKey( 56 SignUsingTpmKey(
57 data_to_sign, 57 data_to_sign,
58 base::Bind(&EasyUnlockChallengeWrapper::OnChannelBindingDataSigned, 58 base::Bind(&EasyUnlockChallengeWrapper::OnChannelBindingDataSigned,
59 weak_ptr_factory_.GetWeakPtr(), signature_metadata)); 59 weak_ptr_factory_.GetWeakPtr(), signature_metadata));
60 } 60 }
61 61
62 void EasyUnlockChallengeWrapper::SignUsingTpmKey( 62 void EasyUnlockChallengeWrapper::SignUsingTpmKey(
63 const std::string& data_to_sign, 63 const std::string& data_to_sign,
64 const base::Callback<void(const std::string&)>& callback) { 64 const base::Callback<void(const std::string&)>& callback) {
65 key_manager_->SignUsingTpmKey(user_id_, data_to_sign, callback); 65 key_manager_->SignUsingTpmKey(account_id_, data_to_sign, callback);
66 } 66 }
67 67
68 void EasyUnlockChallengeWrapper::OnChannelBindingDataSigned( 68 void EasyUnlockChallengeWrapper::OnChannelBindingDataSigned(
69 const std::string& signature_metadata, 69 const std::string& signature_metadata,
70 const std::string& signature) { 70 const std::string& signature) {
71 // Wrap the challenge and channel binding signature in SecureMessage protos. 71 // Wrap the challenge and channel binding signature in SecureMessage protos.
72 securemessage::SecureMessage signature_container; 72 securemessage::SecureMessage signature_container;
73 signature_container.set_header_and_body(signature_metadata); 73 signature_container.set_header_and_body(signature_metadata);
74 signature_container.set_signature(signature); 74 signature_container.set_signature(signature);
75 75
76 securemessage::SecureMessage wrapped_challenge; 76 securemessage::SecureMessage wrapped_challenge;
77 wrapped_challenge.set_header_and_body(challenge_); 77 wrapped_challenge.set_header_and_body(challenge_);
78 wrapped_challenge.set_signature(signature_container.SerializeAsString()); 78 wrapped_challenge.set_signature(signature_container.SerializeAsString());
79 79
80 PA_LOG(INFO) << "Finished wrapping challenge."; 80 PA_LOG(INFO) << "Finished wrapping challenge.";
81 callback_.Run(wrapped_challenge.SerializeAsString()); 81 callback_.Run(wrapped_challenge.SerializeAsString());
82 } 82 }
83 83
84 } // namespace chromeos 84 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698