OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SCOPED_TEST_SYSTEM_NSS_KEY_SLOT_H_ | 5 #ifndef CRYPTO_SCOPED_TEST_SYSTEM_NSS_KEY_SLOT_H_ |
6 #define CRYPTO_SCOPED_TEST_SYSTEM_NSS_KEY_SLOT_H_ | 6 #define CRYPTO_SCOPED_TEST_SYSTEM_NSS_KEY_SLOT_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "crypto/crypto_export.h" | 11 #include "crypto/crypto_export.h" |
12 | 12 |
13 // Forward declaration, from <pk11pub.h> | 13 // Forward declaration, from <pk11pub.h> |
14 typedef struct PK11SlotInfoStr PK11SlotInfo; | 14 typedef struct PK11SlotInfoStr PK11SlotInfo; |
15 | 15 |
16 namespace crypto { | 16 namespace crypto { |
17 | 17 |
18 class ScopedTestNSSDB; | 18 class ScopedTestNSSDB; |
19 | 19 |
20 // Opens a persistent NSS software database in a temporary directory and sets | 20 // Opens a persistent NSS software database in a temporary directory and sets |
21 // the test system slot to the opened database. This helper should be created in | 21 // the test system slot to the opened database. This helper should be created in |
22 // tests to fake the system token that is usually provided by the Chaps module. | 22 // tests to fake the system token that is usually provided by the Chaps module. |
23 // |slot| is exposed through |GetSystemNSSKeySlot| and |IsTPMTokenReady| will | 23 // |slot| is exposed through |GetSystemNSSKeySlot| and |IsTPMTokenReady| will |
24 // return true. | 24 // return true. |
25 // |InitializeTPMTokenAndSystemSlot|, which triggers the TPM initialization, | 25 // |InitializeTPMTokenAndSystemSlot|, which triggers the TPM initialization, |
26 // does not have to be called if this helper is used. | 26 // does not have to be called if this helper is used. |
27 // At most one instance of this helper must be used at a time. | 27 // At most one instance of this helper must be used at a time. |
28 class CRYPTO_EXPORT ScopedTestSystemNSSKeySlot { | 28 class CRYPTO_EXPORT ScopedTestSystemNSSKeySlot { |
29 public: | 29 public: |
30 explicit ScopedTestSystemNSSKeySlot(); | 30 ScopedTestSystemNSSKeySlot(); |
31 ~ScopedTestSystemNSSKeySlot(); | 31 ~ScopedTestSystemNSSKeySlot(); |
32 | 32 |
33 bool ConstructedSuccessfully() const; | 33 bool ConstructedSuccessfully() const; |
34 PK11SlotInfo* slot() const; | 34 PK11SlotInfo* slot() const; |
35 | 35 |
36 private: | 36 private: |
37 std::unique_ptr<ScopedTestNSSDB> test_db_; | 37 std::unique_ptr<ScopedTestNSSDB> test_db_; |
38 | 38 |
39 DISALLOW_COPY_AND_ASSIGN(ScopedTestSystemNSSKeySlot); | 39 DISALLOW_COPY_AND_ASSIGN(ScopedTestSystemNSSKeySlot); |
40 }; | 40 }; |
41 | 41 |
42 } // namespace crypto | 42 } // namespace crypto |
43 | 43 |
44 #endif // CRYPTO_SCOPED_TEST_SYSTEM_NSS_KEY_SLOT_H_ | 44 #endif // CRYPTO_SCOPED_TEST_SYSTEM_NSS_KEY_SLOT_H_ |
OLD | NEW |