blob: 4bc52bb8c2c4f1b707c27742b006614ea8d76668 [file] [log] [blame]
pneubeck@chromium.org190933f2014-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#include "crypto/scoped_test_system_nss_key_slot.h"
6
Michael Ershov6b5e4182021-09-28 13:46:327#include "crypto/nss_util.h"
pneubeck@chromium.org190933f2014-07-28 09:56:518#include "crypto/nss_util_internal.h"
9#include "crypto/scoped_test_nss_db.h"
10
11namespace crypto {
12
Michael Ershov6b5e4182021-09-28 13:46:3213ScopedTestSystemNSSKeySlot::ScopedTestSystemNSSKeySlot(
14 bool simulate_token_loader)
pneubeck@chromium.org190933f2014-07-28 09:56:5115 : test_db_(new ScopedTestNSSDB) {
16 if (!test_db_->is_open())
17 return;
Michael Ershov6b5e4182021-09-28 13:46:3218
19 PrepareSystemSlotForTesting( // IN-TEST
pneubeck@chromium.org190933f2014-07-28 09:56:5120 ScopedPK11Slot(PK11_ReferenceSlot(test_db_->slot())));
Michael Ershov6b5e4182021-09-28 13:46:3221
22 if (simulate_token_loader)
23 FinishInitializingTPMTokenAndSystemSlot();
pneubeck@chromium.org190933f2014-07-28 09:56:5124}
25
26ScopedTestSystemNSSKeySlot::~ScopedTestSystemNSSKeySlot() {
Michael Ershov6b5e4182021-09-28 13:46:3227 ResetSystemSlotForTesting(); // IN-TEST
pneubeck@chromium.org190933f2014-07-28 09:56:5128}
29
30bool ScopedTestSystemNSSKeySlot::ConstructedSuccessfully() const {
31 return test_db_->is_open();
32}
33
pneubeck@chromium.org442233d42014-08-02 07:37:2434PK11SlotInfo* ScopedTestSystemNSSKeySlot::slot() const {
35 return test_db_->slot();
36}
37
pneubeck@chromium.org190933f2014-07-28 09:56:5138} // namespace crypto