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

Unified Diff: chrome/browser/chromeos/login/auth/key.h

Issue 296773002: Add a Key class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 7 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: chrome/browser/chromeos/login/auth/key.h
diff --git a/chrome/browser/chromeos/login/auth/key.h b/chrome/browser/chromeos/login/auth/key.h
new file mode 100644
index 0000000000000000000000000000000000000000..9b8e9725e71004495c983d7020b500a25e4e07cf
--- /dev/null
+++ b/chrome/browser/chromeos/login/auth/key.h
@@ -0,0 +1,52 @@
+// Copyright 2014 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.
+
+#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_KEY_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_KEY_H_
+
+#include <string>
+
+namespace chromeos {
+
+// Key for user authentication. The class supports hashing of plain text
+// passwords to generate keys as well as the use of pre-hashed keys.
+class Key {
+ public:
+ enum KeyType {
+ // Plain text password.
+ KEY_TYPE_PASSWORD_PLAIN,
+ // SHA256 of salt + password, first half only, lower-case hex encoded.
+ KEY_TYPE_SALTED_SHA256_TOP_HALF,
+ // PBKDF2 with 256 bit AES and 1234 iterations, base64 encoded.
+ KEY_TYPE_SALTED_PBKDF2_AES256_1234,
+ };
+
+ Key();
+ Key(const Key& other);
+ explicit Key(const std::string& plain_text_password);
+ Key(KeyType key_type, const std::string& salt, const std::string& secret);
+ ~Key();
+
+ bool operator==(const Key& other) const;
+
+ KeyType GetKeyType() const;
+ const std::string& GetSecret() const;
+ const std::string& GetLabel() const;
+
+ void SetLabel(const std::string& label);
+
+ void ClearSecret();
+
+ void Transform(KeyType target_key_type, const std::string& salt);
+
+ private:
+ KeyType key_type_;
+ std::string salt_;
+ std::string secret_;
+ std::string label_;
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_KEY_H_
« no previous file with comments | « chrome/browser/chromeos/login/auth/extended_authenticator.cc ('k') | chrome/browser/chromeos/login/auth/key.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698