pin_hash.h 1.3 KB

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