blob: 99a269cddabadac4e672f8e00ad01f1e878db25d [file] [log] [blame]
[email protected]190933f2014-07-28 09:56:511// Copyright 2014 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 CRYPTO_SCOPED_TEST_SYSTEM_NSS_KEY_SLOT_H_
6#define CRYPTO_SCOPED_TEST_SYSTEM_NSS_KEY_SLOT_H_
7
8#include "base/macros.h"
9#include "base/memory/scoped_ptr.h"
10#include "crypto/crypto_export.h"
11
[email protected]442233d42014-08-02 07:37:2412// Forward declaration, from <pk11pub.h>
13typedef struct PK11SlotInfoStr PK11SlotInfo;
14
[email protected]190933f2014-07-28 09:56:5115namespace crypto {
16
17class ScopedTestNSSDB;
18
19// Opens a persistent NSS software database in a temporary directory and sets
20// the test system slot to the opened database. This helper should be created in
[email protected]442233d42014-08-02 07:37:2421// tests to fake the system token that is usually provided by the Chaps module.
22// |slot| is exposed through |GetSystemNSSKeySlot| and |IsTPMTokenReady| will
23// return true.
24// |InitializeTPMTokenAndSystemSlot|, which triggers the TPM initialization,
25// does not have to be called if this helper is used.
[email protected]190933f2014-07-28 09:56:5126// At most one instance of this helper must be used at a time.
xhwang3e9ca562015-11-06 18:50:3627class CRYPTO_EXPORT ScopedTestSystemNSSKeySlot {
[email protected]190933f2014-07-28 09:56:5128 public:
29 explicit ScopedTestSystemNSSKeySlot();
30 ~ScopedTestSystemNSSKeySlot();
31
32 bool ConstructedSuccessfully() const;
[email protected]442233d42014-08-02 07:37:2433 PK11SlotInfo* slot() const;
[email protected]190933f2014-07-28 09:56:5134
35 private:
36 scoped_ptr<ScopedTestNSSDB> test_db_;
37
38 DISALLOW_COPY_AND_ASSIGN(ScopedTestSystemNSSKeySlot);
39};
40
41} // namespace crypto
42
43#endif // CRYPTO_SCOPED_TEST_SYSTEM_NSS_KEY_SLOT_H_