[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
parent 47f2c69a
......@@ -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
......@@ -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
......
......@@ -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,
......
......@@ -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|.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment