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

Side by Side Diff: trunk/src/remoting/host/pin_hash.cc

Issue 101113004: Revert 239759 "The comment in base64.h implies that base::Base64..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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/host/pin_hash.h" 5 #include "remoting/host/pin_hash.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "remoting/protocol/authentication_method.h" 9 #include "remoting/protocol/authentication_method.h"
10 #include "remoting/protocol/me2me_host_authenticator_factory.h" 10 #include "remoting/protocol/me2me_host_authenticator_factory.h"
11 11
12 namespace remoting { 12 namespace remoting {
13 13
14 std::string MakeHostPinHash(const std::string& host_id, 14 std::string MakeHostPinHash(const std::string& host_id,
15 const std::string& pin) { 15 const std::string& pin) {
16 std::string hash = protocol::AuthenticationMethod::ApplyHashFunction( 16 std::string hash = protocol::AuthenticationMethod::ApplyHashFunction(
17 protocol::AuthenticationMethod::HMAC_SHA256, host_id, pin); 17 protocol::AuthenticationMethod::HMAC_SHA256, host_id, pin);
18 std::string hash_base64; 18 std::string hash_base64;
19 base::Base64Encode(hash, &hash_base64); 19 if (!base::Base64Encode(hash, &hash_base64)) {
20 LOG(FATAL) << "Base64Encode failed";
21 }
20 return "hmac:" + hash_base64; 22 return "hmac:" + hash_base64;
21 } 23 }
22 24
23 bool VerifyHostPinHash(const std::string& hash, 25 bool VerifyHostPinHash(const std::string& hash,
24 const std::string& host_id, 26 const std::string& host_id,
25 const std::string& pin) { 27 const std::string& pin) {
26 remoting::protocol::SharedSecretHash hash_parsed; 28 remoting::protocol::SharedSecretHash hash_parsed;
27 if (!hash_parsed.Parse(hash)) { 29 if (!hash_parsed.Parse(hash)) {
28 LOG(FATAL) << "Invalid hash."; 30 LOG(FATAL) << "Invalid hash.";
29 return false; 31 return false;
30 } 32 }
31 std::string hash_calculated = 33 std::string hash_calculated =
32 remoting::protocol::AuthenticationMethod::ApplyHashFunction( 34 remoting::protocol::AuthenticationMethod::ApplyHashFunction(
33 hash_parsed.hash_function, host_id, pin); 35 hash_parsed.hash_function, host_id, pin);
34 return hash_calculated == hash_parsed.value; 36 return hash_calculated == hash_parsed.value;
35 } 37 }
36 38
37 } // namespace remoting 39 } // namespace remoting
OLDNEW
« no previous file with comments | « trunk/src/remoting/base/rsa_key_pair.cc ('k') | trunk/src/remoting/host/token_validator_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698