diff options
author | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-05 03:07:41 +0000 |
---|---|---|
committer | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-05 03:07:41 +0000 |
commit | 8baba583071c36d85bc2ad49e3da3db419ec2dfb (patch) | |
tree | 7b85e566f88d666343cb6dd385b3da6253c93e84 | |
parent | 47f2c69a9a107eae2ae8ce3a8de04b227969cca9 (diff) | |
download | chromium_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
-rw-r--r-- | remoting/protocol/authentication_method.cc | 22 | ||||
-rw-r--r-- | remoting/protocol/authentication_method.h | 11 | ||||
-rw-r--r-- | remoting/protocol/me2me_host_authenticator_factory.cc | 21 | ||||
-rw-r--r-- | remoting/protocol/me2me_host_authenticator_factory.h | 11 |
4 files changed, 33 insertions, 32 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 diff --git a/remoting/protocol/authentication_method.h b/remoting/protocol/authentication_method.h index 6702187..a4f003e 100644 --- a/remoting/protocol/authentication_method.h +++ b/remoting/protocol/authentication_method.h @@ -69,6 +69,17 @@ class AuthenticationMethod { HashFunction hash_function_; }; +// SharedSecretHash stores hash of a host secret paired with the type +// of the hashing function. +struct SharedSecretHash { + AuthenticationMethod::HashFunction hash_function; + std::string value; + + // 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); +}; + } // namespace protocol } // namespace remoting diff --git a/remoting/protocol/me2me_host_authenticator_factory.cc b/remoting/protocol/me2me_host_authenticator_factory.cc index 8762a48..776c2d1 100644 --- a/remoting/protocol/me2me_host_authenticator_factory.cc +++ b/remoting/protocol/me2me_host_authenticator_factory.cc @@ -57,27 +57,6 @@ class RejectingAuthenticator : public Authenticator { } // namespace -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; -} - Me2MeHostAuthenticatorFactory::Me2MeHostAuthenticatorFactory( const std::string& local_jid, const std::string& local_cert, diff --git a/remoting/protocol/me2me_host_authenticator_factory.h b/remoting/protocol/me2me_host_authenticator_factory.h index a2cf3e5..b0f9b4e 100644 --- a/remoting/protocol/me2me_host_authenticator_factory.h +++ b/remoting/protocol/me2me_host_authenticator_factory.h @@ -20,17 +20,6 @@ class RSAPrivateKey; namespace remoting { namespace protocol { -// SharedSecretHash stores hash of a host secret paired with the type -// of the hashing function. -struct SharedSecretHash { - AuthenticationMethod::HashFunction hash_function; - std::string value; - - // 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); -}; - class Me2MeHostAuthenticatorFactory : public AuthenticatorFactory { public: // Doesn't take ownership of |local_private_key|. |