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

Unified Diff: components/proximity_auth/cryptauth/cryptauth_enrollment_utils.cc

Issue 877033005: Use a stable device-user identifier for CryptAuth enrollments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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: components/proximity_auth/cryptauth/cryptauth_enrollment_utils.cc
diff --git a/components/proximity_auth/cryptauth/cryptauth_enrollment_utils.cc b/components/proximity_auth/cryptauth/cryptauth_enrollment_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5f31b762040a8f7a5aee0b217a89ed1eac27080c
--- /dev/null
+++ b/components/proximity_auth/cryptauth/cryptauth_enrollment_utils.cc
@@ -0,0 +1,22 @@
+// Copyright 2015 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 "base/md5.h"
+#include "components/proximity_auth/cryptauth/cryptauth_enrollment_utils.h"
Ilya Sherman 2015/02/10 01:31:05 nit: This include should be first.
Tim Song 2015/02/10 22:20:33 Done.
+
+namespace proximity_auth {
+
+std::string CalculateDeviceUserId(const std::string& device_id,
+ const std::string& user_id) {
+ base::MD5Context context;
+ base::MD5Init(&context);
+ base::MD5Update(&context, device_id);
+ base::MD5Update(&context, user_id);
+
+ base::MD5Digest digest;
+ base::MD5Final(&digest, &context);
+ return base::MD5DigestToBase16(digest);
Ilya Sherman 2015/02/10 01:31:05 MD5 is somewhat frowned upon these days, as secure
Tim Song 2015/02/10 22:20:33 I mainly did it because MD5 is fast, but I switche
Ilya Sherman 2015/02/10 23:20:14 As long as we're using SHA, why not use SHA-256, v
+}
+
+} // namespace proximity_auth

Powered by Google App Engine
This is Rietveld 408576698