scoped_test_system_nss_key_slot.cc 1013 B

1234567891011121314151617181920212223242526272829303132333435363738
  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
  3. // found in the LICENSE file.
  4. #include "crypto/scoped_test_system_nss_key_slot.h"
  5. #include "crypto/nss_util.h"
  6. #include "crypto/nss_util_internal.h"
  7. #include "crypto/scoped_test_nss_db.h"
  8. namespace crypto {
  9. ScopedTestSystemNSSKeySlot::ScopedTestSystemNSSKeySlot(
  10. bool simulate_token_loader)
  11. : test_db_(new ScopedTestNSSDB) {
  12. if (!test_db_->is_open())
  13. return;
  14. PrepareSystemSlotForTesting( // IN-TEST
  15. ScopedPK11Slot(PK11_ReferenceSlot(test_db_->slot())));
  16. if (simulate_token_loader)
  17. FinishInitializingTPMTokenAndSystemSlot();
  18. }
  19. ScopedTestSystemNSSKeySlot::~ScopedTestSystemNSSKeySlot() {
  20. ResetSystemSlotForTesting(); // IN-TEST
  21. }
  22. bool ScopedTestSystemNSSKeySlot::ConstructedSuccessfully() const {
  23. return test_db_->is_open();
  24. }
  25. PK11SlotInfo* ScopedTestSystemNSSKeySlot::slot() const {
  26. return test_db_->slot();
  27. }
  28. } // namespace crypto