1 // Copyright 2014 The Chromium Authors 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 7 #include "crypto/nss_util.h" 8 #include "crypto/nss_util_internal.h" 9 #include "crypto/scoped_test_nss_db.h" 10 11 namespace crypto { 12 ScopedTestSystemNSSKeySlot(bool simulate_token_loader)13ScopedTestSystemNSSKeySlot::ScopedTestSystemNSSKeySlot( 14 bool simulate_token_loader) 15 : test_db_(new ScopedTestNSSDB) { 16 if (!test_db_->is_open()) 17 return; 18 19 PrepareSystemSlotForTesting( // IN-TEST 20 ScopedPK11Slot(PK11_ReferenceSlot(test_db_->slot()))); 21 22 if (simulate_token_loader) 23 FinishInitializingTPMTokenAndSystemSlot(); 24 } 25 ~ScopedTestSystemNSSKeySlot()26ScopedTestSystemNSSKeySlot::~ScopedTestSystemNSSKeySlot() { 27 ResetSystemSlotForTesting(); // IN-TEST 28 } 29 ConstructedSuccessfully() const30bool ScopedTestSystemNSSKeySlot::ConstructedSuccessfully() const { 31 return test_db_->is_open(); 32 } 33 slot() const34PK11SlotInfo* ScopedTestSystemNSSKeySlot::slot() const { 35 return test_db_->slot(); 36 } 37 38 } // namespace crypto 39