| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_SPAKE2_AUTHENTICATOR_H_ | 5 #ifndef REMOTING_PROTOCOL_SPAKE2_AUTHENTICATOR_H_ |
| 6 #define REMOTING_PROTOCOL_SPAKE2_AUTHENTICATOR_H_ | 6 #define REMOTING_PROTOCOL_SPAKE2_AUTHENTICATOR_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <queue> | 9 #include <queue> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "remoting/protocol/authenticator.h" | 16 #include "remoting/protocol/authenticator.h" |
| 17 | 17 |
| 18 typedef struct spake2_ctx_st SPAKE2_CTX; | 18 typedef struct spake2_ctx_st SPAKE2_CTX; |
| 19 | 19 |
| 20 namespace remoting { | 20 namespace remoting { |
| 21 | 21 |
| 22 class RsaKeyPair; | 22 class RsaKeyPair; |
| 23 | 23 |
| 24 namespace protocol { | 24 namespace protocol { |
| 25 | 25 |
| 26 // Authenticator that uses SPAKE2 implementation from BoringSSL. It | 26 // Authenticator that uses SPAKE2 implementation from BoringSSL. It |
| 27 // implements SPAKE2 over Curve25519. | 27 // implements SPAKE2 over Curve25519. |
| 28 class Spake2Authenticator : public Authenticator { | 28 class Spake2Authenticator : public Authenticator { |
| 29 public: | 29 public: |
| 30 static scoped_ptr<Authenticator> CreateForClient( | 30 static std::unique_ptr<Authenticator> CreateForClient( |
| 31 const std::string& local_id, | 31 const std::string& local_id, |
| 32 const std::string& remote_id, | 32 const std::string& remote_id, |
| 33 const std::string& shared_secret, | 33 const std::string& shared_secret, |
| 34 State initial_state); | 34 State initial_state); |
| 35 | 35 |
| 36 static scoped_ptr<Authenticator> CreateForHost( | 36 static std::unique_ptr<Authenticator> CreateForHost( |
| 37 const std::string& local_id, | 37 const std::string& local_id, |
| 38 const std::string& remote_id, | 38 const std::string& remote_id, |
| 39 const std::string& local_cert, | 39 const std::string& local_cert, |
| 40 scoped_refptr<RsaKeyPair> key_pair, | 40 scoped_refptr<RsaKeyPair> key_pair, |
| 41 const std::string& shared_secret, | 41 const std::string& shared_secret, |
| 42 State initial_state); | 42 State initial_state); |
| 43 | 43 |
| 44 ~Spake2Authenticator() override; | 44 ~Spake2Authenticator() override; |
| 45 | 45 |
| 46 // Authenticator interface. | 46 // Authenticator interface. |
| 47 State state() const override; | 47 State state() const override; |
| 48 bool started() const override; | 48 bool started() const override; |
| 49 RejectionReason rejection_reason() const override; | 49 RejectionReason rejection_reason() const override; |
| 50 void ProcessMessage(const buzz::XmlElement* message, | 50 void ProcessMessage(const buzz::XmlElement* message, |
| 51 const base::Closure& resume_callback) override; | 51 const base::Closure& resume_callback) override; |
| 52 scoped_ptr<buzz::XmlElement> GetNextMessage() override; | 52 std::unique_ptr<buzz::XmlElement> GetNextMessage() override; |
| 53 const std::string& GetAuthKey() const override; | 53 const std::string& GetAuthKey() const override; |
| 54 scoped_ptr<ChannelAuthenticator> CreateChannelAuthenticator() const override; | 54 std::unique_ptr<ChannelAuthenticator> CreateChannelAuthenticator() |
| 55 const override; |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 FRIEND_TEST_ALL_PREFIXES(Spake2AuthenticatorTest, InvalidSecret); | 58 FRIEND_TEST_ALL_PREFIXES(Spake2AuthenticatorTest, InvalidSecret); |
| 58 | 59 |
| 59 Spake2Authenticator(const std::string& local_id, | 60 Spake2Authenticator(const std::string& local_id, |
| 60 const std::string& remote_id, | 61 const std::string& remote_id, |
| 61 const std::string& shared_secret, | 62 const std::string& shared_secret, |
| 62 bool is_host, | 63 bool is_host, |
| 63 State initial_state); | 64 State initial_state); |
| 64 | 65 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 91 std::string auth_key_; | 92 std::string auth_key_; |
| 92 std::string expected_verification_hash_; | 93 std::string expected_verification_hash_; |
| 93 | 94 |
| 94 DISALLOW_COPY_AND_ASSIGN(Spake2Authenticator); | 95 DISALLOW_COPY_AND_ASSIGN(Spake2Authenticator); |
| 95 }; | 96 }; |
| 96 | 97 |
| 97 } // namespace protocol | 98 } // namespace protocol |
| 98 } // namespace remoting | 99 } // namespace remoting |
| 99 | 100 |
| 100 #endif // REMOTING_PROTOCOL_SPAKE2_AUTHENTICATOR_H_ | 101 #endif // REMOTING_PROTOCOL_SPAKE2_AUTHENTICATOR_H_ |
| OLD | NEW |