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

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: Add missing files, move TestKeyPair. Created 7 years, 10 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 (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"
11 #include "remoting/protocol/ssl_hmac_channel_authenticator.h" 10 #include "remoting/protocol/ssl_hmac_channel_authenticator.h"
12 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 11 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
13 12
14 using crypto::P224EncryptedKeyExchange; 13 using crypto::P224EncryptedKeyExchange;
15 14
16 #if defined(_WIN32) && defined(GetMessage) 15 #if defined(_WIN32) && defined(GetMessage)
17 #undef GetMessage 16 #undef GetMessage
18 #endif 17 #endif
19 18
(...skipping 18 matching lines...) Expand all
38 scoped_ptr<Authenticator> V2Authenticator::CreateForClient( 37 scoped_ptr<Authenticator> V2Authenticator::CreateForClient(
39 const std::string& shared_secret, 38 const std::string& shared_secret,
40 Authenticator::State initial_state) { 39 Authenticator::State initial_state) {
41 return scoped_ptr<Authenticator>(new V2Authenticator( 40 return scoped_ptr<Authenticator>(new V2Authenticator(
42 P224EncryptedKeyExchange::kPeerTypeClient, shared_secret, initial_state)); 41 P224EncryptedKeyExchange::kPeerTypeClient, shared_secret, initial_state));
43 } 42 }
44 43
45 // static 44 // static
46 scoped_ptr<Authenticator> V2Authenticator::CreateForHost( 45 scoped_ptr<Authenticator> V2Authenticator::CreateForHost(
47 const std::string& local_cert, 46 const std::string& local_cert,
48 const crypto::RSAPrivateKey& local_private_key, 47 scoped_ptr<KeyPair> key_pair,
49 const std::string& shared_secret, 48 const std::string& shared_secret,
50 Authenticator::State initial_state) { 49 Authenticator::State initial_state) {
51 scoped_ptr<V2Authenticator> result(new V2Authenticator( 50 scoped_ptr<V2Authenticator> result(new V2Authenticator(
52 P224EncryptedKeyExchange::kPeerTypeServer, shared_secret, initial_state)); 51 P224EncryptedKeyExchange::kPeerTypeServer, shared_secret, initial_state));
53 result->local_cert_ = local_cert; 52 result->local_cert_ = local_cert;
54 result->local_private_key_.reset(local_private_key.Copy()); 53 result->key_pair_ = key_pair.Pass();
55 return scoped_ptr<Authenticator>(result.Pass()); 54 return scoped_ptr<Authenticator>(result.Pass());
56 } 55 }
57 56
58 V2Authenticator::V2Authenticator( 57 V2Authenticator::V2Authenticator(
59 crypto::P224EncryptedKeyExchange::PeerType type, 58 crypto::P224EncryptedKeyExchange::PeerType type,
60 const std::string& shared_secret, 59 const std::string& shared_secret,
61 Authenticator::State initial_state) 60 Authenticator::State initial_state)
62 : certificate_sent_(false), 61 : certificate_sent_(false),
63 key_exchange_impl_(type, shared_secret), 62 key_exchange_impl_(type, shared_secret),
64 state_(initial_state), 63 state_(initial_state),
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 179 }
181 180
182 scoped_ptr<ChannelAuthenticator> 181 scoped_ptr<ChannelAuthenticator>
183 V2Authenticator::CreateChannelAuthenticator() const { 182 V2Authenticator::CreateChannelAuthenticator() const {
184 DCHECK_EQ(state(), ACCEPTED); 183 DCHECK_EQ(state(), ACCEPTED);
185 CHECK(!auth_key_.empty()); 184 CHECK(!auth_key_.empty());
186 185
187 if (is_host_side()) { 186 if (is_host_side()) {
188 return scoped_ptr<ChannelAuthenticator>( 187 return scoped_ptr<ChannelAuthenticator>(
189 SslHmacChannelAuthenticator::CreateForHost( 188 SslHmacChannelAuthenticator::CreateForHost(
190 local_cert_, local_private_key_.get(), auth_key_).Pass()); 189 local_cert_, key_pair_->Copy(), auth_key_).Pass());
191 } else { 190 } else {
192 return scoped_ptr<ChannelAuthenticator>( 191 return scoped_ptr<ChannelAuthenticator>(
193 SslHmacChannelAuthenticator::CreateForClient( 192 SslHmacChannelAuthenticator::CreateForClient(
194 remote_cert_, auth_key_).Pass()); 193 remote_cert_, auth_key_).Pass());
195 } 194 }
196 } 195 }
197 196
198 bool V2Authenticator::is_host_side() const { 197 bool V2Authenticator::is_host_side() const {
199 return local_private_key_.get() != NULL; 198 return key_pair_.get() != NULL;
200 } 199 }
201 200
202 } // namespace protocol 201 } // namespace protocol
203 } // namespace remoting 202 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698