Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1338)

Unified Diff: remoting/protocol/authentication_method.h

Issue 1755273003: Simplify AuthenticationMethod type and PIN hash handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/authentication_method.h
diff --git a/remoting/protocol/authentication_method.h b/remoting/protocol/authentication_method.h
index c2265d5e7d38e1b42138efbaf40203d61b453790..1b8dc46bddf5b09f0b09925e3bf31f56334e9f1c 100644
--- a/remoting/protocol/authentication_method.h
+++ b/remoting/protocol/authentication_method.h
@@ -1,14 +1,6 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
-// AuthenticationMethod represents an authentication algorithm and its
-// configuration. It knows how to parse and format authentication
-// method names.
-// Currently the following methods are supported:
-// spake2_plain - SPAKE2 without hashing applied to the password.
-// spake2_hmac - SPAKE2 with HMAC hashing of the password.
-
#ifndef REMOTING_PROTOCOL_AUTHENTICATION_METHOD_H_
#define REMOTING_PROTOCOL_AUTHENTICATION_METHOD_H_
@@ -19,73 +11,37 @@ namespace protocol {
class Authenticator;
-class AuthenticationMethod {
- public:
- enum MethodType {
- INVALID,
- SPAKE2,
- SPAKE2_PAIR,
- THIRD_PARTY
- };
-
- enum HashFunction {
- NONE,
- HMAC_SHA256,
- };
-
- // Constructors for various authentication methods.
- static AuthenticationMethod Invalid();
- static AuthenticationMethod Spake2(HashFunction hash_function);
- static AuthenticationMethod Spake2Pair();
- static AuthenticationMethod ThirdParty();
-
- // Parses a string that defines an authentication method. Returns an
- // invalid value if the string is invalid.
- static AuthenticationMethod FromString(const std::string& value);
-
- // Applies the specified hash function to |shared_secret| with the
- // specified |tag| as a key.
- static std::string ApplyHashFunction(HashFunction hash_function,
- const std::string& tag,
- const std::string& shared_secret);
-
- bool is_valid() const { return type_ != INVALID; }
-
- MethodType type() const { return type_; }
-
- // Following methods are valid only when is_valid() returns true.
-
- // Hash function applied to the shared secret on both ends.
- HashFunction hash_function() const;
-
- // Returns string representation of the value stored in this object.
- const std::string ToString() const;
+// AuthenticationMethod represents an authentication algorithm.
+enum class AuthenticationMethod {
+ INVALID,
+ SPAKE2_SHARED_SECRET_PLAIN,
+ SPAKE2_SHARED_SECRET_HMAC,
+ SPAKE2_PAIR,
+ THIRD_PARTY
+};
- // Comparison operators so that std::find() can be used with
- // collections of this class.
- bool operator ==(const AuthenticationMethod& other) const;
- bool operator !=(const AuthenticationMethod& other) const {
- return !(*this == other);
- }
+enum class HashFunction {
+ NONE,
+ HMAC_SHA256,
+};
- protected:
- AuthenticationMethod();
- AuthenticationMethod(MethodType type, HashFunction hash_function);
+// Parses a string that defines an authentication method. Returns
+// AuthenticationMethod::INVALID if the string is invalid.
+AuthenticationMethod ParseAuthenticationMethodString(const std::string& value);
- MethodType type_;
- HashFunction hash_function_;
-};
+// Returns string representation of |method|.
+const std::string AuthenticationMethodToString(AuthenticationMethod method);
-// SharedSecretHash stores hash of a host secret paired with the type
-// of the hashing function.
-struct SharedSecretHash {
- AuthenticationMethod::HashFunction hash_function;
- std::string value;
+// Returns hash function applied to the shared secret on both ends for the
+// spefied |method|.
+HashFunction GetHashFunctionForAuthenticationMethod(
+ AuthenticationMethod method);
- // Parse string representation of a shared secret hash. The |as_string|
- // must be in form "<hash_function>:<hash_value_base64>".
- bool Parse(const std::string& as_string);
-};
+// Applies the specified hash function to |shared_secret| with the
+// specified |tag| as a key.
+std::string ApplySharedSecretHashFunction(HashFunction hash_function,
+ const std::string& tag,
+ const std::string& shared_secret);
} // namespace protocol
} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698