os_crypt_mocker.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2016 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. #ifndef COMPONENTS_OS_CRYPT_OS_CRYPT_MOCKER_H_
  5. #define COMPONENTS_OS_CRYPT_OS_CRYPT_MOCKER_H_
  6. #include "build/build_config.h"
  7. // Handles the mocking of OSCrypt, such that it does not reach system level
  8. // services.
  9. class OSCryptMocker {
  10. public:
  11. OSCryptMocker(const OSCryptMocker&) = delete;
  12. OSCryptMocker& operator=(const OSCryptMocker&) = delete;
  13. // Inject mocking into OSCrypt.
  14. static void SetUp();
  15. #if BUILDFLAG(IS_APPLE)
  16. // Pretend that backend for storing keys is unavailable.
  17. static void SetBackendLocked(bool locked);
  18. #endif
  19. #if BUILDFLAG(IS_WIN)
  20. // Store data using the older DPAPI interface rather than session key.
  21. static void SetLegacyEncryption(bool legacy);
  22. // Reset OSCrypt so it can be initialized again with a new profile/key.
  23. static void ResetState();
  24. #endif
  25. // Restore OSCrypt to its real behaviour.
  26. static void TearDown();
  27. };
  28. #endif // COMPONENTS_OS_CRYPT_OS_CRYPT_MOCKER_H_