| 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 // AuthenticationMethod represents an authentication algorithm and its | 5 // AuthenticationMethod represents an authentication algorithm and its |
| 6 // configuration. It knows how to parse and format authentication | 6 // configuration. It knows how to parse and format authentication |
| 7 // method names. | 7 // method names. |
| 8 // Currently the following methods are supported: | 8 // Currently the following methods are supported: |
| 9 // spake2_plain - SPAKE2 without hashing applied to the password. | 9 // spake2_plain - SPAKE2 without hashing applied to the password. |
| 10 // spake2_hmac - SPAKE2 with HMAC hashing of the password. | 10 // spake2_hmac - SPAKE2 with HMAC hashing of the password. |
| 11 | 11 |
| 12 #ifndef REMOTING_PROTOCOL_AUTHENTICATION_METHOD_H_ | 12 #ifndef REMOTING_PROTOCOL_AUTHENTICATION_METHOD_H_ |
| 13 #define REMOTING_PROTOCOL_AUTHENTICATION_METHOD_H_ | 13 #define REMOTING_PROTOCOL_AUTHENTICATION_METHOD_H_ |
| 14 | 14 |
| 15 #include <string> | 15 #include <string> |
| 16 | 16 |
| 17 namespace remoting { | 17 namespace remoting { |
| 18 namespace protocol { | 18 namespace protocol { |
| 19 | 19 |
| 20 class Authenticator; | 20 class Authenticator; |
| 21 | 21 |
| 22 class AuthenticationMethod { | 22 class AuthenticationMethod { |
| 23 public: | 23 public: |
| 24 enum MethodType { | 24 enum MethodType { |
| 25 INVALID, | 25 INVALID, |
| 26 SPAKE2, | 26 SPAKE2, |
| 27 SPAKE2_PAIR, |
| 27 THIRD_PARTY | 28 THIRD_PARTY |
| 28 }; | 29 }; |
| 29 | 30 |
| 30 enum HashFunction { | 31 enum HashFunction { |
| 31 NONE, | 32 NONE, |
| 32 HMAC_SHA256, | 33 HMAC_SHA256, |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 // Constructors for various authentication methods. | 36 // Constructors for various authentication methods. |
| 36 static AuthenticationMethod Invalid(); | 37 static AuthenticationMethod Invalid(); |
| 37 static AuthenticationMethod Spake2(HashFunction hash_function); | 38 static AuthenticationMethod Spake2(HashFunction hash_function); |
| 39 static AuthenticationMethod Spake2Pair(); |
| 38 static AuthenticationMethod ThirdParty(); | 40 static AuthenticationMethod ThirdParty(); |
| 39 | 41 |
| 40 // Parses a string that defines an authentication method. Returns an | 42 // Parses a string that defines an authentication method. Returns an |
| 41 // invalid value if the string is invalid. | 43 // invalid value if the string is invalid. |
| 42 static AuthenticationMethod FromString(const std::string& value); | 44 static AuthenticationMethod FromString(const std::string& value); |
| 43 | 45 |
| 44 // Applies the specified hash function to |shared_secret| with the | 46 // Applies the specified hash function to |shared_secret| with the |
| 45 // specified |tag| as a key. | 47 // specified |tag| as a key. |
| 46 static std::string ApplyHashFunction(HashFunction hash_function, | 48 static std::string ApplyHashFunction(HashFunction hash_function, |
| 47 const std::string& tag, | 49 const std::string& tag, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 84 |
| 83 // Parse string representation of a shared secret hash. The |as_string| | 85 // Parse string representation of a shared secret hash. The |as_string| |
| 84 // must be in form "<hash_function>:<hash_value_base64>". | 86 // must be in form "<hash_function>:<hash_value_base64>". |
| 85 bool Parse(const std::string& as_string); | 87 bool Parse(const std::string& as_string); |
| 86 }; | 88 }; |
| 87 | 89 |
| 88 } // namespace protocol | 90 } // namespace protocol |
| 89 } // namespace remoting | 91 } // namespace remoting |
| 90 | 92 |
| 91 #endif // REMOTING_PROTOCOL_AUTHENTICATION_METHOD_H_ | 93 #endif // REMOTING_PROTOCOL_AUTHENTICATION_METHOD_H_ |
| OLD | NEW |