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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // UsernamePasskey wraps a username/passkey pair that can be used to
6 // authenticate a user.
7
8 #ifndef CRYPTOHOME_USERNAME_PASSKEY_H_
9 #define CRYPTOHOME_USERNAME_PASSKEY_H_
10
11 #include "cryptohome/credentials.h"
12
13 #include <string.h>
14
15 #include "base/basictypes.h"
16
17 namespace cryptohome {
18
19 class UsernamePasskey : public Credentials {
20 public:
21 // Constructs UsernamePasskey from username strings and passkeys
22 UsernamePasskey(const char *username, const int username_length,
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
30 ~UsernamePasskey();
31
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
41 void GetFullUsername(char *name_buffer, int length) const;
42 std::string GetFullUsername() const;
43 void GetPartialUsername(char *name_buffer, int length) const;
44 std::string GetObfuscatedUsername(const chromeos::Blob &system_salt) const;
45 SecureBlob GetPasskey() const;
46
47 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_;
55 SecureBlob passkey_;
56 };
57
58 } // namespace cryptohome
59
60 #endif // CRYPTOHOME_USERNAME_PASSKEY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698