blob: ee7502b5cbf3785e244d214f71f3635fdbd6c011 [file] [log] [blame]
[email protected]21109572012-01-10 00:19:531// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]ac1042d2011-12-22 22:17:262// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]21109572012-01-10 00:19:535#ifndef REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_
6#define REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_
[email protected]ac1042d2011-12-22 22:17:267
dcheng0765c492016-04-06 22:41:538#include <memory>
avi5a080f012015-12-22 23:15:439#include <string>
[email protected]ac1042d2011-12-22 22:17:2610
11#include "base/compiler_specific.h"
Brett Wilsonb02c0a22017-09-25 22:34:4212#include "base/containers/queue.h"
[email protected]ac1042d2011-12-22 22:17:2613#include "base/gtest_prod_util.h"
avi5a080f012015-12-22 23:15:4314#include "base/macros.h"
sergeyu64adc272016-03-12 09:12:4315#include "base/memory/ref_counted.h"
[email protected]ac1042d2011-12-22 22:17:2616#include "crypto/p224_spake.h"
17#include "remoting/protocol/authenticator.h"
18
[email protected]ac1042d2011-12-22 22:17:2619namespace remoting {
[email protected]8f1504b2013-03-07 13:43:1020
21class RsaKeyPair;
22
[email protected]ac1042d2011-12-22 22:17:2623namespace protocol {
24
25class V2Authenticator : public Authenticator {
26 public:
27 static bool IsEkeMessage(const buzz::XmlElement* message);
28
dcheng0765c492016-04-06 22:41:5329 static std::unique_ptr<Authenticator> CreateForClient(
[email protected]de702112012-01-30 23:31:4330 const std::string& shared_secret,
31 State initial_state);
[email protected]ac1042d2011-12-22 22:17:2632
dcheng0765c492016-04-06 22:41:5333 static std::unique_ptr<Authenticator> CreateForHost(
[email protected]ac1042d2011-12-22 22:17:2634 const std::string& local_cert,
[email protected]8f1504b2013-03-07 13:43:1035 scoped_refptr<RsaKeyPair> key_pair,
[email protected]de702112012-01-30 23:31:4336 const std::string& shared_secret,
37 State initial_state);
[email protected]ac1042d2011-12-22 22:17:2638
dcheng562aba52014-10-21 12:30:1439 ~V2Authenticator() override;
[email protected]ac1042d2011-12-22 22:17:2640
41 // Authenticator interface.
dcheng562aba52014-10-21 12:30:1442 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;
dcheng0765c492016-04-06 22:41:5347 std::unique_ptr<buzz::XmlElement> GetNextMessage() override;
sergeyu2a640402015-08-14 19:52:1848 const std::string& GetAuthKey() const override;
dcheng0765c492016-04-06 22:41:5349 std::unique_ptr<ChannelAuthenticator> CreateChannelAuthenticator()
50 const override;
[email protected]ac1042d2011-12-22 22:17:2651
52 private:
53 FRIEND_TEST_ALL_PREFIXES(V2AuthenticatorTest, InvalidSecret);
54
55 V2Authenticator(crypto::P224EncryptedKeyExchange::PeerType type,
[email protected]de702112012-01-30 23:31:4356 const std::string& shared_secret,
57 State initial_state);
[email protected]ac1042d2011-12-22 22:17:2658
[email protected]c22db292013-03-01 07:59:4059 virtual void ProcessMessageInternal(const buzz::XmlElement* message);
60
[email protected]ac1042d2011-12-22 22:17:2661 bool is_host_side() const;
62
[email protected]de702112012-01-30 23:31:4363 // Used only for host authenticators.
[email protected]ac1042d2011-12-22 22:17:2664 std::string local_cert_;
[email protected]8f1504b2013-03-07 13:43:1065 scoped_refptr<RsaKeyPair> local_key_pair_;
[email protected]ac1042d2011-12-22 22:17:2666 bool certificate_sent_;
67
[email protected]de702112012-01-30 23:31:4368 // Used only for client authenticators.
[email protected]ac1042d2011-12-22 22:17:2669 std::string remote_cert_;
70
[email protected]de702112012-01-30 23:31:4371 // Used for both host and client authenticators.
[email protected]ac1042d2011-12-22 22:17:2672 crypto::P224EncryptedKeyExchange key_exchange_impl_;
73 State state_;
[email protected]064128c2014-04-07 22:33:2874 bool started_;
[email protected]6bad55c2012-01-24 20:50:2775 RejectionReason rejection_reason_;
Brett Wilsonb02c0a22017-09-25 22:34:4276 base::queue<std::string> pending_messages_;
[email protected]ac1042d2011-12-22 22:17:2677 std::string auth_key_;
78
79 DISALLOW_COPY_AND_ASSIGN(V2Authenticator);
80};
81
[email protected]ac1042d2011-12-22 22:17:2682} // namespace protocol
83} // namespace remoting
84
[email protected]21109572012-01-10 00:19:5385#endif // REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_