Chromium Code Reviews| Index: remoting/host/pin_hash.cc |
| diff --git a/remoting/host/pin_hash.cc b/remoting/host/pin_hash.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..86465f7fcd42c24cdcf582f6e23feaa6b4bb9588 |
| --- /dev/null |
| +++ b/remoting/host/pin_hash.cc |
| @@ -0,0 +1,25 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "remoting/host/pin_hash.h" |
| + |
| +#include "base/base64.h" |
| +#include "base/logging.h" |
| +#include "remoting/protocol/authentication_method.h" |
| + |
| +namespace remoting { |
| + |
| +// Hashes a host ID and a PIN. |
| +std::string GetPinHash(const std::string& host_id, const std::string& pin) { |
| + std::string hash = protocol::AuthenticationMethod::ApplyHashFunction( |
| + protocol::AuthenticationMethod::HMAC_SHA256, host_id, pin); |
| + std::string hash_base64; |
| + 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.
|
| + if (!base64_result) { |
| + LOG(FATAL) << "Base64Encode failed"; |
| + } |
| + return "hmac:" + hash_base64; |
| +} |
| + |
| +} // namespace remoting |