HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/cryptography/x509/__pycache__/ocsp.cpython-310.pyc
o

�h#N�@sbddlmZddlZddlZddlZddlmZmZddlm	Z	ddl
mZmZddl
mZddlmZmZmZGdd	�d	ej�ZGd
d�dej�ZejejejejejfZd!dd�ZGdd�dej�ZGdd�d�ZGdd�dejd�Z Gdd�dejd�Z!Gdd�dejd�Z"e �#e	j �e"�#e	j"�e!�#e	j!�Gdd�d�Z$Gdd �d �Z%e	j&Z&e	j'Z'dS)"�)�annotationsN)�utils�x509)�ocsp)�hashes�
serialization)� CertificateIssuerPrivateKeyTypes)�_EARLIEST_UTC_TIME�_convert_to_naive_utc_time�_reject_duplicate_extensionc@seZdZdZdZdS)�OCSPResponderEncodingzBy HashzBy NameN)�__name__�
__module__�__qualname__�HASH�NAME�rr�I/usr/local/CyberCP/lib/python3.10/site-packages/cryptography/x509/ocsp.pyrsrc@s$eZdZdZdZdZdZdZdZdS)�OCSPResponseStatusr�����N)	r
rr�
SUCCESSFUL�MALFORMED_REQUEST�INTERNAL_ERROR�	TRY_LATER�SIG_REQUIRED�UNAUTHORIZEDrrrrrsr�	algorithm�hashes.HashAlgorithm�return�NonecCst|t�s	td��dS)Nz9Algorithm must be SHA1, SHA224, SHA256, SHA384, or SHA512)�
isinstance�_ALLOWED_HASHES�
ValueError)r rrr�_verify_algorithm/s

��r'c@seZdZdZdZdZdS)�OCSPCertStatusrrrN)r
rr�GOOD�REVOKED�UNKNOWNrrrrr(6sr(c@seZdZddd�ZdS)�_SingleResponse�cert�x509.Certificate�issuerr r!�cert_statusr(�this_update�datetime.datetime�next_update�datetime.datetime | None�revocation_time�revocation_reason�x509.ReasonFlags | Nonec		Cst|tj�rt|tj�std��t|�t|tj�std��|dur,t|tj�s,td��||_||_||_||_	||_
t|t�sDtd��|tjurZ|durQt
d��|durYt
d��n$t|tj�sdtd��t|�}|tkrpt
d��|dur~t|tj�s~td	��||_||_||_dS)
N�%cert and issuer must be a Certificatez%this_update must be a datetime objectz-next_update must be a datetime object or Nonez8cert_status must be an item from the OCSPCertStatus enumzBrevocation_time can only be provided if the certificate is revokedzDrevocation_reason can only be provided if the certificate is revokedz)revocation_time must be a datetime objectz7The revocation_time must be on or after 1950 January 1.zCrevocation_reason must be an item from the ReasonFlags enum or None)r$r�Certificate�	TypeErrorr'�datetime�_cert�_issuer�
_algorithm�_this_update�_next_updater(r*r&r
r	�ReasonFlags�_cert_status�_revocation_time�_revocation_reason)	�selfr-r/r r0r1r3r5r6rrr�__init__=s\�
�
�
����
��
z_SingleResponse.__init__N)r-r.r/r.r r!r0r(r1r2r3r4r5r4r6r7)r
rrrFrrrrr,<sr,c@s�eZdZeejddd���Zeejddd���Zeejddd	���Zeejddd���Z	ejddd��Z
eejddd���ZdS)�OCSPRequestr"�bytescC�dS�z3
        The hash of the issuer public key
        Nr�rErrr�issuer_key_hash��zOCSPRequest.issuer_key_hashcCrI�z-
        The hash of the issuer name
        NrrKrrr�issuer_name_hash�rMzOCSPRequest.issuer_name_hashr!cCrI�zK
        The hash algorithm used in the issuer name and key hashes
        NrrKrrr�hash_algorithm�rMzOCSPRequest.hash_algorithm�intcCrI�zM
        The serial number of the cert whose status is being checked
        NrrKrrr�
serial_number�rMzOCSPRequest.serial_number�encoding�serialization.EncodingcCrI)z/
        Serializes the request to DER
        Nr�rErUrrr�public_bytes�rMzOCSPRequest.public_bytes�x509.ExtensionscCrI)zP
        The list of request extensions. Not single request extensions.
        NrrKrrr�
extensions�rMzOCSPRequest.extensionsN�r"rH�r"r!�r"rR�rUrVr"rH�r"rY)r
rr�property�abc�abstractmethodrLrOrQrTrXrZrrrrrG�s$rG)�	metaclassc@s�eZdZeejd"dd���Zeejd#dd���Zeejd#dd	���Zeejd$dd���Z	eejd%dd���Z
eejd%dd���Zeejd#dd���Zeejd#dd���Z
eejd&dd���Zeejd&dd���Zeejd'dd���Zeejd(dd ���Zd!S))�OCSPSingleResponser"r(cCrI�zY
        The status of the certificate (an element from the OCSPCertStatus enum)
        NrrKrrr�certificate_status�rMz%OCSPSingleResponse.certificate_statusr4cCrI�z^
        The date of when the certificate was revoked or None if not
        revoked.
        NrrKrrrr5�rMz"OCSPSingleResponse.revocation_timecCrI�z�
        The date of when the certificate was revoked or None if not
        revoked. Represented as a non-naive UTC datetime.
        NrrKrrr�revocation_time_utc�rMz&OCSPSingleResponse.revocation_time_utcr7cCrI�zi
        The reason the certificate was revoked or None if not specified or
        not revoked.
        NrrKrrrr6�rMz$OCSPSingleResponse.revocation_reasonr2cCrI�z�
        The most recent time at which the status being indicated is known by
        the responder to have been correct
        NrrKrrrr1�rMzOCSPSingleResponse.this_updatecCrI�z�
        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.
        NrrKrrr�this_update_utc�rMz"OCSPSingleResponse.this_update_utccCrI�zC
        The time when newer information will be available
        NrrKrrrr3�rMzOCSPSingleResponse.next_updatecCrI�zu
        The time when newer information will be available. Represented as a
        non-naive UTC datetime.
        NrrKrrr�next_update_utc�rMz"OCSPSingleResponse.next_update_utcrHcCrIrJrrKrrrrL�rMz"OCSPSingleResponse.issuer_key_hashcCrIrNrrKrrrrO�rMz#OCSPSingleResponse.issuer_name_hashr!cCrIrPrrKrrrrQ�rMz!OCSPSingleResponse.hash_algorithmrRcCrIrSrrKrrrrTrMz OCSPSingleResponse.serial_numberN�r"r(�r"r4�r"r7�r"r2r[r\r])r
rrr`rarbrfr5rir6r1rmr3rprLrOrQrTrrrrrd�sJrdc@seZdZeejdHdd���ZeejdIdd���ZeejdJd	d
���ZeejdKdd
���Z	eejdLdd���Z
eejdLdd���ZeejdMdd���ZeejdNdd���Z
eejdOdd���ZeejdPdd���ZeejdPdd ���ZeejdQd"d#���ZeejdRd%d&���ZeejdRd'd(���ZeejdSd*d+���ZeejdPd,d-���ZeejdPd.d/���ZeejdRd0d1���ZeejdRd2d3���ZeejdLd4d5���ZeejdLd6d7���ZeejdTd9d:���ZeejdUd<d=���ZeejdVd?d@���ZeejdVdAdB���ZejdWdEdF��ZdGS)X�OCSPResponser"�#typing.Iterator[OCSPSingleResponse]cCrI)z_
        An iterator over the individual SINGLERESP structures in the
        response
        NrrKrrr�	responsesrMzOCSPResponse.responsesrcCrI)zm
        The status of the response. This is a value from the OCSPResponseStatus
        enumeration
        NrrKrrr�response_statusrMzOCSPResponse.response_status�x509.ObjectIdentifiercCrI)zA
        The ObjectIdentifier of the signature algorithm
        NrrKrrr�signature_algorithm_oidrMz$OCSPResponse.signature_algorithm_oid�hashes.HashAlgorithm | NonecCrI)zX
        Returns a HashAlgorithm corresponding to the type of the digest signed
        NrrKrrr�signature_hash_algorithm"rMz%OCSPResponse.signature_hash_algorithmrHcCrI)z%
        The signature bytes
        NrrKrrr�	signature+rMzOCSPResponse.signaturecCrI)z+
        The tbsResponseData bytes
        NrrKrrr�tbs_response_bytes2rMzOCSPResponse.tbs_response_bytes�list[x509.Certificate]cCrI)z�
        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.
        NrrKrrr�certificates9rMzOCSPResponse.certificates�bytes | NonecCrI)z2
        The responder's key hash or None
        NrrKrrr�responder_key_hashBrMzOCSPResponse.responder_key_hash�x509.Name | NonecCrI)z.
        The responder's Name or None
        NrrKrrr�responder_nameIrMzOCSPResponse.responder_namer2cCrI)z4
        The time the response was produced
        NrrKrrr�produced_atPrMzOCSPResponse.produced_atcCrI)zf
        The time the response was produced. Represented as a non-naive UTC
        datetime.
        NrrKrrr�produced_at_utcWrMzOCSPResponse.produced_at_utcr(cCrIrerrKrrrrf_rMzOCSPResponse.certificate_statusr4cCrIrgrrKrrrr5frMzOCSPResponse.revocation_timecCrIrhrrKrrrrinrMz OCSPResponse.revocation_time_utcr7cCrIrjrrKrrrr6vrMzOCSPResponse.revocation_reasoncCrIrkrrKrrrr1~rMzOCSPResponse.this_updatecCrIrlrrKrrrrm�rMzOCSPResponse.this_update_utccCrIrnrrKrrrr3�rMzOCSPResponse.next_updatecCrIrorrKrrrrp�rMzOCSPResponse.next_update_utccCrIrJrrKrrrrL�rMzOCSPResponse.issuer_key_hashcCrIrNrrKrrrrO�rMzOCSPResponse.issuer_name_hashr!cCrIrPrrKrrrrQ�rMzOCSPResponse.hash_algorithmrRcCrIrSrrKrrrrT�rMzOCSPResponse.serial_numberrYcCrI)zR
        The list of response extensions. Not single response extensions.
        NrrKrrrrZ�rMzOCSPResponse.extensionscCrI)zR
        The list of single response extensions. Not response extensions.
        NrrKrrr�single_extensions�rMzOCSPResponse.single_extensionsrUrVcCrI)z0
        Serializes the response to DER
        NrrWrrrrX�rMzOCSPResponse.public_bytesN)r"rv)r"r)r"ry)r"r{r[)r"r)r"r�)r"r�rtrqrrrsr\r]r_r^) r
rrr`rarbrwrxrzr|r}r~r�r�r�r�r�rfr5rir6r1rmr3rprLrOrQrTrZr�rXrrrrru
s�ruc@sFeZdZddgfd#d
d�Zd$dd�Zd%dd�Zd&dd�Zd'd!d"�ZdS)(�OCSPRequestBuilderN�request�Ftuple[x509.Certificate, x509.Certificate, hashes.HashAlgorithm] | None�request_hash�5tuple[bytes, bytes, int, hashes.HashAlgorithm] | NonerZ�(list[x509.Extension[x509.ExtensionType]]r"r#cCs||_||_||_dS�N)�_request�
_request_hash�_extensions)rEr�r�rZrrrrF�s

zOCSPRequestBuilder.__init__r-r.r/r r!cCsZ|jdus
|jdurtd��t|�t|tj�rt|tj�s"td��t|||f|j|j	�S)N�.Only one certificate can be added to a requestr8)
r�r�r&r'r$rr9r:r�r�)rEr-r/r rrr�add_certificate�s��z"OCSPRequestBuilder.add_certificaterOrHrLrTrRcCs�|jdus
|jdurtd��t|t�std��t|�t�d|�t�d|�|j	t
|�ks5|j	t
|�kr9td��t|j||||f|j�S)Nr�z serial_number must be an integerrOrLz`issuer_name_hash and issuer_key_hash must be the same length as the digest size of the algorithm)
r�r�r&r$rRr:r'r�_check_bytes�digest_size�lenr�r�)rErOrLrTr rrr�add_certificate_by_hash�s&
��
�z*OCSPRequestBuilder.add_certificate_by_hash�extval�x509.ExtensionType�critical�boolcCsJt|tj�s
td��t�|j||�}t||j�t|j	|j
g|j�|��S�Nz"extension must be an ExtensionType)r$r�
ExtensionTyper:�	Extension�oidrr�r�r�r��rEr�r��	extensionrrr�
add_extensions�z OCSPRequestBuilder.add_extensionrGcCs&|jdur|jdurtd��t�|�S)Nz*You must add a certificate before building)r�r�r&r�create_ocsp_requestrKrrr�build!s
zOCSPRequestBuilder.build)r�r�r�r�rZr�r"r#)r-r.r/r.r r!r"r�)
rOrHrLrHrTrRr r!r"r�)r�r�r�r�r"r�)r"rG)r
rrrFr�r�r�r�rrrrr��s�



r�c@s`eZdZdddgfd5d
d�Zd6dd�Zd7d d!�Zd8d#d$�Zd9d)d*�Zd:d/d0�Ze	d;d3d4��Z
dS)<�OCSPResponseBuilderN�response�_SingleResponse | None�responder_id�5tuple[x509.Certificate, OCSPResponderEncoding] | None�certs�list[x509.Certificate] | NonerZr�cCs||_||_||_||_dSr�)�	_response�
_responder_id�_certsr�)rEr�r�r�rZrrrrF)s
zOCSPResponseBuilder.__init__r-r.r/r r!r0r(r1r2r3r4r5r6r7r"c	
	Cs<|jdur	td��t||||||||�}	t|	|j|j|j�S)Nz#Only one response per OCSPResponse.)r�r&r,r�r�r�r�)
rEr-r/r r0r1r3r5r6�
singleresprrr�add_response6s$
�
�z OCSPResponseBuilder.add_responserUr�responder_certcCsP|jdur	td��t|tj�std��t|t�std��t|j||f|j	|j
�S)Nz!responder_id can only be set oncez$responder_cert must be a Certificatez6encoding must be an element from OCSPResponderEncoding)r�r&r$rr9r:rr�r�r�r�)rErUr�rrrr�Us

��z OCSPResponseBuilder.responder_id�!typing.Iterable[x509.Certificate]cCs\|jdur	td��t|�}t|�dkrtd��tdd�|D��s$td��t|j|j||j	�S)Nz!certificates may only be set oncerzcerts must not be an empty listcss�|]	}t|tj�VqdSr�)r$rr9)�.0�xrrr�	<genexpr>ps�z3OCSPResponseBuilder.certificates.<locals>.<genexpr>z$certs must be a list of Certificates)
r�r&�listr��allr:r�r�r�r�)rEr�rrrr�hs
�z OCSPResponseBuilder.certificatesr�r�r�r�cCsNt|tj�s
td��t�|j||�}t||j�t|j	|j
|jg|j�|��Sr�)r$rr�r:r�r�rr�r�r�r�r�r�rrrr�ys�z!OCSPResponseBuilder.add_extension�private_keyrr{rucCs6|jdur	td��|jdurtd��t�tj|||�S)Nz&You must add a response before signingz*You must add a responder_id before signing)r�r&r�r�create_ocsp_responserr)rEr�r rrr�sign�s


�zOCSPResponseBuilder.signrxrcCs4t|t�s	td��|tjurtd��t�|ddd�S)Nz7response_status must be an item from OCSPResponseStatusz$response_status cannot be SUCCESSFUL)r$rr:rr&rr�)�clsrxrrr�build_unsuccessful�s
�
z&OCSPResponseBuilder.build_unsuccessful)r�r�r�r�r�r�rZr�)r-r.r/r.r r!r0r(r1r2r3r4r5r4r6r7r"r�)rUrr�r.r"r�)r�r�r"r�)r�r�r�r�r"r�)r�rr r{r"ru)rxrr"ru)r
rrrFr�r�r�r�r��classmethodr�rrrrr�(s�




r�)r r!r"r#)(�
__future__rrar;�typing�cryptographyrr�"cryptography.hazmat.bindings._rustr�cryptography.hazmat.primitivesrr�/cryptography.hazmat.primitives.asymmetric.typesr�cryptography.x509.baser	r
r�Enumrr�SHA1�SHA224�SHA256�SHA384�SHA512r%r'r(r,�ABCMetarGrdru�registerr�r��load_der_ocsp_request�load_der_ocsp_responserrrr�<module>s>
�
	F+]FT}