OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "remoting/host/pin_hash.h" | |
6 | |
7 #include "base/base64.h" | |
8 #include "base/logging.h" | |
9 #include "remoting/protocol/authentication_method.h" | |
10 | |
11 namespace remoting { | |
12 | |
13 // Hashes a host ID and a PIN. | |
14 std::string GetPinHash(const std::string& host_id, const std::string& pin) { | |
15 std::string hash = protocol::AuthenticationMethod::ApplyHashFunction( | |
16 protocol::AuthenticationMethod::HMAC_SHA256, host_id, pin); | |
17 std::string hash_base64; | |
18 bool base64_result = base::Base64Encode(hash, &hash_base64); | |
Wez
2012/04/30 23:13:57
nit: Test base::Base64Encode()'s result directly r
simonmorris
2012/05/01 00:25:55
Done.
| |
19 if (!base64_result) { | |
20 LOG(FATAL) << "Base64Encode failed"; | |
21 } | |
22 return "hmac:" + hash_base64; | |
23 } | |
24 | |
25 } // namespace remoting | |
OLD | NEW |