Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/cryptography/x509/certificate_transparency.py: 100%
41 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 06:36 +0000
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 06:36 +0000
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.
6import abc
7import datetime
9from cryptography import utils
10from cryptography.hazmat.bindings._rust import x509 as rust_x509
11from cryptography.hazmat.primitives.hashes import HashAlgorithm
14class LogEntryType(utils.Enum):
15 X509_CERTIFICATE = 0
16 PRE_CERTIFICATE = 1
19class Version(utils.Enum):
20 v1 = 0
23class SignatureAlgorithm(utils.Enum):
24 """
25 Signature algorithms that are valid for SCTs.
27 These are exactly the same as SignatureAlgorithm in RFC 5246 (TLS 1.2).
29 See: <https://datatracker.ietf.org/doc/html/rfc5246#section-7.4.1.4.1>
30 """
32 ANONYMOUS = 0
33 RSA = 1
34 DSA = 2
35 ECDSA = 3
38class SignedCertificateTimestamp(metaclass=abc.ABCMeta):
39 @property
40 @abc.abstractmethod
41 def version(self) -> Version:
42 """
43 Returns the SCT version.
44 """
46 @property
47 @abc.abstractmethod
48 def log_id(self) -> bytes:
49 """
50 Returns an identifier indicating which log this SCT is for.
51 """
53 @property
54 @abc.abstractmethod
55 def timestamp(self) -> datetime.datetime:
56 """
57 Returns the timestamp for this SCT.
58 """
60 @property
61 @abc.abstractmethod
62 def entry_type(self) -> LogEntryType:
63 """
64 Returns whether this is an SCT for a certificate or pre-certificate.
65 """
67 @property
68 @abc.abstractmethod
69 def signature_hash_algorithm(self) -> HashAlgorithm:
70 """
71 Returns the hash algorithm used for the SCT's signature.
72 """
74 @property
75 @abc.abstractmethod
76 def signature_algorithm(self) -> SignatureAlgorithm:
77 """
78 Returns the signing algorithm used for the SCT's signature.
79 """
81 @property
82 @abc.abstractmethod
83 def signature(self) -> bytes:
84 """
85 Returns the signature for this SCT.
86 """
88 @property
89 @abc.abstractmethod
90 def extension_bytes(self) -> bytes:
91 """
92 Returns the raw bytes of any extensions for this SCT.
93 """
96SignedCertificateTimestamp.register(rust_x509.Sct)