Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

certificate_transparency.py 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 __future__ import annotations
  5. import abc
  6. import datetime
  7. from cryptography import utils
  8. from cryptography.hazmat.bindings._rust import x509 as rust_x509
  9. from cryptography.hazmat.primitives.hashes import HashAlgorithm
  10. class LogEntryType(utils.Enum):
  11. X509_CERTIFICATE = 0
  12. PRE_CERTIFICATE = 1
  13. class Version(utils.Enum):
  14. v1 = 0
  15. class SignatureAlgorithm(utils.Enum):
  16. """
  17. Signature algorithms that are valid for SCTs.
  18. These are exactly the same as SignatureAlgorithm in RFC 5246 (TLS 1.2).
  19. See: <https://datatracker.ietf.org/doc/html/rfc5246#section-7.4.1.4.1>
  20. """
  21. ANONYMOUS = 0
  22. RSA = 1
  23. DSA = 2
  24. ECDSA = 3
  25. class SignedCertificateTimestamp(metaclass=abc.ABCMeta):
  26. @property
  27. @abc.abstractmethod
  28. def version(self) -> Version:
  29. """
  30. Returns the SCT version.
  31. """
  32. @property
  33. @abc.abstractmethod
  34. def log_id(self) -> bytes:
  35. """
  36. Returns an identifier indicating which log this SCT is for.
  37. """
  38. @property
  39. @abc.abstractmethod
  40. def timestamp(self) -> datetime.datetime:
  41. """
  42. Returns the timestamp for this SCT.
  43. """
  44. @property
  45. @abc.abstractmethod
  46. def entry_type(self) -> LogEntryType:
  47. """
  48. Returns whether this is an SCT for a certificate or pre-certificate.
  49. """
  50. @property
  51. @abc.abstractmethod
  52. def signature_hash_algorithm(self) -> HashAlgorithm:
  53. """
  54. Returns the hash algorithm used for the SCT's signature.
  55. """
  56. @property
  57. @abc.abstractmethod
  58. def signature_algorithm(self) -> SignatureAlgorithm:
  59. """
  60. Returns the signing algorithm used for the SCT's signature.
  61. """
  62. @property
  63. @abc.abstractmethod
  64. def signature(self) -> bytes:
  65. """
  66. Returns the signature for this SCT.
  67. """
  68. @property
  69. @abc.abstractmethod
  70. def extension_bytes(self) -> bytes:
  71. """
  72. Returns the raw bytes of any extensions for this SCT.
  73. """
  74. SignedCertificateTimestamp.register(rust_x509.Sct)