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

Side by Side Diff: remoting/protocol/v2_authenticator.cc

Issue 12316083: Move HostKeyPair into protocol::KeyPair. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 7 years, 9 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
« no previous file with comments | « remoting/protocol/v2_authenticator.h ('k') | remoting/protocol/v2_authenticator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/protocol/v2_authenticator.h" 5 #include "remoting/protocol/v2_authenticator.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "crypto/rsa_private_key.h"
10 #include "remoting/base/constants.h" 9 #include "remoting/base/constants.h"
10 #include "remoting/base/rsa_key_pair.h"
11 #include "remoting/protocol/ssl_hmac_channel_authenticator.h" 11 #include "remoting/protocol/ssl_hmac_channel_authenticator.h"
12 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 12 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
13 13
14 using crypto::P224EncryptedKeyExchange; 14 using crypto::P224EncryptedKeyExchange;
15 15
16 #if defined(_WIN32) && defined(GetMessage) 16 #if defined(_WIN32) && defined(GetMessage)
17 #undef GetMessage 17 #undef GetMessage
18 #endif 18 #endif
19 19
20 namespace remoting { 20 namespace remoting {
(...skipping 17 matching lines...) Expand all
38 scoped_ptr<Authenticator> V2Authenticator::CreateForClient( 38 scoped_ptr<Authenticator> V2Authenticator::CreateForClient(
39 const std::string& shared_secret, 39 const std::string& shared_secret,
40 Authenticator::State initial_state) { 40 Authenticator::State initial_state) {
41 return scoped_ptr<Authenticator>(new V2Authenticator( 41 return scoped_ptr<Authenticator>(new V2Authenticator(
42 P224EncryptedKeyExchange::kPeerTypeClient, shared_secret, initial_state)); 42 P224EncryptedKeyExchange::kPeerTypeClient, shared_secret, initial_state));
43 } 43 }
44 44
45 // static 45 // static
46 scoped_ptr<Authenticator> V2Authenticator::CreateForHost( 46 scoped_ptr<Authenticator> V2Authenticator::CreateForHost(
47 const std::string& local_cert, 47 const std::string& local_cert,
48 const crypto::RSAPrivateKey& local_private_key, 48 scoped_refptr<RsaKeyPair> key_pair,
49 const std::string& shared_secret, 49 const std::string& shared_secret,
50 Authenticator::State initial_state) { 50 Authenticator::State initial_state) {
51 scoped_ptr<V2Authenticator> result(new V2Authenticator( 51 scoped_ptr<V2Authenticator> result(new V2Authenticator(
52 P224EncryptedKeyExchange::kPeerTypeServer, shared_secret, initial_state)); 52 P224EncryptedKeyExchange::kPeerTypeServer, shared_secret, initial_state));
53 result->local_cert_ = local_cert; 53 result->local_cert_ = local_cert;
54 result->local_private_key_.reset(local_private_key.Copy()); 54 result->local_key_pair_ = key_pair;
55 return scoped_ptr<Authenticator>(result.Pass()); 55 return scoped_ptr<Authenticator>(result.Pass());
56 } 56 }
57 57
58 V2Authenticator::V2Authenticator( 58 V2Authenticator::V2Authenticator(
59 crypto::P224EncryptedKeyExchange::PeerType type, 59 crypto::P224EncryptedKeyExchange::PeerType type,
60 const std::string& shared_secret, 60 const std::string& shared_secret,
61 Authenticator::State initial_state) 61 Authenticator::State initial_state)
62 : certificate_sent_(false), 62 : certificate_sent_(false),
63 key_exchange_impl_(type, shared_secret), 63 key_exchange_impl_(type, shared_secret),
64 state_(initial_state), 64 state_(initial_state),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 186 }
187 187
188 scoped_ptr<ChannelAuthenticator> 188 scoped_ptr<ChannelAuthenticator>
189 V2Authenticator::CreateChannelAuthenticator() const { 189 V2Authenticator::CreateChannelAuthenticator() const {
190 DCHECK_EQ(state(), ACCEPTED); 190 DCHECK_EQ(state(), ACCEPTED);
191 CHECK(!auth_key_.empty()); 191 CHECK(!auth_key_.empty());
192 192
193 if (is_host_side()) { 193 if (is_host_side()) {
194 return scoped_ptr<ChannelAuthenticator>( 194 return scoped_ptr<ChannelAuthenticator>(
195 SslHmacChannelAuthenticator::CreateForHost( 195 SslHmacChannelAuthenticator::CreateForHost(
196 local_cert_, local_private_key_.get(), auth_key_).Pass()); 196 local_cert_, local_key_pair_, auth_key_).Pass());
197 } else { 197 } else {
198 return scoped_ptr<ChannelAuthenticator>( 198 return scoped_ptr<ChannelAuthenticator>(
199 SslHmacChannelAuthenticator::CreateForClient( 199 SslHmacChannelAuthenticator::CreateForClient(
200 remote_cert_, auth_key_).Pass()); 200 remote_cert_, auth_key_).Pass());
201 } 201 }
202 } 202 }
203 203
204 bool V2Authenticator::is_host_side() const { 204 bool V2Authenticator::is_host_side() const {
205 return local_private_key_.get() != NULL; 205 return local_key_pair_.get() != NULL;
206 } 206 }
207 207
208 } // namespace protocol 208 } // namespace protocol
209 } // namespace remoting 209 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/v2_authenticator.h ('k') | remoting/protocol/v2_authenticator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698