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

Side by Side Diff: crypto/nss_util_internal.h

Issue 53763003: Initialize per-ChromeOS-user NSS slots and provide the functions to access them. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix CertificateManagerBrowserTest Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « crypto/nss_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/compiler_specific.h"
10 #include "crypto/crypto_export.h" 12 #include "crypto/crypto_export.h"
13 #include "crypto/scoped_nss_types.h"
14
15 namespace base {
16 class FilePath;
17 }
11 18
12 // 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
13 // declared in nss_util.h. Hence, they are declared here. 20 // declared in nss_util.h. Hence, they are declared here.
14 21
15 namespace crypto { 22 namespace crypto {
16 23
17 // Returns a reference to the default NSS key slot for storing 24 // Returns a reference to the default NSS key slot for storing
18 // public-key data only (e.g. server certs). Caller must release 25 // public-key data only (e.g. server certs). Caller must release
19 // returned reference with PK11_FreeSlot. 26 // returned reference with PK11_FreeSlot.
20 CRYPTO_EXPORT PK11SlotInfo* GetPublicNSSKeySlot(); 27 CRYPTO_EXPORT PK11SlotInfo* GetPublicNSSKeySlot() WARN_UNUSED_RESULT;
21 28
22 // Returns a reference to the default slot for storing private-key and 29 // Returns a reference to the default slot for storing private-key and
23 // mixed private-key/public-key data. Returns a hardware (TPM) NSS 30 // mixed private-key/public-key data. Returns a hardware (TPM) NSS
24 // key slot if on ChromeOS and EnableTPMForNSS() has been called 31 // key slot if on ChromeOS and EnableTPMForNSS() has been called
25 // successfully. Caller must release returned reference with 32 // successfully. Caller must release returned reference with
26 // PK11_FreeSlot. 33 // PK11_FreeSlot.
27 CRYPTO_EXPORT PK11SlotInfo* GetPrivateNSSKeySlot(); 34 CRYPTO_EXPORT PK11SlotInfo* GetPrivateNSSKeySlot() WARN_UNUSED_RESULT;
28 35
29 // A helper class that acquires the SECMOD list read lock while the 36 // A helper class that acquires the SECMOD list read lock while the
30 // AutoSECMODListReadLock is in scope. 37 // AutoSECMODListReadLock is in scope.
31 class AutoSECMODListReadLock { 38 class AutoSECMODListReadLock {
32 public: 39 public:
33 AutoSECMODListReadLock(); 40 AutoSECMODListReadLock();
34 ~AutoSECMODListReadLock(); 41 ~AutoSECMODListReadLock();
35 42
36 private: 43 private:
37 SECMODListLock* lock_; 44 SECMODListLock* lock_;
38 DISALLOW_COPY_AND_ASSIGN(AutoSECMODListReadLock); 45 DISALLOW_COPY_AND_ASSIGN(AutoSECMODListReadLock);
39 }; 46 };
40 47
48 #if defined(OS_CHROMEOS)
49 // 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.
51 CRYPTO_EXPORT bool InitializeNSSForChromeOSUser(
52 const std::string& email,
53 const std::string& username_hash,
54 bool is_primary_user,
55 const base::FilePath& path) WARN_UNUSED_RESULT;
56
57 // Use TPM slot |slot_id| for user. InitializeNSSForChromeOSUser must have been
58 // called first.
59 CRYPTO_EXPORT void InitializeTPMForChromeOSUser(
60 const std::string& username_hash,
61 CK_SLOT_ID slot_id);
62
63 // Use the software slot as the private slot for user.
64 // InitializeNSSForChromeOSUser must have been called first.
65 CRYPTO_EXPORT void InitializePrivateSoftwareSlotForChromeOSUser(
66 const std::string& username_hash);
67
68 // Returns a reference to the public slot for user.
69 CRYPTO_EXPORT ScopedPK11Slot GetPublicSlotForChromeOSUser(
70 const std::string& username_hash) WARN_UNUSED_RESULT;
71
72 // Returns the private slot for |username_hash| if it is loaded. If it is not
73 // loaded and |callback| is non-null, the |callback| will be run once the slot
74 // is loaded.
75 CRYPTO_EXPORT ScopedPK11Slot GetPrivateSlotForChromeOSUser(
76 const std::string& username_hash,
77 const base::Callback<void(ScopedPK11Slot)>& callback) WARN_UNUSED_RESULT;
78 #endif // defined(OS_CHROMEOS)
79
41 } // namespace crypto 80 } // namespace crypto
42 81
43 #endif // CRYPTO_NSS_UTIL_INTERNAL_H_ 82 #endif // CRYPTO_NSS_UTIL_INTERNAL_H_
OLDNEW
« no previous file with comments | « crypto/nss_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698