OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 #ifndef CRYPTO_NSS_UTIL_INTERNAL_H_ | 5 #ifndef CRYPTO_NSS_UTIL_INTERNAL_H_ |
6 #define CRYPTO_NSS_UTIL_INTERNAL_H_ | 6 #define CRYPTO_NSS_UTIL_INTERNAL_H_ |
7 | 7 |
8 #include <secmodt.h> | 8 #include <secmodt.h> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "crypto/crypto_export.h" | 12 #include "crypto/crypto_export.h" |
13 #include "crypto/scoped_nss_types.h" | 13 #include "crypto/scoped_nss_types.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class FilePath; | 16 class FilePath; |
17 } | 17 } |
18 | 18 |
19 // These functions return a type defined in an NSS header, and so cannot be | 19 // These functions return a type defined in an NSS header, and so cannot be |
20 // declared in nss_util.h. Hence, they are declared here. | 20 // declared in nss_util.h. Hence, they are declared here. |
21 | 21 |
22 namespace crypto { | 22 namespace crypto { |
23 | 23 |
24 // Returns a reference to the default NSS key slot for storing | 24 // Returns a reference to the default NSS key slot for storing persistent data. |
25 // public-key data only (e.g. server certs). Caller must release | 25 // Caller must release returned reference with PK11_FreeSlot. |
26 // returned reference with PK11_FreeSlot. | 26 // TODO(mattm): this should be if !defined(OS_CHROMEOS), but some tests need to |
27 CRYPTO_EXPORT PK11SlotInfo* GetPublicNSSKeySlot() WARN_UNUSED_RESULT; | 27 // be fixed first. |
28 | 28 CRYPTO_EXPORT PK11SlotInfo* GetPersistentNSSKeySlot() WARN_UNUSED_RESULT; |
29 // Returns a reference to the default slot for storing private-key and | |
30 // mixed private-key/public-key data. Returns a hardware (TPM) NSS | |
31 // key slot if on ChromeOS and EnableTPMForNSS() has been called | |
32 // successfully. Caller must release returned reference with | |
33 // PK11_FreeSlot. | |
34 CRYPTO_EXPORT PK11SlotInfo* GetPrivateNSSKeySlot() WARN_UNUSED_RESULT; | |
35 | 29 |
36 // A helper class that acquires the SECMOD list read lock while the | 30 // A helper class that acquires the SECMOD list read lock while the |
37 // AutoSECMODListReadLock is in scope. | 31 // AutoSECMODListReadLock is in scope. |
38 class CRYPTO_EXPORT AutoSECMODListReadLock { | 32 class CRYPTO_EXPORT AutoSECMODListReadLock { |
39 public: | 33 public: |
40 AutoSECMODListReadLock(); | 34 AutoSECMODListReadLock(); |
41 ~AutoSECMODListReadLock(); | 35 ~AutoSECMODListReadLock(); |
42 | 36 |
43 private: | 37 private: |
44 SECMODListLock* lock_; | 38 SECMODListLock* lock_; |
45 DISALLOW_COPY_AND_ASSIGN(AutoSECMODListReadLock); | 39 DISALLOW_COPY_AND_ASSIGN(AutoSECMODListReadLock); |
46 }; | 40 }; |
47 | 41 |
48 #if defined(OS_CHROMEOS) | 42 #if defined(OS_CHROMEOS) |
| 43 // Returns a reference to the system-wide TPM slot. Caller must release |
| 44 // returned reference with PK11_FreeSlot. |
| 45 CRYPTO_EXPORT PK11SlotInfo* GetSystemNSSKeySlot() WARN_UNUSED_RESULT; |
| 46 |
49 // Prepare per-user NSS slot mapping. It is safe to call this function multiple | 47 // Prepare per-user NSS slot mapping. It is safe to call this function multiple |
50 // times. Returns true if the user was added, or false if it already existed. | 48 // times. Returns true if the user was added, or false if it already existed. |
51 CRYPTO_EXPORT bool InitializeNSSForChromeOSUser( | 49 CRYPTO_EXPORT bool InitializeNSSForChromeOSUser( |
52 const std::string& email, | 50 const std::string& email, |
53 const std::string& username_hash, | 51 const std::string& username_hash, |
54 const base::FilePath& path); | 52 const base::FilePath& path); |
55 | 53 |
56 // Returns whether TPM for ChromeOS user still needs initialization. If | 54 // Returns whether TPM for ChromeOS user still needs initialization. If |
57 // true is returned, the caller can proceed to initialize TPM slot for the | 55 // true is returned, the caller can proceed to initialize TPM slot for the |
58 // user, but should call |WillInitializeTPMForChromeOSUser| first. | 56 // user, but should call |WillInitializeTPMForChromeOSUser| first. |
(...skipping 26 matching lines...) Expand all Loading... |
85 // loaded and |callback| is non-null, the |callback| will be run once the slot | 83 // loaded and |callback| is non-null, the |callback| will be run once the slot |
86 // is loaded. | 84 // is loaded. |
87 CRYPTO_EXPORT ScopedPK11Slot GetPrivateSlotForChromeOSUser( | 85 CRYPTO_EXPORT ScopedPK11Slot GetPrivateSlotForChromeOSUser( |
88 const std::string& username_hash, | 86 const std::string& username_hash, |
89 const base::Callback<void(ScopedPK11Slot)>& callback) WARN_UNUSED_RESULT; | 87 const base::Callback<void(ScopedPK11Slot)>& callback) WARN_UNUSED_RESULT; |
90 #endif // defined(OS_CHROMEOS) | 88 #endif // defined(OS_CHROMEOS) |
91 | 89 |
92 } // namespace crypto | 90 } // namespace crypto |
93 | 91 |
94 #endif // CRYPTO_NSS_UTIL_INTERNAL_H_ | 92 #endif // CRYPTO_NSS_UTIL_INTERNAL_H_ |
OLD | NEW |