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 // v1_token - deprecated V1 authentication mechanism, | 9 // v1_token - deprecated V1 authentication mechanism, |
10 // spake2_plain - SPAKE2 without hashing applied to the password. | 10 // spake2_plain - SPAKE2 without hashing applied to the password. |
11 // spake2_hmac - SPAKE2 with HMAC hashing of the password. | 11 // spake2_hmac - SPAKE2 with HMAC hashing of the password. |
12 | 12 |
13 #ifndef REMOTING_PROTOCOL_AUTHENTICATION_METHOD_H_ | 13 #ifndef REMOTING_PROTOCOL_AUTHENTICATION_METHOD_H_ |
14 #define REMOTING_PROTOCOL_AUTHENTICATION_METHOD_H_ | 14 #define REMOTING_PROTOCOL_AUTHENTICATION_METHOD_H_ |
15 | 15 |
16 #include <string> | 16 #include <string> |
17 | 17 |
18 #include "base/memory/scoped_ptr.h" | |
19 | |
20 namespace remoting { | 18 namespace remoting { |
21 namespace protocol { | 19 namespace protocol { |
22 | 20 |
23 class Authenticator; | 21 class Authenticator; |
24 | 22 |
25 class AuthenticationMethod { | 23 class AuthenticationMethod { |
26 public: | 24 public: |
27 enum HashFunction { | 25 enum HashFunction { |
28 NONE, | 26 NONE, |
29 HMAC_SHA256, | 27 HMAC_SHA256, |
(...skipping 26 matching lines...) Expand all Loading... |
56 | 54 |
57 // Comparison operators so that std::find() can be used with | 55 // Comparison operators so that std::find() can be used with |
58 // collections of this class. | 56 // collections of this class. |
59 bool operator ==(const AuthenticationMethod& other) const; | 57 bool operator ==(const AuthenticationMethod& other) const; |
60 bool operator !=(const AuthenticationMethod& other) const { | 58 bool operator !=(const AuthenticationMethod& other) const { |
61 return !(*this == other); | 59 return !(*this == other); |
62 } | 60 } |
63 | 61 |
64 private: | 62 private: |
65 AuthenticationMethod(); | 63 AuthenticationMethod(); |
66 AuthenticationMethod(HashFunction hash_function); | 64 explicit AuthenticationMethod(HashFunction hash_function); |
67 | 65 |
68 bool invalid_; | 66 bool invalid_; |
69 HashFunction hash_function_; | 67 HashFunction hash_function_; |
70 }; | 68 }; |
71 | 69 |
72 // SharedSecretHash stores hash of a host secret paired with the type | 70 // SharedSecretHash stores hash of a host secret paired with the type |
73 // of the hashing function. | 71 // of the hashing function. |
74 struct SharedSecretHash { | 72 struct SharedSecretHash { |
75 AuthenticationMethod::HashFunction hash_function; | 73 AuthenticationMethod::HashFunction hash_function; |
76 std::string value; | 74 std::string value; |
77 | 75 |
78 // Parse string representation of a shared secret hash. The |as_string| | 76 // Parse string representation of a shared secret hash. The |as_string| |
79 // must be in form "<hash_function>:<hash_value_base64>". | 77 // must be in form "<hash_function>:<hash_value_base64>". |
80 bool Parse(const std::string& as_string); | 78 bool Parse(const std::string& as_string); |
81 }; | 79 }; |
82 | 80 |
83 } // namespace protocol | 81 } // namespace protocol |
84 } // namespace remoting | 82 } // namespace remoting |
85 | 83 |
86 #endif // REMOTING_PROTOCOL_AUTHENTICATION_METHOD_H_ | 84 #endif // REMOTING_PROTOCOL_AUTHENTICATION_METHOD_H_ |
OLD | NEW |