summaryrefslogtreecommitdiffstats
path: root/remoting/protocol/authentication_method.cc
diff options
context:
space:
mode:
authorsimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-05 03:07:41 +0000
committersimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-05 03:07:41 +0000
commit8baba583071c36d85bc2ad49e3da3db419ec2dfb (patch)
tree7b85e566f88d666343cb6dd385b3da6253c93e84 /remoting/protocol/authentication_method.cc
parent47f2c69a9a107eae2ae8ce3a8de04b227969cca9 (diff)
downloadchromium_src-8baba583071c36d85bc2ad49e3da3db419ec2dfb.zip
chromium_src-8baba583071c36d85bc2ad49e3da3db419ec2dfb.tar.gz
chromium_src-8baba583071c36d85bc2ad49e3da3db419ec2dfb.tar.bz2
[Chromoting] Move SharedSecretHash from Me2MeHostAuthenticatorFactory to AuthenticationMethod.
This reduces the size of remoting_host_controller.exe, which depends on SharedSecretHash. BUG=126256 Review URL: http://codereview.chromium.org/10317021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135522 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol/authentication_method.cc')
-rw-r--r--remoting/protocol/authentication_method.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/remoting/protocol/authentication_method.cc b/remoting/protocol/authentication_method.cc
index fc9289f..ab60f39 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"
@@ -100,5 +101,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