doubles.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # This file is dual licensed under the terms of the Apache License, Version
  2. # 2.0, and the BSD License. See the LICENSE file in the root of this repository
  3. # for complete details.
  4. from cryptography.hazmat.primitives import hashes, serialization
  5. from cryptography.hazmat.primitives.asymmetric import padding
  6. from cryptography.hazmat.primitives.ciphers import (
  7. BlockCipherAlgorithm,
  8. CipherAlgorithm,
  9. )
  10. from cryptography.hazmat.primitives.ciphers.modes import Mode
  11. class DummyCipherAlgorithm(CipherAlgorithm):
  12. name = "dummy-cipher"
  13. block_size = 128
  14. key_size = 256
  15. key_sizes = frozenset([256])
  16. class DummyBlockCipherAlgorithm(DummyCipherAlgorithm, BlockCipherAlgorithm):
  17. def __init__(self, _: object) -> None:
  18. pass
  19. name = "dummy-block-cipher"
  20. class DummyMode(Mode):
  21. name = "dummy-mode"
  22. def validate_for_algorithm(self, algorithm: CipherAlgorithm) -> None:
  23. pass
  24. class DummyHashAlgorithm(hashes.HashAlgorithm):
  25. name = "dummy-hash"
  26. block_size = None
  27. digest_size = 32
  28. class DummyKeySerializationEncryption(
  29. serialization.KeySerializationEncryption
  30. ):
  31. pass
  32. class DummyAsymmetricPadding(padding.AsymmetricPadding):
  33. name = "dummy-padding"