Current File : //usr/lib64/python3.9/site-packages/cryptography/x509/__pycache__/ocsp.cpython-39.opt-1.pyc
a

�a�8�@s6ddlZddlZddlZddlmZddlmZddlmZddlm	Z	m
Z
ddlmZm
Z
mZmZGdd�dej�ZGd	d
�d
ej�Ze	je	je	je	je	jfZdd�ZGd
d�dej�ZGdd�de�ZGdd�dejd�ZGdd�dejd�ZGdd�de�Z Gdd�de�Z!e"ed�dd�Z#e"ed�dd�Z$dS)�N)�utils)�x509)�ocsp)�hashes�
serialization)�PRIVATE_KEY_TYPES�_EARLIEST_UTC_TIME�_convert_to_naive_utc_time�_reject_duplicate_extensionc@seZdZdZdZdS)�OCSPResponderEncodingzBy HashzBy NameN)�__name__�
__module__�__qualname__�HASH�NAME�rr�</usr/lib64/python3.9/site-packages/cryptography/x509/ocsp.pyrsrc@s$eZdZdZdZdZdZdZdZdS)�OCSPResponseStatusr�����N)	rr
r�
SUCCESSFULZMALFORMED_REQUESTZINTERNAL_ERRORZ	TRY_LATERZSIG_REQUIREDZUNAUTHORIZEDrrrrrsrcCst|t�std��dS)Nz9Algorithm must be SHA1, SHA224, SHA256, SHA384, or SHA512)�
isinstance�_ALLOWED_HASHES�
ValueError)�	algorithmrrr�_verify_algorithm-s
�rc@seZdZdZdZdZdS)�OCSPCertStatusrrrN)rr
rZGOOD�REVOKEDZUNKNOWNrrrrr4src@seZdZdd�ZdS)�_SingleResponsec		Cst|tj�rt|tj�s td��t|�t|tj�s<td��|durXt|tj�sXtd��||_||_||_||_	||_
t|t�s�td��|tjur�|dur�t
d��|dur�t
d��nHt|tj�s�td��t|�}|tkr�t
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)rr�Certificate�	TypeErrorr�datetimeZ_certZ_issuerZ
_algorithmZ_this_updateZ_next_updaterr rr	r�ReasonFlagsZ_cert_statusZ_revocation_timeZ_revocation_reason)	�self�cert�issuerr�cert_status�this_update�next_update�revocation_time�revocation_reasonrrr�__init__;sZ�
�
�
���
��z_SingleResponse.__init__N)rr
rr/rrrrr!:sr!c@s�eZdZejed�dd��Zejed�dd��Zejej	d�dd��Z
ejed�dd	��Zej
ejed
�dd��Zejejd�d
d��ZdS)�OCSPRequest��returncCsdS�z3
        The hash of the issuer public key
        Nr�r'rrr�issuer_key_hash�szOCSPRequest.issuer_key_hashcCsdS�z-
        The hash of the issuer name
        Nrr4rrr�issuer_name_hash�szOCSPRequest.issuer_name_hashcCsdS�zK
        The hash algorithm used in the issuer name and key hashes
        Nrr4rrr�hash_algorithm�szOCSPRequest.hash_algorithmcCsdS�zM
        The serial number of the cert whose status is being checked
        Nrr4rrr�
serial_number�szOCSPRequest.serial_number��encodingr2cCsdS)z/
        Serializes the request to DER
        Nr�r'r=rrr�public_bytes�szOCSPRequest.public_bytescCsdS)zP
        The list of request extensions. Not single request extensions.
        Nrr4rrr�
extensions�szOCSPRequest.extensionsN)rr
r�abc�abstractproperty�bytesr5r7r�
HashAlgorithmr9�intr;�abstractmethodr�Encodingr?r�
Extensionsr@rrrrr0�sr0)�	metaclassc@s�eZdZejed�dd��Zejejd�dd��Z	eje
jej
d�dd��Zejed�dd	��Zejed�d
d��Zeje
jejd�dd
��Zeje
jed�dd��Zeje
jejd�dd��Zejejd�dd��Zejed�dd��Zeje
jejd�dd��Zeje
jejd�dd��Zejejd�dd��Zeje
jejd�dd��Z ejed�dd��Z!ejed�d d!��Z"ejej
d�d"d#��Z#eje$d�d$d%��Z%ejej&d�d&d'��Z'ejej&d�d(d)��Z(ej)e*j+ed*�d+d,��Z,d-S).�OCSPResponser1cCsdS)zm
        The status of the response. This is a value from the OCSPResponseStatus
        enumeration
        Nrr4rrr�response_status�szOCSPResponse.response_statuscCsdS)zA
        The ObjectIdentifier of the signature algorithm
        Nrr4rrr�signature_algorithm_oid�sz$OCSPResponse.signature_algorithm_oidcCsdS)zX
        Returns a HashAlgorithm corresponding to the type of the digest signed
        Nrr4rrr�signature_hash_algorithm�sz%OCSPResponse.signature_hash_algorithmcCsdS)z%
        The signature bytes
        Nrr4rrr�	signature�szOCSPResponse.signaturecCsdS)z+
        The tbsResponseData bytes
        Nrr4rrr�tbs_response_bytes�szOCSPResponse.tbs_response_bytescCsdS)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.
        Nrr4rrr�certificates�szOCSPResponse.certificatescCsdS)z2
        The responder's key hash or None
        Nrr4rrr�responder_key_hash�szOCSPResponse.responder_key_hashcCsdS)z.
        The responder's Name or None
        Nrr4rrr�responder_name�szOCSPResponse.responder_namecCsdS)z4
        The time the response was produced
        Nrr4rrr�produced_at�szOCSPResponse.produced_atcCsdS)zY
        The status of the certificate (an element from the OCSPCertStatus enum)
        Nrr4rrr�certificate_status�szOCSPResponse.certificate_statuscCsdS)z^
        The date of when the certificate was revoked or None if not
        revoked.
        Nrr4rrrr-�szOCSPResponse.revocation_timecCsdS)zi
        The reason the certificate was revoked or None if not specified or
        not revoked.
        Nrr4rrrr.�szOCSPResponse.revocation_reasoncCsdS)z�
        The most recent time at which the status being indicated is known by
        the responder to have been correct
        Nrr4rrrr+�szOCSPResponse.this_updatecCsdS)zC
        The time when newer information will be available
        Nrr4rrrr,�szOCSPResponse.next_updatecCsdSr3rr4rrrr5szOCSPResponse.issuer_key_hashcCsdSr6rr4rrrr7	szOCSPResponse.issuer_name_hashcCsdSr8rr4rrrr9szOCSPResponse.hash_algorithmcCsdSr:rr4rrrr;szOCSPResponse.serial_numbercCsdS)zR
        The list of response extensions. Not single response extensions.
        Nrr4rrrr@szOCSPResponse.extensionscCsdS)zR
        The list of single response extensions. Not response extensions.
        Nrr4rrr�single_extensions!szOCSPResponse.single_extensionsr<cCsdS)z0
        Serializes the response to DER
        Nrr>rrrr?'szOCSPResponse.public_bytesN)-rr
rrArBrrKrZObjectIdentifierrL�typing�OptionalrrDrMrCrNrO�Listr#rPrQ�NamerRr%rSrrTr-r&r.r+r,r5r7r9rEr;rHr@rUrFrrGr?rrrrrJ�sV
�rJc@s�eZdZdgfejejejejej	fej
ejejdd�dd�Z
ejejej	dd�dd�Zejedd�d	d
�Zed�dd
�ZdS)�OCSPRequestBuilderN)�requestr@r2cCs||_||_dS�N)�_request�_extensions)r'r[r@rrrr//s	zOCSPRequestBuilder.__init__)r(r)rr2cCsL|jdurtd��t|�t|tj�r2t|tj�s:td��t|||f|j�S)Nz.Only one certificate can be added to a requestr")	r]rrrrr#r$rZr^)r'r(r)rrrr�add_certificate;s
�z"OCSPRequestBuilder.add_certificate��extval�criticalr2cCsDt|tj�std��t�|j||�}t||j�t|j	|j|g�S�Nz"extension must be an ExtensionType)
rr�
ExtensionTyper$�	Extension�oidr
r^rZr]�r'rarb�	extensionrrr�
add_extensionLs�z OCSPRequestBuilder.add_extensionr1cCs|jdurtd��t�|�S)Nz*You must add a certificate before building)r]rrZcreate_ocsp_requestr4rrr�buildYs
zOCSPRequestBuilder.build)rr
rrVrW�Tuplerr#rrDrXrerdr/r_�boolrir0rjrrrrrZ.s(������
rZc
@s
eZdZdddgfejeejejeje	fejej
ejej
ejejd�dd�Z
ejejejeejejejejejejejdd�	dd�Ze	ejdd�d	d
�Zejejdd�dd
�Zejedd�dd�Zeejejed�dd�Zeeed�dd��ZdS)�OCSPResponseBuilderN)�response�responder_id�certsr@cCs||_||_||_||_dSr\)�	_response�
_responder_id�_certsr^)r'rnrorpr@rrrr/as	zOCSPResponseBuilder.__init__)	r(r)rr*r+r,r-r.r2c	
	Cs<|jdurtd��t||||||||�}	t|	|j|j|j�S)Nz#Only one response per OCSPResponse.)rqrr!rmrrrsr^)
r'r(r)rr*r+r,r-r.Z
singleresprrr�add_responseos$
�
�z OCSPResponseBuilder.add_response)r=�responder_certr2cCsP|jdurtd��t|tj�s&td��t|t�s8td��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)rrrrrr#r$rrmrqrsr^)r'r=rurrrro�s

��z OCSPResponseBuilder.responder_id)rpr2cCs\|jdurtd��t|�}t|�dkr.td��tdd�|D��sHtd��t|j|j||j	�S)Nz!certificates may only be set oncerzcerts must not be an empty listcss|]}t|tj�VqdSr\)rrr#)�.0�xrrr�	<genexpr>��z3OCSPResponseBuilder.certificates.<locals>.<genexpr>z$certs must be a list of Certificates)
rsr�list�len�allr$rmrqrrr^)r'rprrrrP�s
�z OCSPResponseBuilder.certificatesr`cCsLt|tj�std��t�|j||�}t||j�t|j	|j
|j|j|g�Src)rrrdr$rerfr
r^rmrqrrrsrgrrrri�s
�z!OCSPResponseBuilder.add_extension)�private_keyrr2cCs6|jdurtd��|jdur$td��t�tj|||�S)Nz&You must add a response before signingz*You must add a responder_id before signing)rqrrrr�create_ocsp_responserr)r'r}rrrr�sign�s


�zOCSPResponseBuilder.sign)rKr2cCs4t|t�std��|tjur$td��t�|ddd�S)Nz7response_status must be an item from OCSPResponseStatusz$response_status cannot be SUCCESSFUL)rrr$rrrr~)�clsrKrrr�build_unsuccessful�s
�
z&OCSPResponseBuilder.build_unsuccessful)rr
rrVrWr!rkrr#rrXrerdr/rrDrr%r&rtro�IterablerPrlrirrJr�classmethodrr�rrrrrm`sN���


� �
��
��rm)�datar2cCs
t�|�Sr\)r�load_der_ocsp_request�r�rrrr��sr�cCs
t�|�Sr\)r�load_der_ocsp_responser�rrrr��sr�)%rAr%rVZcryptographyrrZ"cryptography.hazmat.bindings._rustrZcryptography.hazmat.primitivesrrZcryptography.x509.baserrr	r
�EnumrrZSHA1ZSHA224ZSHA256ZSHA384ZSHA512rrr�objectr!�ABCMetar0rJrZrmrCr�r�rrrr�<module>s2
�	F&	2~