summaryrefslogtreecommitdiffstats
path: root/crypto/scoped_test_system_nss_key_slot.cc
blob: 53fbbffc1a99fb8b5b111c7ad399909c8969367d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "crypto/scoped_test_system_nss_key_slot.h"

#include "crypto/nss_util_internal.h"
#include "crypto/scoped_test_nss_db.h"

namespace crypto {

ScopedTestSystemNSSKeySlot::ScopedTestSystemNSSKeySlot()
    : test_db_(new ScopedTestNSSDB) {
  if (!test_db_->is_open())
    return;
  SetSystemKeySlotForTesting(
      ScopedPK11Slot(PK11_ReferenceSlot(test_db_->slot())));
}

ScopedTestSystemNSSKeySlot::~ScopedTestSystemNSSKeySlot() {
  SetSystemKeySlotForTesting(ScopedPK11Slot());
}

bool ScopedTestSystemNSSKeySlot::ConstructedSuccessfully() const {
  return test_db_->is_open();
}

PK11SlotInfo* ScopedTestSystemNSSKeySlot::slot() const {
  return test_db_->slot();
}

}  // namespace crypto