certificate_transparency.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. import abc
  5. import datetime
  6. from cryptography import utils
  7. from cryptography.hazmat.bindings._rust import x509 as rust_x509
  8. class LogEntryType(utils.Enum):
  9. X509_CERTIFICATE = 0
  10. PRE_CERTIFICATE = 1
  11. class Version(utils.Enum):
  12. v1 = 0
  13. class SignedCertificateTimestamp(metaclass=abc.ABCMeta):
  14. @abc.abstractproperty
  15. def version(self) -> Version:
  16. """
  17. Returns the SCT version.
  18. """
  19. @abc.abstractproperty
  20. def log_id(self) -> bytes:
  21. """
  22. Returns an identifier indicating which log this SCT is for.
  23. """
  24. @abc.abstractproperty
  25. def timestamp(self) -> datetime.datetime:
  26. """
  27. Returns the timestamp for this SCT.
  28. """
  29. @abc.abstractproperty
  30. def entry_type(self) -> LogEntryType:
  31. """
  32. Returns whether this is an SCT for a certificate or pre-certificate.
  33. """
  34. SignedCertificateTimestamp.register(rust_x509.Sct)