Index: remoting/protocol/authentication_method.cc |
diff --git a/remoting/protocol/authentication_method.cc b/remoting/protocol/authentication_method.cc |
index 97dca63bd59fae95f95572d85e76ea3b3b33ba74..64ba574aa75f28fefdc75fe14c5b9b5c1e6f8169 100644 |
--- a/remoting/protocol/authentication_method.cc |
+++ b/remoting/protocol/authentication_method.cc |
@@ -4,6 +4,7 @@ |
#include "remoting/protocol/authentication_method.h" |
+#include "base/base64.h" |
#include "base/logging.h" |
#include "crypto/hmac.h" |
#include "remoting/protocol/auth_util.h" |
@@ -102,5 +103,26 @@ bool AuthenticationMethod::operator ==( |
return hash_function_ == other.hash_function_; |
} |
+bool SharedSecretHash::Parse(const std::string& as_string) { |
+ size_t separator = as_string.find(':'); |
+ if (separator == std::string::npos) |
+ return false; |
+ |
+ std::string function_name = as_string.substr(0, separator); |
+ if (function_name == "plain") { |
+ hash_function = AuthenticationMethod::NONE; |
+ } else if (function_name == "hmac") { |
+ hash_function = AuthenticationMethod::HMAC_SHA256; |
+ } else { |
+ return false; |
+ } |
+ |
+ if (!base::Base64Decode(as_string.substr(separator + 1), &value)) { |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
} // namespace protocol |
} // namespace remoting |