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

Unified Diff: remoting/host/pin_hash.cc

Issue 10243011: [Chromoting] Factor out common code for pin hashing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698