Index: remoting/protocol/authentication_method.cc |
diff --git a/remoting/protocol/authentication_method.cc b/remoting/protocol/authentication_method.cc |
index ab60f399535289f9e5084b7d646519a85e91fd1d..71ec00880a9a88fecbca5d33c440f5e80572b59e 100644 |
--- a/remoting/protocol/authentication_method.cc |
+++ b/remoting/protocol/authentication_method.cc |
@@ -19,7 +19,12 @@ AuthenticationMethod AuthenticationMethod::Invalid() { |
// static |
AuthenticationMethod AuthenticationMethod::Spake2(HashFunction hash_function) { |
- return AuthenticationMethod(hash_function); |
+ return AuthenticationMethod(SPAKE2, hash_function); |
+} |
+ |
+// static |
+AuthenticationMethod AuthenticationMethod::ThirdParty() { |
+ return AuthenticationMethod(THIRD_PARTY, NONE); |
} |
// static |
@@ -29,6 +34,8 @@ AuthenticationMethod AuthenticationMethod::FromString( |
return Spake2(NONE); |
} else if (value == "spake2_hmac") { |
return Spake2(HMAC_SHA256); |
+ } else if (value == "third_party") { |
+ return ThirdParty(); |
} else { |
return AuthenticationMethod::Invalid(); |
} |
@@ -64,13 +71,15 @@ std::string AuthenticationMethod::ApplyHashFunction( |
} |
AuthenticationMethod::AuthenticationMethod() |
- : invalid_(true), |
+ : type_(INVALID), |
hash_function_(NONE) { |
} |
-AuthenticationMethod::AuthenticationMethod(HashFunction hash_function) |
- : invalid_(false), |
+AuthenticationMethod::AuthenticationMethod(MethodType type, |
+ HashFunction hash_function) |
+ : type_(type), |
hash_function_(hash_function) { |
+ DCHECK_NE(type_, INVALID); |
} |
AuthenticationMethod::HashFunction AuthenticationMethod::hash_function() const { |
@@ -81,6 +90,11 @@ AuthenticationMethod::HashFunction AuthenticationMethod::hash_function() const { |
const std::string AuthenticationMethod::ToString() const { |
DCHECK(is_valid()); |
+ if (type_ == THIRD_PARTY) |
+ return "third_party"; |
+ |
+ DCHECK_EQ(type_, SPAKE2); |
+ |
switch (hash_function_) { |
case NONE: |
return "spake2_plain"; |
@@ -88,17 +102,13 @@ const std::string AuthenticationMethod::ToString() const { |
return "spake2_hmac"; |
} |
- NOTREACHED(); |
- return ""; |
+ return "invalid"; |
} |
bool AuthenticationMethod::operator ==( |
const AuthenticationMethod& other) const { |
- if (!is_valid()) |
- return !other.is_valid(); |
- if (!other.is_valid()) |
- return false; |
- return hash_function_ == other.hash_function_; |
+ return type_ == other.type_ && |
+ hash_function_ == other.hash_function_; |
} |
bool SharedSecretHash::Parse(const std::string& as_string) { |