Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_ | 5 #ifndef REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_ |
| 6 #define REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_ | 6 #define REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <queue> | 9 #include <queue> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "crypto/p224_spake.h" | 14 #include "crypto/p224_spake.h" |
| 15 #include "remoting/base/rsa_key_pair.h" | |
|
Wez
2013/03/06 00:43:25
nit: Can you forward-declare RsaKeyPair?
rmsousa
2013/03/06 04:36:49
Done.
| |
| 15 #include "remoting/protocol/authenticator.h" | 16 #include "remoting/protocol/authenticator.h" |
| 16 | 17 |
| 17 namespace crypto { | |
| 18 class RSAPrivateKey; | |
| 19 } // namespace crypto | |
| 20 | |
| 21 namespace remoting { | 18 namespace remoting { |
| 22 namespace protocol { | 19 namespace protocol { |
| 23 | 20 |
| 24 class V2Authenticator : public Authenticator { | 21 class V2Authenticator : public Authenticator { |
| 25 public: | 22 public: |
| 26 static bool IsEkeMessage(const buzz::XmlElement* message); | 23 static bool IsEkeMessage(const buzz::XmlElement* message); |
| 27 | 24 |
| 28 static scoped_ptr<Authenticator> CreateForClient( | 25 static scoped_ptr<Authenticator> CreateForClient( |
| 29 const std::string& shared_secret, | 26 const std::string& shared_secret, |
| 30 State initial_state); | 27 State initial_state); |
| 31 | 28 |
| 32 static scoped_ptr<Authenticator> CreateForHost( | 29 static scoped_ptr<Authenticator> CreateForHost( |
| 33 const std::string& local_cert, | 30 const std::string& local_cert, |
| 34 const crypto::RSAPrivateKey& local_private_key, | 31 scoped_refptr<RsaKeyPair> key_pair, |
| 35 const std::string& shared_secret, | 32 const std::string& shared_secret, |
| 36 State initial_state); | 33 State initial_state); |
| 37 | 34 |
| 38 virtual ~V2Authenticator(); | 35 virtual ~V2Authenticator(); |
| 39 | 36 |
| 40 // Authenticator interface. | 37 // Authenticator interface. |
| 41 virtual State state() const OVERRIDE; | 38 virtual State state() const OVERRIDE; |
| 42 virtual RejectionReason rejection_reason() const OVERRIDE; | 39 virtual RejectionReason rejection_reason() const OVERRIDE; |
| 43 virtual void ProcessMessage(const buzz::XmlElement* message) OVERRIDE; | 40 virtual void ProcessMessage(const buzz::XmlElement* message) OVERRIDE; |
| 44 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE; | 41 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE; |
| 45 virtual scoped_ptr<ChannelAuthenticator> | 42 virtual scoped_ptr<ChannelAuthenticator> |
| 46 CreateChannelAuthenticator() const OVERRIDE; | 43 CreateChannelAuthenticator() const OVERRIDE; |
| 47 | 44 |
| 48 private: | 45 private: |
| 49 FRIEND_TEST_ALL_PREFIXES(V2AuthenticatorTest, InvalidSecret); | 46 FRIEND_TEST_ALL_PREFIXES(V2AuthenticatorTest, InvalidSecret); |
| 50 | 47 |
| 51 V2Authenticator(crypto::P224EncryptedKeyExchange::PeerType type, | 48 V2Authenticator(crypto::P224EncryptedKeyExchange::PeerType type, |
| 52 const std::string& shared_secret, | 49 const std::string& shared_secret, |
| 53 State initial_state); | 50 State initial_state); |
| 54 | 51 |
| 55 bool is_host_side() const; | 52 bool is_host_side() const; |
| 56 | 53 |
| 57 // Used only for host authenticators. | 54 // Used only for host authenticators. |
| 58 std::string local_cert_; | 55 std::string local_cert_; |
| 59 scoped_ptr<crypto::RSAPrivateKey> local_private_key_; | 56 scoped_refptr<RsaKeyPair> local_key_pair_; |
| 60 bool certificate_sent_; | 57 bool certificate_sent_; |
| 61 | 58 |
| 62 // Used only for client authenticators. | 59 // Used only for client authenticators. |
| 63 std::string remote_cert_; | 60 std::string remote_cert_; |
| 64 | 61 |
| 65 // Used for both host and client authenticators. | 62 // Used for both host and client authenticators. |
| 66 crypto::P224EncryptedKeyExchange key_exchange_impl_; | 63 crypto::P224EncryptedKeyExchange key_exchange_impl_; |
| 67 State state_; | 64 State state_; |
| 68 RejectionReason rejection_reason_; | 65 RejectionReason rejection_reason_; |
| 69 std::queue<std::string> pending_messages_; | 66 std::queue<std::string> pending_messages_; |
| 70 std::string auth_key_; | 67 std::string auth_key_; |
| 71 | 68 |
| 72 DISALLOW_COPY_AND_ASSIGN(V2Authenticator); | 69 DISALLOW_COPY_AND_ASSIGN(V2Authenticator); |
| 73 }; | 70 }; |
| 74 | 71 |
| 75 } // namespace protocol | 72 } // namespace protocol |
| 76 } // namespace remoting | 73 } // namespace remoting |
| 77 | 74 |
| 78 #endif // REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_ | 75 #endif // REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_ |
| OLD | NEW |