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

Unified Diff: src/platform/cryptohome/username_passkey.h

Issue 2051003: Initial patch from Will. (Closed) Base URL: ssh://git@chromiumos-git/chromiumos
Patch Set: Address style nits. Created 10 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: src/platform/cryptohome/username_passkey.h
diff --git a/src/platform/cryptohome/username_passkey.h b/src/platform/cryptohome/username_passkey.h
new file mode 100644
index 0000000000000000000000000000000000000000..e2dc99f67891babb3ee176dbe1cfdb2556cc0bbd
--- /dev/null
+++ b/src/platform/cryptohome/username_passkey.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// UsernamePasskey wraps a username/passkey pair that can be used to
+// authenticate a user.
+
+#ifndef CRYPTOHOME_USERNAME_PASSKEY_H_
+#define CRYPTOHOME_USERNAME_PASSKEY_H_
+
+#include "cryptohome/credentials.h"
+
+#include <string.h>
+
+#include "base/basictypes.h"
+
+namespace cryptohome {
+
+class UsernamePasskey : public Credentials {
+ public:
+ // Constructs UsernamePasskey from username strings and passkeys
+ UsernamePasskey(const char *username, const int username_length,
+ const char *passkey, const int passkey_length);
+ UsernamePasskey(const char *username, const int username_length,
+ const chromeos::Blob& passkey);
+ UsernamePasskey(const char *username, const int username_length,
+ const std::string& passkey);
+ UsernamePasskey(const UsernamePasskey& rhs);
+
+ ~UsernamePasskey();
+
+ UsernamePasskey& operator=(const UsernamePasskey& rhs);
+
+ // Constructs UsernamePasskey from a username and password, converting the
+ // password to a passkey using the given salt
+ static UsernamePasskey FromUsernamePassword(const char* username,
+ const char* password,
+ const chromeos::Blob& salt);
+
+ // Overridden from cryptohome::Credentials
+ void GetFullUsername(char *name_buffer, int length) const;
+ std::string GetFullUsername() const;
+ void GetPartialUsername(char *name_buffer, int length) const;
+ std::string GetObfuscatedUsername(const chromeos::Blob &system_salt) const;
+ SecureBlob GetPasskey() const;
+
+ private:
+ static SecureBlob PasswordToPasskey(const char *password,
+ const chromeos::Blob& salt);
+ static void AsciiEncodeToBuffer(const unsigned char* source,
+ int source_length, char* buffer,
+ int buffer_length);
+
+ std::string username_;
+ SecureBlob passkey_;
+};
+
+} // namespace cryptohome
+
+#endif // CRYPTOHOME_USERNAME_PASSKEY_H_

Powered by Google App Engine
This is Rietveld 408576698