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