Cleanup AuthenticationMethod usage.

Previously AuthenticationMethod type was used in many places. Removed
all dependencies on it except from NegotiatingAuthenticator classes.
AuthenticationMethod has been moved to
NegotiatingAuthenticatorBase::Method.

Also includes the following cleanups:
 - removed old authentication functions from auth_util.cc which were
   no longer needed.
 - Remove HashFunction enum as it wasn't useful.

BUG=589698

Review URL: https://codereview.chromium.org/1768383004

Cr-Commit-Position: refs/heads/master@{#380078}
diff --git a/remoting/protocol/negotiating_host_authenticator.cc b/remoting/protocol/negotiating_host_authenticator.cc
index bcdb591..bfdb80f4 100644
--- a/remoting/protocol/negotiating_host_authenticator.cc
+++ b/remoting/protocol/negotiating_host_authenticator.cc
@@ -38,7 +38,7 @@
   scoped_ptr<NegotiatingHostAuthenticator> result(
       new NegotiatingHostAuthenticator(local_cert, key_pair));
   result->shared_secret_hash_ = access_code;
-  result->AddMethod(AuthenticationMethod::SPAKE2_SHARED_SECRET_PLAIN);
+  result->AddMethod(Method::SPAKE2_SHARED_SECRET_PLAIN);
   return std::move(result);
 }
 
@@ -52,9 +52,9 @@
       new NegotiatingHostAuthenticator(local_cert, key_pair));
   result->shared_secret_hash_ = pin_hash;
   result->pairing_registry_ = pairing_registry;
-  result->AddMethod(AuthenticationMethod::SPAKE2_SHARED_SECRET_HMAC);
+  result->AddMethod(Method::SPAKE2_SHARED_SECRET_HMAC);
   if (pairing_registry.get()) {
-    result->AddMethod(AuthenticationMethod::SPAKE2_PAIR);
+    result->AddMethod(Method::SPAKE2_PAIR);
   }
   return std::move(result);
 }
@@ -68,7 +68,7 @@
   scoped_ptr<NegotiatingHostAuthenticator> result(
       new NegotiatingHostAuthenticator(local_cert, key_pair));
   result->token_validator_ = std::move(token_validator);
-  result->AddMethod(AuthenticationMethod::THIRD_PARTY);
+  result->AddMethod(Method::THIRD_PARTY);
   return std::move(result);
 }
 
@@ -81,11 +81,10 @@
   DCHECK_EQ(state(), WAITING_MESSAGE);
 
   std::string method_attr = message->Attr(kMethodAttributeQName);
-  AuthenticationMethod method = ParseAuthenticationMethodString(method_attr);
+  Method method = ParseMethodString(method_attr);
 
   // If the host has already chosen a method, it can't be changed by the client.
-  if (current_method_ != AuthenticationMethod::INVALID &&
-      method != current_method_) {
+  if (current_method_ != Method::INVALID && method != current_method_) {
     state_ = REJECTED;
     rejection_reason_ = PROTOCOL_ERROR;
     resume_callback.Run();
@@ -95,9 +94,9 @@
   // If the client did not specify a preferred auth method, or specified an
   // unknown or unsupported method, then select the first known method from
   // the supported-methods attribute.
-  if (method == AuthenticationMethod::INVALID ||
+  if (method == Method::INVALID ||
       std::find(methods_.begin(), methods_.end(), method) == methods_.end()) {
-    method = AuthenticationMethod::INVALID;
+    method = Method::INVALID;
 
     std::string supported_methods_attr =
         message->Attr(kSupportedMethodsAttributeQName);
@@ -115,9 +114,8 @@
          base::SplitString(supported_methods_attr,
                            std::string(1, kSupportedMethodsSeparator),
                            base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
-      AuthenticationMethod list_value =
-          ParseAuthenticationMethodString(method_str);
-      if (list_value != AuthenticationMethod::INVALID &&
+      Method list_value = ParseMethodString(method_str);
+      if (list_value != Method::INVALID &&
           std::find(methods_.begin(), methods_.end(), list_value) !=
               methods_.end()) {
         // Found common method.
@@ -126,7 +124,7 @@
       }
     }
 
-    if (method == AuthenticationMethod::INVALID) {
+    if (method == Method::INVALID) {
       // Failed to find a common auth method.
       state_ = REJECTED;
       rejection_reason_ = PROTOCOL_ERROR;
@@ -145,7 +143,7 @@
 
   // If the client specified a supported method, and the host hasn't chosen a
   // method yet, use the client's preferred method and process the message.
-  if (current_method_ == AuthenticationMethod::INVALID) {
+  if (current_method_ == Method::INVALID) {
     current_method_ = method;
     state_ = PROCESSING_MESSAGE;
     // Copy the message since the authenticator may process it asynchronously.
@@ -167,9 +165,9 @@
 void NegotiatingHostAuthenticator::CreateAuthenticator(
     Authenticator::State preferred_initial_state,
     const base::Closure& resume_callback) {
-  DCHECK(current_method_ != AuthenticationMethod::INVALID);
+  DCHECK(current_method_ != Method::INVALID);
 
-  if (current_method_ == AuthenticationMethod::THIRD_PARTY) {
+  if (current_method_ == Method::THIRD_PARTY) {
     // |ThirdPartyHostAuthenticator| takes ownership of |token_validator_|.
     // The authentication method negotiation logic should guarantee that only
     // one |ThirdPartyHostAuthenticator| will need to be created per session.
@@ -178,7 +176,7 @@
         base::Bind(&V2Authenticator::CreateForHost, local_cert_,
                    local_key_pair_),
         std::move(token_validator_)));
-  } else if (current_method_ == AuthenticationMethod::SPAKE2_PAIR &&
+  } else if (current_method_ == Method::SPAKE2_PAIR &&
              preferred_initial_state == WAITING_MESSAGE) {
     // If the client requested Spake2Pair and sent an initial message, attempt
     // the paired connection protocol.
@@ -193,10 +191,9 @@
     // Spake2Pair so that the client knows that the host supports pairing and
     // that it can therefore present the option to the user when they enter
     // the PIN.
-    DCHECK(current_method_ ==
-               AuthenticationMethod::SPAKE2_SHARED_SECRET_PLAIN ||
-           current_method_ == AuthenticationMethod::SPAKE2_SHARED_SECRET_HMAC ||
-           current_method_ == AuthenticationMethod::SPAKE2_PAIR);
+    DCHECK(current_method_ == Method::SPAKE2_SHARED_SECRET_PLAIN ||
+           current_method_ == Method::SPAKE2_SHARED_SECRET_HMAC ||
+           current_method_ == Method::SPAKE2_PAIR);
     current_authenticator_ = V2Authenticator::CreateForHost(
         local_cert_, local_key_pair_, shared_secret_hash_,
         preferred_initial_state);