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

Unified Diff: remoting/protocol/authentication_method.cc

Issue 10317021: [Chromoting] Move SharedSecretHash from Me2MeHostAuthenticatorFactory to AuthenticationMethod. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync. Created 8 years, 8 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
« no previous file with comments | « remoting/protocol/authentication_method.h ('k') | remoting/protocol/me2me_host_authenticator_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « remoting/protocol/authentication_method.h ('k') | remoting/protocol/me2me_host_authenticator_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698