| OLD | NEW |
| 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 #ifndef REMOTING_HOST_PIN_HASH_H_ | 5 #ifndef REMOTING_HOST_PIN_HASH_H_ |
| 6 #define REMOTING_HOST_PIN_HASH_H_ | 6 #define REMOTING_HOST_PIN_HASH_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 namespace remoting { | 10 namespace remoting { |
| 11 | 11 |
| 12 // Creates a Me2Me shared-secret hash, consisting of the hash method, and the | 12 // Creates a Me2Me shared-secret hash, consisting of the hash method, and the |
| 13 // hashed host ID and PIN. | 13 // hashed host ID and PIN. |
| 14 std::string MakeHostPinHash(const std::string& host_id, const std::string& pin); | 14 std::string MakeHostPinHash(const std::string& host_id, const std::string& pin); |
| 15 | 15 |
| 16 // Parse string representation of a shared secret hash. The value can be either |
| 17 // "plain:<pin_in_base64>" or "hmac:<pin_hmac_in_base64>". In the first case the |
| 18 // returned value is automatically hashed. False is returned if |value| is in |
| 19 // invalid format. |
| 20 bool ParsePinHashFromConfig(const std::string& value, |
| 21 const std::string& host_id, |
| 22 std::string* pin_hash_out); |
| 23 |
| 16 // Extracts the hash function from the given hash, uses it to calculate the | 24 // Extracts the hash function from the given hash, uses it to calculate the |
| 17 // hash of the given host ID and PIN, and compares that hash to the given hash. | 25 // hash of the given host ID and PIN, and compares that hash to the given hash. |
| 18 // Returns true if the calculated and given hashes are equal. | 26 // Returns true if the calculated and given hashes are equal. |
| 19 bool VerifyHostPinHash(const std::string& hash, | 27 bool VerifyHostPinHash(const std::string& hash, |
| 20 const std::string& host_id, | 28 const std::string& host_id, |
| 21 const std::string& pin); | 29 const std::string& pin); |
| 22 | 30 |
| 23 } // namespace remoting | 31 } // namespace remoting |
| 24 | 32 |
| 25 #endif // REMOTING_HOST_PIN_HASH_ | 33 #endif // REMOTING_HOST_PIN_HASH_ |
| OLD | NEW |