%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core/17212/usr/lib/python3/dist-packages/cryptography/x509/__pycache__/
Upload File :
Create Path :
Current File : //snap/core/17212/usr/lib/python3/dist-packages/cryptography/x509/__pycache__/base.cpython-35.pyc



�K�V�T�@s'ddlmZmZmZddlZddlZddlmZddlZddl	m
Z
ddlmZm
Z
mZddlmZmZddlmZejdd	d	�ZGd
d�de�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�de�Zejej�Gdd�de ��Z!ejej�Gdd�de ��Z"ejej�Gdd�de ��Z#ejej�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(dS)*�)�absolute_import�division�print_functionN)�Enum)�utils)�dsa�ec�rsa)�	Extension�
ExtensionType)�Namei��c@seZdZdZdZdS)�Versionr�N)�__name__�
__module__�__qualname__Zv1�v3�rr�8/usr/lib/python3/dist-packages/cryptography/x509/base.pyrsrcCs
|j|�S)N)�load_pem_x509_certificate)�data�backendrrrrsrcCs
|j|�S)N)�load_der_x509_certificate)rrrrrrsrcCs
|j|�S)N)�load_pem_x509_csr)rrrrrr#srcCs
|j|�S)N)�load_der_x509_csr)rrrrrr'srcCs
|j|�S)N)�load_pem_x509_crl)rrrrrr+srcCs
|j|�S)N)�load_der_x509_crl)rrrrrr/srcs"eZdZ�fdd�Z�S)�InvalidVersioncs#tt|�j|�||_dS)N)�superr�__init__�parsed_version)�self�msgr!)�	__class__rrr 4szInvalidVersion.__init__)rrrr rr)r$rr3src@s`eZdZejdd��Zejdd��Zejdd��Zejdd��Z	ejd	d
��Z
ejdd��Zejd
d��Zejdd��Z
ejdd��Zejdd��Zejdd��Zejdd��Zejdd��Zejdd��Zejdd��Zejdd ��Zd!S)"�CertificatecCsdS)z4
        Returns bytes using digest passed.
        Nr)r"�	algorithmrrr�fingerprint;szCertificate.fingerprintcCsdS)z3
        Returns certificate serial number
        Nr)r"rrr�serialAszCertificate.serialcCsdS)z1
        Returns the certificate version
        Nr)r"rrr�versionGszCertificate.versioncCsdS)z(
        Returns the public key
        Nr)r"rrr�
public_keyMszCertificate.public_keycCsdS)z?
        Not before time (represented as UTC datetime)
        Nr)r"rrr�not_valid_beforeSszCertificate.not_valid_beforecCsdS)z>
        Not after time (represented as UTC datetime)
        Nr)r"rrr�not_valid_afterYszCertificate.not_valid_aftercCsdS)z1
        Returns the issuer name object.
        Nr)r"rrr�issuer_szCertificate.issuercCsdS)z2
        Returns the subject name object.
        Nr)r"rrr�subjecteszCertificate.subjectcCsdS)zt
        Returns a HashAlgorithm corresponding to the type of the digest signed
        in the certificate.
        Nr)r"rrr�signature_hash_algorithmksz$Certificate.signature_hash_algorithmcCsdS)z/
        Returns an Extensions object.
        Nr)r"rrr�
extensionsrszCertificate.extensionscCsdS)z.
        Returns the signature bytes.
        Nr)r"rrr�	signaturexszCertificate.signaturecCsdS)zR
        Returns the tbsCertificate payload bytes as defined in RFC 5280.
        Nr)r"rrr�tbs_certificate_bytes~sz!Certificate.tbs_certificate_bytescCsdS)z"
        Checks equality.
        Nr)r"�otherrrr�__eq__�szCertificate.__eq__cCsdS)z#
        Checks not equal.
        Nr)r"r3rrr�__ne__�szCertificate.__ne__cCsdS)z"
        Computes a hash.
        Nr)r"rrr�__hash__�szCertificate.__hash__cCsdS)zB
        Serializes the certificate to PEM or DER format.
        Nr)r"�encodingrrr�public_bytes�szCertificate.public_bytesN)rrr�abc�abstractmethodr'�abstractpropertyr(r)r*r+r,r-r.r/r0r1r2r4r5r6r8rrrrr%9s r%c@s�eZdZejdd��Zejdd��Zejdd��Zejdd��Z	ejd	d
��Z
ejdd��Zejd
d��Zejdd��Z
ejdd��Zejdd��Zejdd��ZdS)�CertificateRevocationListcCsdS)z:
        Serializes the CRL to PEM or DER format.
        Nr)r"r7rrrr8�sz&CertificateRevocationList.public_bytescCsdS)z4
        Returns bytes using digest passed.
        Nr)r"r&rrrr'�sz%CertificateRevocationList.fingerprintcCsdS)zt
        Returns a HashAlgorithm corresponding to the type of the digest signed
        in the certificate.
        Nr)r"rrrr/�sz2CertificateRevocationList.signature_hash_algorithmcCsdS)zC
        Returns the X509Name with the issuer of this CRL.
        Nr)r"rrrr-�sz CertificateRevocationList.issuercCsdS)z?
        Returns the date of next update for this CRL.
        Nr)r"rrr�next_update�sz%CertificateRevocationList.next_updatecCsdS)z?
        Returns the date of last update for this CRL.
        Nr)r"rrr�last_update�sz%CertificateRevocationList.last_updatecCsdS)zS
        Returns an Extensions object containing a list of CRL extensions.
        Nr)r"rrrr0�sz$CertificateRevocationList.extensionscCsdS)z.
        Returns the signature bytes.
        Nr)r"rrrr1�sz#CertificateRevocationList.signaturecCsdS)zO
        Returns the tbsCertList payload bytes as defined in RFC 5280.
        Nr)r"rrr�tbs_certlist_bytes�sz,CertificateRevocationList.tbs_certlist_bytescCsdS)z"
        Checks equality.
        Nr)r"r3rrrr4�sz CertificateRevocationList.__eq__cCsdS)z#
        Checks not equal.
        Nr)r"r3rrrr5�sz CertificateRevocationList.__ne__N)rrrr9r:r8r'r;r/r-r=r>r0r1r?r4r5rrrrr<�sr<c@s�eZdZejdd��Zejdd��Zejdd��Zejdd��Zej	d	d
��Z
ej	dd��Zej	d
d��Zejdd��Z
ej	dd��Zej	dd��ZdS)�CertificateSigningRequestcCsdS)z"
        Checks equality.
        Nr)r"r3rrrr4�sz CertificateSigningRequest.__eq__cCsdS)z#
        Checks not equal.
        Nr)r"r3rrrr5�sz CertificateSigningRequest.__ne__cCsdS)z"
        Computes a hash.
        Nr)r"rrrr6�sz"CertificateSigningRequest.__hash__cCsdS)z(
        Returns the public key
        Nr)r"rrrr*�sz$CertificateSigningRequest.public_keycCsdS)z2
        Returns the subject name object.
        Nr)r"rrrr.�sz!CertificateSigningRequest.subjectcCsdS)zt
        Returns a HashAlgorithm corresponding to the type of the digest signed
        in the certificate.
        Nr)r"rrrr/sz2CertificateSigningRequest.signature_hash_algorithmcCsdS)z@
        Returns the extensions in the signing request.
        Nr)r"rrrr0
sz$CertificateSigningRequest.extensionscCsdS)z;
        Encodes the request to PEM or DER format.
        Nr)r"r7rrrr8sz&CertificateSigningRequest.public_bytescCsdS)z.
        Returns the signature bytes.
        Nr)r"rrrr1sz#CertificateSigningRequest.signaturecCsdS)zd
        Returns the PKCS#10 CertificationRequestInfo bytes as defined in RFC
        2986.
        Nr)r"rrr�tbs_certrequest_bytessz/CertificateSigningRequest.tbs_certrequest_bytesN)rrrr9r:r4r5r6r*r;r.r/r0r8r1rArrrrr@�sr@c@sOeZdZejdd��Zejdd��Zejdd��ZdS)�RevokedCertificatecCsdS)zG
        Returns the serial number of the revoked certificate.
        Nr)r"rrr�
serial_number&sz RevokedCertificate.serial_numbercCsdS)zH
        Returns the date of when this certificate was revoked.
        Nr)r"rrr�revocation_date,sz"RevokedCertificate.revocation_datecCsdS)zW
        Returns an Extensions object containing a list of Revoked extensions.
        Nr)r"rrrr02szRevokedCertificate.extensionsN)rrrr9r;rCrDr0rrrrrB$srBc@sFeZdZdgdd�Zdd�Zdd�Zdd	�ZdS)
� CertificateSigningRequestBuilderNcCs||_||_dS)zB
        Creates an empty X.509 certificate request (v1).
        N)�
_subject_name�_extensions)r"�subject_namer0rrrr :s	z)CertificateSigningRequestBuilder.__init__cCsFt|t�std��|jdk	r6td��t||j�S)zF
        Sets the certificate requestor's distinguished name.
        zExpecting x509.Name object.Nz&The subject name may only be set once.)�
isinstancer�	TypeErrorrF�
ValueErrorrErG)r"�namerrrrHAs
z-CertificateSigningRequestBuilder.subject_namecCs|t|t�std��t|j||�}x/|jD]$}|j|jkr:td��q:Wt|j|j|g�S)zE
        Adds an X.509 extension to the certificate request.
        z"extension must be an ExtensionTypez$This extension has already been set.)	rIrrJr
�oidrGrKrErF)r"�	extension�critical�errr�
add_extensionKsz.CertificateSigningRequestBuilder.add_extensioncCs.|jdkrtd��|j|||�S)zF
        Signs the request using the requestor's private key.
        Nz/A CertificateSigningRequest must have a subject)rFrKZcreate_x509_csr)r"�private_keyr&rrrr�sign\sz%CertificateSigningRequestBuilder.sign)rrrr rHrQrSrrrrrE9s
rEc	@s�eZdZddddddgdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)�CertificateBuilderNcCsOtj|_||_||_||_||_||_||_||_	dS)N)
rrZ_version�_issuer_namerF�_public_key�_serial_number�_not_valid_before�_not_valid_afterrG)r"�issuer_namerHr*rCr+r,r0rrrr fs						zCertificateBuilder.__init__cCsdt|t�std��|jdk	r6td��t||j|j|j|j	|j
|j�S)z3
        Sets the CA's distinguished name.
        zExpecting x509.Name object.Nz%The issuer name may only be set once.)rIrrJrUrKrTrFrVrWrXrYrG)r"rLrrrrZrszCertificateBuilder.issuer_namecCsdt|t�std��|jdk	r6td��t|j||j|j|j	|j
|j�S)z:
        Sets the requestor's distinguished name.
        zExpecting x509.Name object.Nz&The subject name may only be set once.)rIrrJrFrKrTrUrVrWrXrYrG)r"rLrrrrH�szCertificateBuilder.subject_namecCsvt|tjtjtjf�s-td��|jdk	rHt	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.)rIrZDSAPublicKeyr	ZRSAPublicKeyrZEllipticCurvePublicKeyrJrVrKrTrUrFrWrXrYrG)r"�keyrrrr*�szCertificateBuilder.public_keycCs�t|tj�std��|jdk	r9td��|dkrQtd��tj|�dkrrtd��t|j	|j
|j||j|j
|j�S)z5
        Sets the certificate serial number.
        z'Serial number must be of integral type.Nz'The serial number may only be set once.rz)The serial number should be non-negative.�z3The serial number should not be more than 160 bits.)rI�six�
integer_typesrJrWrKr�
bit_lengthrTrUrFrVrXrYrG)r"�numberrrrrC�sz CertificateBuilder.serial_numbercCs�t|tj�std��|jdk	r9td��|tkrQtd��|jdk	r{||jkr{td��t|j|j	|j
|j||j|j�S)z7
        Sets the certificate activation time.
        zExpecting 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.)
rI�datetimerJrXrK�_UNIX_EPOCHrYrTrUrFrVrWrG)r"�timerrrr+�s	z#CertificateBuilder.not_valid_beforecCs�t|tj�std��|jdk	r9td��|tkrQtd��|jdk	r{||jkr{td��t|j|j	|j
|j|j||j�S)z7
        Sets the certificate expiration time.
        zExpecting datetime object.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.)
rIrarJrYrKrbrXrTrUrFrVrWrG)r"rcrrrr,�s	z"CertificateBuilder.not_valid_afterc	Cs�t|t�std��t|j||�}x/|jD]$}|j|jkr:td��q:Wt|j|j	|j
|j|j|j
|j|g�S)z=
        Adds an X.509 extension to the certificate.
        z"extension must be an ExtensionTypez$This extension has already been set.)rIrrJr
rMrGrKrTrUrFrVrWrXrY)r"rNrOrPrrrrQ�sz CertificateBuilder.add_extensioncCs�|jdkrtd��|jdkr6td��|jdkrQtd��|jdkrltd��|jdkr�td��|jdkr�td��|j|||�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)rFrKrUrWrXrYrVZcreate_x509_certificate)r"rRr&rrrrrS�szCertificateBuilder.sign)rrrr rZrHr*rCr+r,rQrSrrrrrTes	
rTc@sseZdZdddggdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)� CertificateRevocationListBuilderNcCs1||_||_||_||_||_dS)N)rU�_last_update�_next_updaterG�_revoked_certificates)r"rZr>r=r0Zrevoked_certificatesrrrr s
				z)CertificateRevocationListBuilder.__init__cCsXt|t�std��|jdk	r6td��t||j|j|j|j	�S)NzExpecting x509.Name object.z%The issuer name may only be set once.)
rIrrJrUrKrdrerfrGrg)r"rZrrrrZsz,CertificateRevocationListBuilder.issuer_namecCs�t|tj�std��|jdk	r9td��|tkrQtd��|jdk	r{||jkr{td��t|j||j|j	|j
�S)NzExpecting datetime object.z!Last update may only be set once.zCThe last update date must be after the unix epoch (1970 January 1).z9The last update date must be before the next update date.)rIrarJrerKrbrfrdrUrGrg)r"r>rrrr>s	z,CertificateRevocationListBuilder.last_updatecCs�t|tj�std��|jdk	r9td��|tkrQtd��|jdk	r{||jkr{td��t|j|j||j	|j
�S)NzExpecting datetime object.z!Last update may only be set once.zCThe last update date must be after the unix epoch (1970 January 1).z8The next update date must be after the last update date.)rIrarJrfrKrbrerdrUrGrg)r"r=rrrr=/s	z,CertificateRevocationListBuilder.next_updatecCs�t|t�std��t|j||�}x/|jD]$}|j|jkr:td��q:Wt|j|j	|j
|j|g|j�S)zM
        Adds an X.509 extension to the certificate revocation list.
        z"extension must be an ExtensionTypez$This extension has already been set.)rIrrJr
rMrGrKrdrUrerfrg)r"rNrOrPrrrrQ@sz.CertificateRevocationListBuilder.add_extensioncCsGt|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)	rIrBrJrdrUrerfrGrg)r"Zrevoked_certificaterrr�add_revoked_certificateRsz8CertificateRevocationListBuilder.add_revoked_certificatecCsd|jdkrtd��|jdkr6td��|jdkrQtd��|j|||�S)NzA CRL must have an issuer namez"A CRL must have a last update timez"A CRL must have a next update time)rUrKrerfZcreate_x509_crl)r"rRr&rrrrrS_sz%CertificateRevocationListBuilder.sign)
rrrr rZr>r=rQrhrSrrrrrds	

rdc@sUeZdZddgdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)�RevokedCertificateBuilderNcCs||_||_||_dS)N)rW�_revocation_daterG)r"rCrDr0rrrr ms		z"RevokedCertificateBuilder.__init__cCs�t|tj�std��|jdk	r9td��|dkrQtd��tj|�dkrrtd��t||j	|j
�S)Nz'Serial number must be of integral type.z'The serial number may only be set once.rz)The serial number should be non-negative.r\z3The serial number should not be more than 160 bits.)rIr]r^rJrWrKrr_rirjrG)r"r`rrrrCssz'RevokedCertificateBuilder.serial_numbercCsgt|tj�std��|jdk	r9td��|tkrQtd��t|j||j�S)NzExpecting datetime object.z)The revocation date may only be set once.zBThe revocation date must be after the unix epoch (1970 January 1).)	rIrarJrjrKrbrirWrG)r"rcrrrrD�sz)RevokedCertificateBuilder.revocation_datecCs�t|t�std��t|j||�}x/|jD]$}|j|jkr:td��q:Wt|j|j	|j|g�S)Nz"extension must be an ExtensionTypez$This extension has already been set.)
rIrrJr
rMrGrKrirWrj)r"rNrOrPrrrrQ�sz'RevokedCertificateBuilder.add_extensioncCsC|jdkrtd��|jdkr6td��|j|�S)Nz/A revoked certificate must have a serial numberz1A revoked certificate must have a revocation date)rWrKrjZcreate_x509_revoked_certificate)r"rrrr�build�s	zRevokedCertificateBuilder.build)rrrr rCrDrQrkrrrrrilsri))Z
__future__rrrr9raZenumrr]ZcryptographyrZ)cryptography.hazmat.primitives.asymmetricrrr	Zcryptography.x509.extensionsr
rZcryptography.x509.namerrbrrrrrrr�	ExceptionrZ
add_metaclass�ABCMeta�objectr%r<r@rBrErTrdrirrrr�<module>s:cE@,�a

Zerion Mini Shell 1.0