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

Side by Side 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, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/protocol/authentication_method.h" 5 #include "remoting/protocol/authentication_method.h"
6 6
7 #include "base/base64.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "crypto/hmac.h" 9 #include "crypto/hmac.h"
9 #include "remoting/protocol/auth_util.h" 10 #include "remoting/protocol/auth_util.h"
10 #include "remoting/protocol/v1_authenticator.h" 11 #include "remoting/protocol/v1_authenticator.h"
11 #include "remoting/protocol/v2_authenticator.h" 12 #include "remoting/protocol/v2_authenticator.h"
12 13
13 namespace remoting { 14 namespace remoting {
14 namespace protocol { 15 namespace protocol {
15 16
16 // static 17 // static
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 96
96 bool AuthenticationMethod::operator ==( 97 bool AuthenticationMethod::operator ==(
97 const AuthenticationMethod& other) const { 98 const AuthenticationMethod& other) const {
98 if (!is_valid()) 99 if (!is_valid())
99 return !other.is_valid(); 100 return !other.is_valid();
100 if (!other.is_valid()) 101 if (!other.is_valid())
101 return false; 102 return false;
102 return hash_function_ == other.hash_function_; 103 return hash_function_ == other.hash_function_;
103 } 104 }
104 105
106 bool SharedSecretHash::Parse(const std::string& as_string) {
107 size_t separator = as_string.find(':');
108 if (separator == std::string::npos)
109 return false;
110
111 std::string function_name = as_string.substr(0, separator);
112 if (function_name == "plain") {
113 hash_function = AuthenticationMethod::NONE;
114 } else if (function_name == "hmac") {
115 hash_function = AuthenticationMethod::HMAC_SHA256;
116 } else {
117 return false;
118 }
119
120 if (!base::Base64Decode(as_string.substr(separator + 1), &value)) {
121 return false;
122 }
123
124 return true;
125 }
126
105 } // namespace protocol 127 } // namespace protocol
106 } // namespace remoting 128 } // namespace remoting
OLDNEW
« 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