ok

Mini Shell

Direktori : /opt/alt/python38/lib64/python3.8/site-packages/cryptography/x509/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/site-packages/cryptography/x509/__pycache__/base.cpython-38.pyc

U

e�_�\�@s�ddlmZmZmZddlZddlZddlZddlmZddl	Z	ddl
mZddlm
Z
mZmZddlmZmZddlmZe�dd	d	�Zd
d�ZGdd
�d
e�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�de�Ze	� ej!�Gdd�de"��Z#e	� ej!�Gdd�de"��Z$e	� ej!�Gd d!�d!e"��Z%e	� ej!�Gd"d#�d#e"��Z&Gd$d%�d%e"�Z'Gd&d'�d'e"�Z(Gd(d)�d)e"�Z)Gd*d+�d+e"�Z*d,d-�Z+dS).�)�absolute_import�division�print_functionN)�Enum)�utils)�dsa�ec�rsa)�	Extension�
ExtensionType)�Namei��cCs:|jdk	r2|��}|r|nt��}|jdd�|S|SdS)z�Normalizes a datetime to a naive datetime in UTC.

    time -- datetime to normalize. Assumed to be in UTC if not timezone
            aware.
    N)�tzinfo)rZ	utcoffset�datetimeZ	timedelta�replace)�time�offset�r�/base.py�_convert_to_naive_utc_times

rc@seZdZdZdZdS)�Versionr�N)�__name__�
__module__�__qualname__Zv1�v3rrrrr%srcCs
|�|�S�N)�load_pem_x509_certificate��data�backendrrrr*srcCs
|�|�Sr)�load_der_x509_certificaterrrrr!.sr!cCs
|�|�Sr)�load_pem_x509_csrrrrrr"2sr"cCs
|�|�Sr)�load_der_x509_csrrrrrr#6sr#cCs
|�|�Sr)�load_pem_x509_crlrrrrr$:sr$cCs
|�|�Sr)�load_der_x509_crlrrrrr%>sr%cseZdZ�fdd�Z�ZS)�InvalidVersioncstt|��|�||_dSr)�superr&�__init__�parsed_version)�self�msgr)��	__class__rrr(CszInvalidVersion.__init__)rrrr(�
__classcell__rrr,rr&Bsr&c@s�eZdZejdd��Zejdd��Zejdd��Zejdd��Z	ejd	d
��Z
ejdd��Zejd
d��Zejdd��Z
ejdd��Zejdd��Zejdd��Zejdd��Zejdd��Zejdd��Zejdd��Zejdd ��Zejd!d"��Zd#S)$�CertificatecCsdS�z4
        Returns bytes using digest passed.
        Nr�r*�	algorithmrrr�fingerprintJszCertificate.fingerprintcCsdS)z3
        Returns certificate serial number
        Nr�r*rrr�
serial_numberPszCertificate.serial_numbercCsdS)z1
        Returns the certificate version
        Nrr4rrr�versionVszCertificate.versioncCsdS�z(
        Returns the public key
        Nrr4rrr�
public_key\szCertificate.public_keycCsdS)z?
        Not before time (represented as UTC datetime)
        Nrr4rrr�not_valid_beforebszCertificate.not_valid_beforecCsdS)z>
        Not after time (represented as UTC datetime)
        Nrr4rrr�not_valid_afterhszCertificate.not_valid_aftercCsdS)z1
        Returns the issuer name object.
        Nrr4rrr�issuernszCertificate.issuercCsdS�z2
        Returns the subject name object.
        Nrr4rrr�subjecttszCertificate.subjectcCsdS�zt
        Returns a HashAlgorithm corresponding to the type of the digest signed
        in the certificate.
        Nrr4rrr�signature_hash_algorithmzsz$Certificate.signature_hash_algorithmcCsdS�zJ
        Returns the ObjectIdentifier of the signature algorithm.
        Nrr4rrr�signature_algorithm_oid�sz#Certificate.signature_algorithm_oidcCsdS)z/
        Returns an Extensions object.
        Nrr4rrr�
extensions�szCertificate.extensionscCsdS�z.
        Returns the signature bytes.
        Nrr4rrr�	signature�szCertificate.signaturecCsdS)zR
        Returns the tbsCertificate payload bytes as defined in RFC 5280.
        Nrr4rrr�tbs_certificate_bytes�sz!Certificate.tbs_certificate_bytescCsdS�z"
        Checks equality.
        Nr�r*�otherrrr�__eq__�szCertificate.__eq__cCsdS�z#
        Checks not equal.
        NrrGrrr�__ne__�szCertificate.__ne__cCsdS�z"
        Computes a hash.
        Nrr4rrr�__hash__�szCertificate.__hash__cCsdS)zB
        Serializes the certificate to PEM or DER format.
        Nr�r*�encodingrrr�public_bytes�szCertificate.public_bytesN)rrr�abc�abstractmethodr3�abstractpropertyr5r6r8r9r:r;r=r?rArBrDrErIrKrMrPrrrrr/HsD















r/c@s�eZdZejdd��Zejdd��Zejdd��Zejdd��Z	ejd	d
��Z
ejdd��Zejd
d��Zejdd��Z
ejdd��Zejdd��Zejdd��Zejdd��Zejdd��Zejdd��ZdS)�CertificateRevocationListcCsdS)z:
        Serializes the CRL to PEM or DER format.
        NrrNrrrrP�sz&CertificateRevocationList.public_bytescCsdSr0rr1rrrr3�sz%CertificateRevocationList.fingerprintcCsdS)zs
        Returns an instance of RevokedCertificate or None if the serial_number
        is not in the CRL.
        Nr)r*r5rrr�(get_revoked_certificate_by_serial_number�szBCertificateRevocationList.get_revoked_certificate_by_serial_numbercCsdSr>rr4rrrr?�sz2CertificateRevocationList.signature_hash_algorithmcCsdSr@rr4rrrrA�sz1CertificateRevocationList.signature_algorithm_oidcCsdS)zC
        Returns the X509Name with the issuer of this CRL.
        Nrr4rrrr;�sz CertificateRevocationList.issuercCsdS)z?
        Returns the date of next update for this CRL.
        Nrr4rrr�next_update�sz%CertificateRevocationList.next_updatecCsdS)z?
        Returns the date of last update for this CRL.
        Nrr4rrr�last_update�sz%CertificateRevocationList.last_updatecCsdS)zS
        Returns an Extensions object containing a list of CRL extensions.
        Nrr4rrrrB�sz$CertificateRevocationList.extensionscCsdSrCrr4rrrrD�sz#CertificateRevocationList.signaturecCsdS)zO
        Returns the tbsCertList payload bytes as defined in RFC 5280.
        Nrr4rrr�tbs_certlist_bytes�sz,CertificateRevocationList.tbs_certlist_bytescCsdSrFrrGrrrrI�sz CertificateRevocationList.__eq__cCsdSrJrrGrrrrK�sz CertificateRevocationList.__ne__cCsdS)zQ
        Verifies signature of revocation list against given public key.
        Nr)r*r8rrr�is_signature_validsz,CertificateRevocationList.is_signature_validN)rrrrQrRrPr3rUrSr?rAr;rVrWrBrDrXrIrKrYrrrrrT�s8












rTc@s�eZdZejdd��Zejdd��Zejdd��Zejdd��Zej	d	d
��Z
ej	dd��Zej	d
d��Zej	dd��Z
ejdd��Zej	dd��Zej	dd��Zej	dd��ZdS)�CertificateSigningRequestcCsdSrFrrGrrrrI
sz CertificateSigningRequest.__eq__cCsdSrJrrGrrrrKsz CertificateSigningRequest.__ne__cCsdSrLrr4rrrrMsz"CertificateSigningRequest.__hash__cCsdSr7rr4rrrr8sz$CertificateSigningRequest.public_keycCsdSr<rr4rrrr=%sz!CertificateSigningRequest.subjectcCsdSr>rr4rrrr?+sz2CertificateSigningRequest.signature_hash_algorithmcCsdSr@rr4rrrrA2sz1CertificateSigningRequest.signature_algorithm_oidcCsdS)z@
        Returns the extensions in the signing request.
        Nrr4rrrrB8sz$CertificateSigningRequest.extensionscCsdS)z;
        Encodes the request to PEM or DER format.
        NrrNrrrrP>sz&CertificateSigningRequest.public_bytescCsdSrCrr4rrrrDDsz#CertificateSigningRequest.signaturecCsdS)zd
        Returns the PKCS#10 CertificationRequestInfo bytes as defined in RFC
        2986.
        Nrr4rrr�tbs_certrequest_bytesJsz/CertificateSigningRequest.tbs_certrequest_bytescCsdS)z8
        Verifies signature of signing request.
        Nrr4rrrrYQsz,CertificateSigningRequest.is_signature_validN)rrrrQrRrIrKrMr8rSr=r?rArBrPrDr[rYrrrrrZs0










rZc@s6eZdZejdd��Zejdd��Zejdd��ZdS)�RevokedCertificatecCsdS)zG
        Returns the serial number of the revoked certificate.
        Nrr4rrrr5Zsz RevokedCertificate.serial_numbercCsdS)zH
        Returns the date of when this certificate was revoked.
        Nrr4rrr�revocation_date`sz"RevokedCertificate.revocation_datecCsdS)zW
        Returns an Extensions object containing a list of Revoked extensions.
        Nrr4rrrrBfszRevokedCertificate.extensionsN)rrrrQrSr5r]rBrrrrr\Xs

r\c@s2eZdZdgfdd�Zdd�Zdd�Zdd	�ZdS)
� CertificateSigningRequestBuilderNcCs||_||_dS)zB
        Creates an empty X.509 certificate request (v1).
        N)�
_subject_name�_extensions)r*�subject_namerBrrrr(nsz)CertificateSigningRequestBuilder.__init__cCs0t|t�std��|jdk	r$td��t||j�S)zF
        Sets the certificate requestor's distinguished name.
        �Expecting x509.Name object.N�&The subject name may only be set once.)�
isinstancer�	TypeErrorr_�
ValueErrorr^r`�r*�namerrrraus


z-CertificateSigningRequestBuilder.subject_namecCsTt|t�std��t|j||�}|jD]}|j|jkr&td��q&t|j|j|g�S)zE
        Adds an X.509 extension to the certificate request.
        �"extension must be an ExtensionType�$This extension has already been set.)	rdrrer
�oidr`rfr^r_�r*�	extensionZcritical�errr�
add_extensions



�z.CertificateSigningRequestBuilder.add_extensioncCs |jdkrtd��|�|||�S)zF
        Signs the request using the requestor's private key.
        Nz/A CertificateSigningRequest must have a subject)r_rfZcreate_x509_csr�r*Zprivate_keyr2r rrr�sign�s
z%CertificateSigningRequestBuilder.sign)rrrr(rarorqrrrrr^ms
r^c@sdeZdZddddddgfdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)�CertificateBuilderNcCs6tj|_||_||_||_||_||_||_||_	dSr)
rrZ_version�_issuer_namer_�_public_key�_serial_number�_not_valid_before�_not_valid_afterr`)r*�issuer_namerar8r5r9r:rBrrrr(�szCertificateBuilder.__init__cCsDt|t�std��|jdk	r$td��t||j|j|j|j	|j
|j�S)z3
        Sets the CA's distinguished name.
        rbN�%The issuer name may only be set once.)rdrrersrfrrr_rtrurvrwr`rgrrrrx�s

�zCertificateBuilder.issuer_namecCsDt|t�std��|jdk	r$td��t|j||j|j|j	|j
|j�S)z:
        Sets the requestor's distinguished name.
        rbNrc)rdrrer_rfrrrsrtrurvrwr`rgrrrra�s

�zCertificateBuilder.subject_namecCsPt|tjtjtjf�std��|jdk	r0t	d��t
|j|j||j
|j|j|j�S)zT
        Sets the requestor's public key (as found in the signing request).
        zGExpecting one of DSAPublicKey, RSAPublicKey, or EllipticCurvePublicKey.Nz$The public key may only be set once.)rdrZDSAPublicKeyr	ZRSAPublicKeyrZEllipticCurvePublicKeyrertrfrrrsr_rurvrwr`)r*�keyrrrr8�s�
�zCertificateBuilder.public_keycCsjt|tj�std��|jdk	r&td��|dkr6td��|��dkrJtd��t|j|j	|j
||j|j|j
�S)z5
        Sets the certificate serial number.
        �'Serial number must be of integral type.N�'The serial number may only be set once.rz%The serial number should be positive.��3The serial number should not be more than 159 bits.)rd�six�
integer_typesrerurf�
bit_lengthrrrsr_rtrvrwr`�r*Znumberrrrr5�s"
�z CertificateBuilder.serial_numbercCszt|tj�std��|jdk	r&td��t|�}|tkr>td��|jdk	rZ||jkrZtd��t|j	|j
|j|j||j|j
�S)z7
        Sets the certificate activation time.
        �Expecting datetime object.Nz*The not valid before may only be set once.zHThe not valid before date must be after the unix epoch (1970 January 1).zBThe not valid before date must be before the not valid after date.)rdrrervrfr�_UNIX_EPOCHrwrrrsr_rtrur`�r*rrrrr9�s(
��z#CertificateBuilder.not_valid_beforecCszt|tj�std��|jdk	r&td��t|�}|tkr>td��|jdk	rZ||jkrZtd��t|j	|j
|j|j|j||j
�S)z7
        Sets the certificate expiration time.
        r�Nz)The not valid after may only be set once.zGThe not valid after date must be after the unix epoch (1970 January 1).zAThe not valid after date must be after the not valid before date.)rdrrerwrfrr�rvrrrsr_rtrur`r�rrrr:�s,

���z"CertificateBuilder.not_valid_afterc	Csht|t�std��t|j||�}|jD]}|j|jkr&td��q&t|j|j	|j
|j|j|j
|j|g�S)z=
        Adds an X.509 extension to the certificate.
        rirj)rdrrer
rkr`rfrrrsr_rtrurvrwrlrrrros



�z CertificateBuilder.add_extensioncCsz|jdkrtd��|jdkr$td��|jdkr6td��|jdkrHtd��|jdkrZtd��|jdkrltd��|�|||�S)zC
        Signs the certificate using the CA's private key.
        Nz&A certificate must have a subject namez&A certificate must have an issuer namez'A certificate must have a serial numberz/A certificate must have a not valid before timez.A certificate must have a not valid after timez$A certificate must have a public key)r_rfrsrurvrwrtZcreate_x509_certificaterprrrrq+s





zCertificateBuilder.sign)rrrr(rxrar8r5r9r:rorqrrrrrr�s�
rrc@sPeZdZdddggfdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)� CertificateRevocationListBuilderNcCs"||_||_||_||_||_dSr)rs�_last_update�_next_updater`�_revoked_certificates)r*rxrWrVrBZrevoked_certificatesrrrr(Es
z)CertificateRevocationListBuilder.__init__cCs<t|t�std��|jdk	r$td��t||j|j|j|j	�S)Nrbry)
rdrrersrfr�r�r�r`r�)r*rxrrrrxMs

�z,CertificateRevocationListBuilder.issuer_namecCsrt|tj�std��|jdk	r&td��t|�}|tkr>td��|jdk	rZ||jkrZtd��t|j	||j|j
|j�S)Nr��!Last update may only be set once.�CThe last update date must be after the unix epoch (1970 January 1).z9The last update date must be before the next update date.)rdrrer�rfrr�r�r�rsr`r�)r*rWrrrrWWs$
��z,CertificateRevocationListBuilder.last_updatecCsrt|tj�std��|jdk	r&td��t|�}|tkr>td��|jdk	rZ||jkrZtd��t|j	|j||j
|j�S)Nr�r�r�z8The next update date must be after the last update date.)rdrrer�rfrr�r�r�rsr`r�)r*rVrrrrVis$
��z,CertificateRevocationListBuilder.next_updatecCs`t|t�std��t|j||�}|jD]}|j|jkr&td��q&t|j|j	|j
|j|g|j�S)zM
        Adds an X.509 extension to the certificate revocation list.
        rirj)rdrrer
rkr`rfr�rsr�r�r�rlrrrro{s



�z.CertificateRevocationListBuilder.add_extensioncCs2t|t�std��t|j|j|j|j|j|g�S)z8
        Adds a revoked certificate to the CRL.
        z)Must be an instance of RevokedCertificate)	rdr\rer�rsr�r�r`r�)r*Zrevoked_certificaterrr�add_revoked_certificate�s

�z8CertificateRevocationListBuilder.add_revoked_certificatecCsD|jdkrtd��|jdkr$td��|jdkr6td��|�|||�S)NzA CRL must have an issuer namez"A CRL must have a last update timez"A CRL must have a next update time)rsrfr�r�Zcreate_x509_crlrprrrrq�s


z%CertificateRevocationListBuilder.sign)
rrrr(rxrWrVror�rqrrrrr�Ds�


r�c@s<eZdZddgfdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)�RevokedCertificateBuilderNcCs||_||_||_dSr)ru�_revocation_dater`)r*r5r]rBrrrr(�sz"RevokedCertificateBuilder.__init__cCsZt|tj�std��|jdk	r&td��|dkr6td��|��dkrJtd��t||j|j	�S)Nr{r|rz$The serial number should be positiver}r~)
rdrr�rerurfr�r�r�r`r�rrrr5�s
�z'RevokedCertificateBuilder.serial_numbercCsNt|tj�std��|jdk	r&td��t|�}|tkr>td��t|j||j	�S)Nr�z)The revocation date may only be set once.zBThe revocation date must be after the unix epoch (1970 January 1).)
rdrrer�rfrr�r�rur`r�rrrr]�s
�z)RevokedCertificateBuilder.revocation_datecCsXt|t�std��t|j||�}|jD]}|j|jkr&td��q&t|j|j	|j|g�S)Nrirj)
rdrrer
rkr`rfr�rur�rlrrrro�s



�z'RevokedCertificateBuilder.add_extensioncCs.|jdkrtd��|jdkr$td��|�|�S)Nz/A revoked certificate must have a serial numberz1A revoked certificate must have a revocation date)rurfr�Zcreate_x509_revoked_certificate)r*r rrr�build�s

�zRevokedCertificateBuilder.build)rrrr(r5r]ror�rrrrr��s�

r�cCst�t�d�d�d?S)N�Zbigr
)rZint_from_bytes�os�urandomrrrr�random_serial_number�sr�),Z
__future__rrrrQrr��enumrrZcryptographyrZ)cryptography.hazmat.primitives.asymmetricrrr	Zcryptography.x509.extensionsr
rZcryptography.x509.namerr�rrrr!r"r#r$r%�	Exceptionr&Z
add_metaclass�ABCMeta�objectr/rTrZr\r^rrr�r�r�rrrr�<module>sB
i
X
L
,,c?

Zerion Mini Shell 1.0