[email protected] | 2110957 | 2012-01-10 00:19:53 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 2110957 | 2012-01-10 00:19:53 | [diff] [blame] | 5 | #ifndef REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_ |
6 | #define REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_ | ||||
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 7 | |
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 8 | #include <memory> |
avi | 5a080f01 | 2015-12-22 23:15:43 | [diff] [blame] | 9 | #include <string> |
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 10 | |
11 | #include "base/compiler_specific.h" | ||||
Brett Wilson | b02c0a2 | 2017-09-25 22:34:42 | [diff] [blame] | 12 | #include "base/containers/queue.h" |
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 13 | #include "base/gtest_prod_util.h" |
avi | 5a080f01 | 2015-12-22 23:15:43 | [diff] [blame] | 14 | #include "base/macros.h" |
sergeyu | 64adc27 | 2016-03-12 09:12:43 | [diff] [blame] | 15 | #include "base/memory/ref_counted.h" |
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 16 | #include "crypto/p224_spake.h" |
17 | #include "remoting/protocol/authenticator.h" | ||||
18 | |||||
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 19 | namespace remoting { |
[email protected] | 8f1504b | 2013-03-07 13:43:10 | [diff] [blame] | 20 | |
21 | class RsaKeyPair; | ||||
22 | |||||
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 23 | namespace protocol { |
24 | |||||
25 | class V2Authenticator : public Authenticator { | ||||
26 | public: | ||||
27 | static bool IsEkeMessage(const buzz::XmlElement* message); | ||||
28 | |||||
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 29 | static std::unique_ptr<Authenticator> CreateForClient( |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 30 | const std::string& shared_secret, |
31 | State initial_state); | ||||
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 32 | |
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 33 | static std::unique_ptr<Authenticator> CreateForHost( |
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 34 | const std::string& local_cert, |
[email protected] | 8f1504b | 2013-03-07 13:43:10 | [diff] [blame] | 35 | scoped_refptr<RsaKeyPair> key_pair, |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 36 | const std::string& shared_secret, |
37 | State initial_state); | ||||
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 38 | |
dcheng | 562aba5 | 2014-10-21 12:30:14 | [diff] [blame] | 39 | ~V2Authenticator() override; |
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 40 | |
41 | // Authenticator interface. | ||||
dcheng | 562aba5 | 2014-10-21 12:30:14 | [diff] [blame] | 42 | State state() const override; |
43 | bool started() const override; | ||||
44 | RejectionReason rejection_reason() const override; | ||||
45 | void ProcessMessage(const buzz::XmlElement* message, | ||||
46 | const base::Closure& resume_callback) override; | ||||
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 47 | std::unique_ptr<buzz::XmlElement> GetNextMessage() override; |
sergeyu | 2a64040 | 2015-08-14 19:52:18 | [diff] [blame] | 48 | const std::string& GetAuthKey() const override; |
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 49 | std::unique_ptr<ChannelAuthenticator> CreateChannelAuthenticator() |
50 | const override; | ||||
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 51 | |
52 | private: | ||||
53 | FRIEND_TEST_ALL_PREFIXES(V2AuthenticatorTest, InvalidSecret); | ||||
54 | |||||
55 | V2Authenticator(crypto::P224EncryptedKeyExchange::PeerType type, | ||||
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 56 | const std::string& shared_secret, |
57 | State initial_state); | ||||
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 58 | |
[email protected] | c22db29 | 2013-03-01 07:59:40 | [diff] [blame] | 59 | virtual void ProcessMessageInternal(const buzz::XmlElement* message); |
60 | |||||
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 61 | bool is_host_side() const; |
62 | |||||
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 63 | // Used only for host authenticators. |
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 64 | std::string local_cert_; |
[email protected] | 8f1504b | 2013-03-07 13:43:10 | [diff] [blame] | 65 | scoped_refptr<RsaKeyPair> local_key_pair_; |
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 66 | bool certificate_sent_; |
67 | |||||
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 68 | // Used only for client authenticators. |
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 69 | std::string remote_cert_; |
70 | |||||
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 71 | // Used for both host and client authenticators. |
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 72 | crypto::P224EncryptedKeyExchange key_exchange_impl_; |
73 | State state_; | ||||
[email protected] | 064128c | 2014-04-07 22:33:28 | [diff] [blame] | 74 | bool started_; |
[email protected] | 6bad55c | 2012-01-24 20:50:27 | [diff] [blame] | 75 | RejectionReason rejection_reason_; |
Brett Wilson | b02c0a2 | 2017-09-25 22:34:42 | [diff] [blame] | 76 | base::queue<std::string> pending_messages_; |
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 77 | std::string auth_key_; |
78 | |||||
79 | DISALLOW_COPY_AND_ASSIGN(V2Authenticator); | ||||
80 | }; | ||||
81 | |||||
[email protected] | ac1042d | 2011-12-22 22:17:26 | [diff] [blame] | 82 | } // namespace protocol |
83 | } // namespace remoting | ||||
84 | |||||
[email protected] | 2110957 | 2012-01-10 00:19:53 | [diff] [blame] | 85 | #endif // REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_ |