Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / remoting / protocol / v2_authenticator.h
blob4e6f4483a7a1a6cee3c77e2641170d262fa80eb1
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
3 // found in the LICENSE file.
5 #ifndef REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_
6 #define REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_
8 #include <string>
9 #include <queue>
11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "crypto/p224_spake.h"
15 #include "remoting/protocol/authenticator.h"
17 namespace remoting {
19 class RsaKeyPair;
21 namespace protocol {
23 class V2Authenticator : public Authenticator {
24 public:
25 static bool IsEkeMessage(const buzz::XmlElement* message);
27 static scoped_ptr<Authenticator> CreateForClient(
28 const std::string& shared_secret,
29 State initial_state);
31 static scoped_ptr<Authenticator> CreateForHost(
32 const std::string& local_cert,
33 scoped_refptr<RsaKeyPair> key_pair,
34 const std::string& shared_secret,
35 State initial_state);
37 ~V2Authenticator() override;
39 // Authenticator interface.
40 State state() const override;
41 bool started() const override;
42 RejectionReason rejection_reason() const override;
43 void ProcessMessage(const buzz::XmlElement* message,
44 const base::Closure& resume_callback) override;
45 scoped_ptr<buzz::XmlElement> GetNextMessage() override;
46 scoped_ptr<ChannelAuthenticator> CreateChannelAuthenticator() const override;
48 private:
49 FRIEND_TEST_ALL_PREFIXES(V2AuthenticatorTest, InvalidSecret);
51 V2Authenticator(crypto::P224EncryptedKeyExchange::PeerType type,
52 const std::string& shared_secret,
53 State initial_state);
55 virtual void ProcessMessageInternal(const buzz::XmlElement* message);
57 bool is_host_side() const;
59 // Used only for host authenticators.
60 std::string local_cert_;
61 scoped_refptr<RsaKeyPair> local_key_pair_;
62 bool certificate_sent_;
64 // Used only for client authenticators.
65 std::string remote_cert_;
67 // Used for both host and client authenticators.
68 crypto::P224EncryptedKeyExchange key_exchange_impl_;
69 State state_;
70 bool started_;
71 RejectionReason rejection_reason_;
72 std::queue<std::string> pending_messages_;
73 std::string auth_key_;
75 DISALLOW_COPY_AND_ASSIGN(V2Authenticator);
78 } // namespace protocol
79 } // namespace remoting
81 #endif // REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_