Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove OCSPResponse abc #11992

Merged
merged 2 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 58 additions & 1 deletion src/cryptography/hazmat/bindings/_rust/ocsp.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.

import datetime
import typing

from cryptography import x509
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric.types import PrivateKeyTypes
Expand All @@ -20,7 +23,61 @@ class OCSPRequest:
@property
def extensions(self) -> x509.Extensions: ...

class OCSPResponse: ...
class OCSPResponse:
@property
def responses(self) -> typing.Iterator[OCSPSingleResponse]: ...
@property
def response_status(self) -> ocsp.OCSPResponseStatus: ...
@property
def signature_algorithm_oid(self) -> x509.ObjectIdentifier: ...
@property
def signature_hash_algorithm(
self,
) -> hashes.HashAlgorithm | None: ...
@property
def signature(self) -> bytes: ...
@property
def tbs_response_bytes(self) -> bytes: ...
@property
def certificates(self) -> list[x509.Certificate]: ...
@property
def responder_key_hash(self) -> bytes | None: ...
@property
def responder_name(self) -> x509.Name | None: ...
@property
def produced_at(self) -> datetime.datetime: ...
@property
def produced_at_utc(self) -> datetime.datetime: ...
@property
def certificate_status(self) -> ocsp.OCSPCertStatus: ...
@property
def revocation_time(self) -> datetime.datetime | None: ...
@property
def revocation_time_utc(self) -> datetime.datetime | None: ...
@property
def revocation_reason(self) -> x509.ReasonFlags | None: ...
@property
def this_update(self) -> datetime.datetime: ...
@property
def this_update_utc(self) -> datetime.datetime: ...
@property
def next_update(self) -> datetime.datetime | None: ...
@property
def next_update_utc(self) -> datetime.datetime | None: ...
@property
def issuer_key_hash(self) -> bytes: ...
@property
def issuer_name_hash(self) -> bytes: ...
@property
def hash_algorithm(self) -> hashes.HashAlgorithm: ...
@property
def serial_number(self) -> int: ...
@property
def extensions(self) -> x509.Extensions: ...
@property
def single_extensions(self) -> x509.Extensions: ...
def public_bytes(self, encoding: serialization.Encoding) -> bytes: ...

class OCSPSingleResponse: ...

def load_der_ocsp_request(data: bytes) -> ocsp.OCSPRequest: ...
Expand Down
201 changes: 2 additions & 199 deletions src/cryptography/x509/ocsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from cryptography import utils, x509
from cryptography.hazmat.bindings._rust import ocsp
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric.types import (
CertificateIssuerPrivateKeyTypes,
)
Expand Down Expand Up @@ -220,205 +220,8 @@ def serial_number(self) -> int:
"""


class OCSPResponse(metaclass=abc.ABCMeta):
@property
@abc.abstractmethod
def responses(self) -> typing.Iterator[OCSPSingleResponse]:
"""
An iterator over the individual SINGLERESP structures in the
response
"""

@property
@abc.abstractmethod
def response_status(self) -> OCSPResponseStatus:
"""
The status of the response. This is a value from the OCSPResponseStatus
enumeration
"""

@property
@abc.abstractmethod
def signature_algorithm_oid(self) -> x509.ObjectIdentifier:
"""
The ObjectIdentifier of the signature algorithm
"""

@property
@abc.abstractmethod
def signature_hash_algorithm(
self,
) -> hashes.HashAlgorithm | None:
"""
Returns a HashAlgorithm corresponding to the type of the digest signed
"""

@property
@abc.abstractmethod
def signature(self) -> bytes:
"""
The signature bytes
"""

@property
@abc.abstractmethod
def tbs_response_bytes(self) -> bytes:
"""
The tbsResponseData bytes
"""

@property
@abc.abstractmethod
def certificates(self) -> list[x509.Certificate]:
"""
A list of certificates used to help build a chain to verify the OCSP
response. This situation occurs when the OCSP responder uses a delegate
certificate.
"""

@property
@abc.abstractmethod
def responder_key_hash(self) -> bytes | None:
"""
The responder's key hash or None
"""

@property
@abc.abstractmethod
def responder_name(self) -> x509.Name | None:
"""
The responder's Name or None
"""

@property
@abc.abstractmethod
def produced_at(self) -> datetime.datetime:
"""
The time the response was produced
"""

@property
@abc.abstractmethod
def produced_at_utc(self) -> datetime.datetime:
"""
The time the response was produced. Represented as a non-naive UTC
datetime.
"""

@property
@abc.abstractmethod
def certificate_status(self) -> OCSPCertStatus:
"""
The status of the certificate (an element from the OCSPCertStatus enum)
"""

@property
@abc.abstractmethod
def revocation_time(self) -> datetime.datetime | None:
"""
The date of when the certificate was revoked or None if not
revoked.
"""

@property
@abc.abstractmethod
def revocation_time_utc(self) -> datetime.datetime | None:
"""
The date of when the certificate was revoked or None if not
revoked. Represented as a non-naive UTC datetime.
"""

@property
@abc.abstractmethod
def revocation_reason(self) -> x509.ReasonFlags | None:
"""
The reason the certificate was revoked or None if not specified or
not revoked.
"""

@property
@abc.abstractmethod
def this_update(self) -> datetime.datetime:
"""
The most recent time at which the status being indicated is known by
the responder to have been correct
"""

@property
@abc.abstractmethod
def this_update_utc(self) -> datetime.datetime:
"""
The most recent time at which the status being indicated is known by
the responder to have been correct. Represented as a non-naive UTC
datetime.
"""

@property
@abc.abstractmethod
def next_update(self) -> datetime.datetime | None:
"""
The time when newer information will be available
"""

@property
@abc.abstractmethod
def next_update_utc(self) -> datetime.datetime | None:
"""
The time when newer information will be available. Represented as a
non-naive UTC datetime.
"""

@property
@abc.abstractmethod
def issuer_key_hash(self) -> bytes:
"""
The hash of the issuer public key
"""

@property
@abc.abstractmethod
def issuer_name_hash(self) -> bytes:
"""
The hash of the issuer name
"""

@property
@abc.abstractmethod
def hash_algorithm(self) -> hashes.HashAlgorithm:
"""
The hash algorithm used in the issuer name and key hashes
"""

@property
@abc.abstractmethod
def serial_number(self) -> int:
"""
The serial number of the cert whose status is being checked
"""

@property
@abc.abstractmethod
def extensions(self) -> x509.Extensions:
"""
The list of response extensions. Not single response extensions.
"""

@property
@abc.abstractmethod
def single_extensions(self) -> x509.Extensions:
"""
The list of single response extensions. Not response extensions.
"""

@abc.abstractmethod
def public_bytes(self, encoding: serialization.Encoding) -> bytes:
"""
Serializes the response to DER
"""


OCSPRequest = ocsp.OCSPRequest
OCSPResponse.register(ocsp.OCSPResponse)
OCSPResponse = ocsp.OCSPResponse
OCSPSingleResponse.register(ocsp.OCSPSingleResponse)


Expand Down