Skip to content

Commit

Permalink
remove sct abc (pyca#11995)
Browse files Browse the repository at this point in the history
* remove sct abc

* don't alias
  • Loading branch information
reaperhulk authored Nov 17, 2024
1 parent 3fdf1f8 commit 4c72f36
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 64 deletions.
21 changes: 20 additions & 1 deletion src/cryptography/hazmat/bindings/_rust/x509.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ from cryptography.hazmat.primitives.asymmetric.types import (
CertificatePublicKeyTypes,
PrivateKeyTypes,
)
from cryptography.x509 import certificate_transparency

def load_pem_x509_certificate(
data: bytes, backend: typing.Any = None
Expand Down Expand Up @@ -57,7 +58,25 @@ def create_x509_crl(
rsa_padding: PKCS1v15 | PSS | None,
) -> x509.CertificateRevocationList: ...

class Sct: ...
class Sct:
@property
def version(self) -> certificate_transparency.Version: ...
@property
def log_id(self) -> bytes: ...
@property
def timestamp(self) -> datetime.datetime: ...
@property
def entry_type(self) -> certificate_transparency.LogEntryType: ...
@property
def signature_hash_algorithm(self) -> hashes.HashAlgorithm: ...
@property
def signature_algorithm(
self,
) -> certificate_transparency.SignatureAlgorithm: ...
@property
def signature(self) -> bytes: ...
@property
def extension_bytes(self) -> bytes: ...

class Certificate:
def fingerprint(self, algorithm: hashes.HashAlgorithm) -> bytes: ...
Expand Down
64 changes: 1 addition & 63 deletions src/cryptography/x509/certificate_transparency.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@

from __future__ import annotations

import abc
import datetime

from cryptography import utils
from cryptography.hazmat.bindings._rust import x509 as rust_x509
from cryptography.hazmat.primitives.hashes import HashAlgorithm


class LogEntryType(utils.Enum):
Expand All @@ -36,62 +32,4 @@ class SignatureAlgorithm(utils.Enum):
ECDSA = 3


class SignedCertificateTimestamp(metaclass=abc.ABCMeta):
@property
@abc.abstractmethod
def version(self) -> Version:
"""
Returns the SCT version.
"""

@property
@abc.abstractmethod
def log_id(self) -> bytes:
"""
Returns an identifier indicating which log this SCT is for.
"""

@property
@abc.abstractmethod
def timestamp(self) -> datetime.datetime:
"""
Returns the timestamp for this SCT.
"""

@property
@abc.abstractmethod
def entry_type(self) -> LogEntryType:
"""
Returns whether this is an SCT for a certificate or pre-certificate.
"""

@property
@abc.abstractmethod
def signature_hash_algorithm(self) -> HashAlgorithm:
"""
Returns the hash algorithm used for the SCT's signature.
"""

@property
@abc.abstractmethod
def signature_algorithm(self) -> SignatureAlgorithm:
"""
Returns the signing algorithm used for the SCT's signature.
"""

@property
@abc.abstractmethod
def signature(self) -> bytes:
"""
Returns the signature for this SCT.
"""

@property
@abc.abstractmethod
def extension_bytes(self) -> bytes:
"""
Returns the raw bytes of any extensions for this SCT.
"""


SignedCertificateTimestamp.register(rust_x509.Sct)
SignedCertificateTimestamp = rust_x509.Sct

0 comments on commit 4c72f36

Please sign in to comment.