| OLD | NEW |
| 1 // Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // UsernamePasskey wraps a username/passkey pair that can be used to | 5 // UsernamePasskey wraps a username/passkey pair that can be used to |
| 6 // authenticate a user. | 6 // authenticate a user. |
| 7 | 7 |
| 8 #ifndef CRYPTOHOME_USERNAME_PASSKEY_H_ | 8 #ifndef CRYPTOHOME_USERNAME_PASSKEY_H_ |
| 9 #define CRYPTOHOME_USERNAME_PASSKEY_H_ | 9 #define CRYPTOHOME_USERNAME_PASSKEY_H_ |
| 10 | 10 |
| 11 #include "cryptohome/credentials.h" | 11 #include "credentials.h" |
| 12 | 12 |
| 13 #include <string.h> | 13 #include <base/basictypes.h> |
| 14 | 14 #include <string> |
| 15 #include "base/basictypes.h" | |
| 16 | 15 |
| 17 namespace cryptohome { | 16 namespace cryptohome { |
| 18 | 17 |
| 19 class UsernamePasskey : public Credentials { | 18 class UsernamePasskey : public Credentials { |
| 20 public: | 19 public: |
| 21 // Constructs UsernamePasskey from username strings and passkeys | 20 // Constructs UsernamePasskey from username strings and passkeys and passwords |
| 22 UsernamePasskey(const char *username, const int username_length, | 21 UsernamePasskey(const char* username, const chromeos::Blob& passkey); |
| 23 const char *passkey, const int passkey_length); | |
| 24 UsernamePasskey(const char *username, const int username_length, | |
| 25 const chromeos::Blob& passkey); | |
| 26 UsernamePasskey(const char *username, const int username_length, | |
| 27 const std::string& passkey); | |
| 28 UsernamePasskey(const UsernamePasskey& rhs); | |
| 29 | 22 |
| 30 ~UsernamePasskey(); | 23 ~UsernamePasskey(); |
| 31 | 24 |
| 32 UsernamePasskey& operator=(const UsernamePasskey& rhs); | |
| 33 | |
| 34 // Constructs UsernamePasskey from a username and password, converting the | |
| 35 // password to a passkey using the given salt | |
| 36 static UsernamePasskey FromUsernamePassword(const char* username, | |
| 37 const char* password, | |
| 38 const chromeos::Blob& salt); | |
| 39 | |
| 40 // Overridden from cryptohome::Credentials | 25 // Overridden from cryptohome::Credentials |
| 41 void GetFullUsername(char *name_buffer, int length) const; | 26 void GetFullUsername(char *name_buffer, int length) const; |
| 42 std::string GetFullUsername() const; | 27 std::string GetFullUsernameString() const; |
| 43 void GetPartialUsername(char *name_buffer, int length) const; | 28 void GetPartialUsername(char *name_buffer, int length) const; |
| 44 std::string GetObfuscatedUsername(const chromeos::Blob &system_salt) const; | 29 std::string GetObfuscatedUsername(const chromeos::Blob &system_salt) const; |
| 45 SecureBlob GetPasskey() const; | 30 void GetPasskey(SecureBlob* passkey) const; |
| 46 | 31 |
| 47 private: | 32 private: |
| 48 static SecureBlob PasswordToPasskey(const char *password, | |
| 49 const chromeos::Blob& salt); | |
| 50 static void AsciiEncodeToBuffer(const unsigned char* source, | |
| 51 int source_length, char* buffer, | |
| 52 int buffer_length); | |
| 53 | |
| 54 std::string username_; | 33 std::string username_; |
| 55 SecureBlob passkey_; | 34 SecureBlob passkey_; |
| 35 |
| 36 DISALLOW_COPY_AND_ASSIGN(UsernamePasskey); |
| 56 }; | 37 }; |
| 57 | 38 |
| 58 } // namespace cryptohome | 39 } // namespace cryptohome |
| 59 | 40 |
| 60 #endif // CRYPTOHOME_USERNAME_PASSKEY_H_ | 41 #endif // CRYPTOHOME_USERNAME_PASSKEY_H_ |
| OLD | NEW |