OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013 The Chromium 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 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_PASSPHRASE_H_ | |
6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_PASSPHRASE_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 | |
12 // This class can be used to derive a hash of a provided passphrase. When an | |
13 // empty salt is given as parameter to the constructor, a new salt is | |
14 // generated randomly, which can be accessed through the |GetSalt| method. | |
15 class ManagedUserPassphrase { | |
16 public: | |
17 explicit ManagedUserPassphrase(const std::string& salt); | |
18 ~ManagedUserPassphrase(); | |
19 | |
20 std::string GetSalt(); | |
21 | |
22 // This function generates a hash from a passphrase, which should be provided | |
23 // as the first parameter. On return, the second parameter will contain the | |
24 // Base64-encoded hash of the password. | |
25 bool GenerateHashFromPassphrase(const std::string& passphrase, | |
26 std::string* encoded_passphrase_hash) const; | |
27 | |
28 private: | |
29 bool GetPassphraseHash(const std::string& passphrase, | |
30 std::string* passphrase_hash) const; | |
31 void GenerateRandomSalt(); | |
32 | |
33 std::string salt_; | |
34 | |
35 DISALLOW_COPY_AND_ASSIGN(ManagedUserPassphrase); | |
36 }; | |
37 | |
38 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_USER_PASSPHRASE_H_ | |
OLD | NEW |