o
    5Wcf                    @   s  d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z
 d dlmZmZ d dlmZ d dlmZ d dlmZmZ d d	lmZ d d
lmZmZmZmZmZmZmZmZm Z  d dl!m"Z"m#Z# d dl$m%Z%m&Z&m'Z'm(Z( ej)ddddZ*dede+fddZ,de-fddZ.G dd de/Z0G dd de/Z1G dd de j2dZ3G dd dZ4G d d! d!e3Z5G d"d# d#e3Z6G d$d% d%e3Z7G d&d' d'e3Z8G d(d) d)e3Z9G d*d+ d+Z:G d,d- d-e3Z;G d.d/ d/e3Z<G d0d1 d1e3Z=G d2d3 d3e3Z>G d4d5 d5Z?G d6d7 d7ej@ZAeAjBeAjCeAjDeAjEeAjFeAjGeAjHeAjId8ZJeAjBd9eAjCd:eAjDd;eAjEd<eAjFd=eAjGd>eAjHd?eAjId@iZKG dAdB dBe3ZLG dCdD dDe3ZMG dEdF dFZNG dGdH dHZOG dIdJ dJZPG dKdL dLe3ZQG dMdN dNe3ZRG dOdP dPe3ZSG dQdR dRe3ZTG dSdT dTej@ZUdUdV eUD ZVG dWdX dXe3ZWG dYdZ dZe3ZXG d[d\ d\e3ZYG d]d^ d^ejZe* Z[G d_d` d`Z\G dadb dbe3Z]G dcdd dde3Z^G dedf dfe3Z_G dgdh dhe3Z`G didj dje3ZaG dkdl dle3ZbG dmdn dne3ZcG dodp dpe3ZdG dqdr dre3ZeG dsdt dte3ZfdS )u    N)utils)asn1)x509)constant_timeserialization)EllipticCurvePublicKey)RSAPublicKey)#CERTIFICATE_ISSUER_PUBLIC_KEY_TYPESCERTIFICATE_PUBLIC_KEY_TYPES)SignedCertificateTimestamp)	DNSNameDirectoryNameGeneralName	IPAddress	OtherName
RFC822NameRegisteredIDUniformResourceIdentifier_IPADDRESS_TYPES)NameRelativeDistinguishedName)CRLEntryExtensionOIDExtensionOIDOCSPExtensionOIDObjectIdentifierExtensionTypeVarExtensionTypeT)bound	covariant
public_keyreturnc                 C   sl   t | tr| tjjtjj}nt | tr | tjj	tjj
}n| tjjtjj}t|}t| S N)
isinstancer   public_bytesr   ZEncodingZDERZPublicFormatZPKCS1r   ZX962ZUncompressedPointZSubjectPublicKeyInfor   Zparse_spki_for_datahashlibsha1digest)r   dataZ
serialized r(   >D:\Flask\env\Lib\site-packages\cryptography/x509/extensions.py_key_identifier_from_public_key1   s    


r*   
field_namec                    s4   dt f fdd} fdd} fdd}|||fS )Nr    c                       t t|  S r!   )lengetattrselfr+   r(   r)   
len_methodJ      z*_make_sequence_methods.<locals>.len_methodc                    r,   r!   )iterr.   r/   r1   r(   r)   iter_methodM   r3   z+_make_sequence_methods.<locals>.iter_methodc                    s   t |  | S r!   )r.   )r0   idxr1   r(   r)   getitem_methodP   r3   z._make_sequence_methods.<locals>.getitem_method)int)r+   r2   r5   r7   r(   r1   r)   _make_sequence_methodsI   s   
r9   c                       *   e Zd Zdededdf fddZ  ZS )DuplicateExtensionmsgoidr    Nc                       t t| | || _d S r!   )superr;   __init__r=   r0   r<   r=   	__class__r(   r)   r@   W      
zDuplicateExtension.__init____name__
__module____qualname__strr   r@   __classcell__r(   r(   rB   r)   r;   V       "r;   c                       r:   )ExtensionNotFoundr<   r=   r    Nc                    r>   r!   )r?   rL   r@   r=   rA   rB   r(   r)   r@   ]   rD   zExtensionNotFound.__init__rE   r(   r(   rB   r)   rL   \   rK   rL   c                   @   s*   e Zd ZU eje ed< defddZdS )r   r=   r    c                 C   s   t d| )z7
        Serializes the extension type to DER.
        z8public_bytes is not implemented for extension type {0!r})NotImplementedErrorformatr/   r(   r(   r)   r#   e   s
   zExtensionType.public_bytesN)	rF   rG   rH   typingClassVarr   __annotations__bytesr#   r(   r(   r(   r)   r   b   s   
 )	metaclassc                   @   sj   e Zd Zdejd ddfddZdeddfdd	Zd
eje	 ddfddZ
ed\ZZZdefddZdS )
Extensions
extensionszExtension[ExtensionType]r    Nc                 C      t || _d S r!   )list_extensions)r0   rU   r(   r(   r)   r@   q   s   zExtensions.__init__r=   c                 C   s,   | D ]}|j |kr|  S qtd||)NNo {} extension was found)r=   rL   rN   )r0   r=   extr(   r(   r)   get_extension_for_oidv   s
   
z Extensions.get_extension_for_oidextclasszExtension[ExtensionTypeVar]c                 C   s@   |t u rtd| D ]}t|j|r|  S q
td||j)Nz|UnrecognizedExtension can't be used with get_extension_for_class because more than one instance of the class may be present.rY   )UnrecognizedExtension	TypeErrorr"   valuerL   rN   r=   )r0   r\   rZ   r(   r(   r)   get_extension_for_class   s   z"Extensions.get_extension_for_classrX   c                 C      d | jS )Nz<Extensions({})>)rN   rX   r/   r(   r(   r)   __repr__      zExtensions.__repr__)rF   rG   rH   rO   Iterabler@   r   r[   Typer   r`   r9   __len____iter____getitem__rI   rb   r(   r(   r(   r)   rT   p   s$    

	
rT   c                   @   sr   e Zd ZejZdeddfddZdede	fddZ
defd	d
ZdefddZedefddZdefddZdS )	CRLNumber
crl_numberr    Nc                 C      t |ts	td|| _d S Nzcrl_number must be an integerr"   r8   r^   _crl_numberr0   rj   r(   r(   r)   r@         

zCRLNumber.__init__otherc                 C      t |tstS | j|jkS r!   )r"   ri   NotImplementedrj   r0   rq   r(   r(   r)   __eq__      
zCRLNumber.__eq__c                 C   
   t | jS r!   hashrj   r/   r(   r(   r)   __hash__      
zCRLNumber.__hash__c                 C   ra   )Nz<CRLNumber({})>)rN   rj   r/   r(   r(   r)   rb      rc   zCRLNumber.__repr__c                 C      | j S r!   rn   r/   r(   r(   r)   rj         zCRLNumber.crl_numberc                 C   
   t | S r!   	rust_x509Zencode_extension_valuer/   r(   r(   r)   r#      r{   zCRLNumber.public_bytes)rF   rG   rH   r   Z
CRL_NUMBERr=   r8   r@   objectboolru   rz   rI   rb   propertyrj   rR   r#   r(   r(   r(   r)   ri          ri   c                   @   s   e Zd ZejZdeje dejej	e
  deje ddfddZededd fd	d
Ze				 dddZdefddZdedefddZdefddZedeje fddZedejeje
  fddZedeje fddZdefddZdS )AuthorityKeyIdentifierkey_identifierauthority_cert_issuerauthority_cert_serial_numberr    Nc                 C   sr   |d u |d u krt d|d ur!t|}tdd |D s!td|d ur.t|ts.td|| _|| _|| _d S )NzXauthority_cert_issuer and authority_cert_serial_number must both be present or both Nonec                 s       | ]}t |tV  qd S r!   r"   r   .0xr(   r(   r)   	<genexpr>       

z2AuthorityKeyIdentifier.__init__.<locals>.<genexpr>z;authority_cert_issuer must be a list of GeneralName objectsz/authority_cert_serial_number must be an integer)	
ValueErrorrW   allr^   r"   r8   _key_identifier_authority_cert_issuer_authority_cert_serial_number)r0   r   r   r   r(   r(   r)   r@      s*   

zAuthorityKeyIdentifier.__init__r   c                 C   s   t |}| |d d dS N)r   r   r   r*   )clsr   r&   r(   r(   r)   from_issuer_public_key   s   z-AuthorityKeyIdentifier.from_issuer_public_keyskiSubjectKeyIdentifierc                 C   s   | |j d d dS r   )r&   )r   r   r(   r(   r)   "from_issuer_subject_key_identifier   s
   z9AuthorityKeyIdentifier.from_issuer_subject_key_identifierc                 C   
   d | S )Nz<AuthorityKeyIdentifier(key_identifier={0.key_identifier!r}, authority_cert_issuer={0.authority_cert_issuer}, authority_cert_serial_number={0.authority_cert_serial_number})>rN   r/   r(   r(   r)   rb      s   zAuthorityKeyIdentifier.__repr__rq   c                 C   2   t |tstS | j|jko| j|jko| j|jkS r!   )r"   r   rs   r   r   r   rt   r(   r(   r)   ru      s   

zAuthorityKeyIdentifier.__eq__c                 C   s,   | j d u rd }nt| j }t| j|| jfS r!   )r   tuplery   r   r   )r0   Zacir(   r(   r)   rz     s   

zAuthorityKeyIdentifier.__hash__c                 C   r|   r!   )r   r/   r(   r(   r)   r     r~   z%AuthorityKeyIdentifier.key_identifierc                 C   r|   r!   )r   r/   r(   r(   r)   r        z,AuthorityKeyIdentifier.authority_cert_issuerc                 C   r|   r!   )r   r/   r(   r(   r)   r     r~   z3AuthorityKeyIdentifier.authority_cert_serial_numberc                 C   r   r!   r   r/   r(   r(   r)   r#     r{   z#AuthorityKeyIdentifier.public_bytes)r   r   r    r   )rF   rG   rH   r   ZAUTHORITY_KEY_IDENTIFIERr=   rO   OptionalrR   rd   r   r8   r@   classmethodr	   r   r   rI   rb   r   r   ru   rz   r   r   Listr   r   r#   r(   r(   r(   r)   r      sF    
&
		r   c                   @   s   e Zd ZejZdeddfddZede	dd fddZ
edefd	d
ZedefddZdefddZdedefddZdefddZdefddZdS )r   r&   r    Nc                 C   s
   || _ d S r!   Z_digest)r0   r&   r(   r(   r)   r@   #  r{   zSubjectKeyIdentifier.__init__r   c                 C   s   | t |S r!   r   )r   r   r(   r(   r)   from_public_key&  s   z$SubjectKeyIdentifier.from_public_keyc                 C   r|   r!   r   r/   r(   r(   r)   r&   ,  r~   zSubjectKeyIdentifier.digestc                 C   r|   r!   r   r/   r(   r(   r)   r   0  r~   z#SubjectKeyIdentifier.key_identifierc                 C   ra   )Nz$<SubjectKeyIdentifier(digest={0!r})>)rN   r&   r/   r(   r(   r)   rb   4  rc   zSubjectKeyIdentifier.__repr__rq   c                 C   s   t |tstS t| j|jS r!   )r"   r   rs   r   Zbytes_eqr&   rt   r(   r(   r)   ru   7  s   
zSubjectKeyIdentifier.__eq__c                 C   rw   r!   )ry   r&   r/   r(   r(   r)   rz   =  r{   zSubjectKeyIdentifier.__hash__c                 C   r   r!   r   r/   r(   r(   r)   r#   @  r{   z!SubjectKeyIdentifier.public_bytes)rF   rG   rH   r   ZSUBJECT_KEY_IDENTIFIERr=   rR   r@   r   r
   r   r   r&   r   rI   rb   r   r   ru   r8   rz   r#   r(   r(   r(   r)   r      s"    r   c                   @   t   e Zd ZejZdejd ddfddZe	d\Z
ZZdefdd	Zd
edefddZdefddZdefddZdS )AuthorityInformationAccessdescriptionsAccessDescriptionr    Nc                 C   ,   t |}tdd |D std|| _d S )Nc                 s   r   r!   r"   r   r   r(   r(   r)   r   K      z6AuthorityInformationAccess.__init__.<locals>.<genexpr>@Every item in the descriptions list must be an AccessDescriptionrW   r   r^   _descriptionsr0   r   r(   r(   r)   r@   G     
z#AuthorityInformationAccess.__init__r   c                 C   ra   )Nz <AuthorityInformationAccess({})>rN   r   r/   r(   r(   r)   rb   U  rc   z#AuthorityInformationAccess.__repr__rq   c                 C   rr   r!   )r"   r   rs   r   rt   r(   r(   r)   ru   X  rv   z!AuthorityInformationAccess.__eq__c                 C      t t| jS r!   ry   r   r   r/   r(   r(   r)   rz   ^  r3   z#AuthorityInformationAccess.__hash__c                 C   r   r!   r   r/   r(   r(   r)   r#   a  r{   z'AuthorityInformationAccess.public_bytes)rF   rG   rH   r   ZAUTHORITY_INFORMATION_ACCESSr=   rO   rd   r@   r9   rf   rg   rh   rI   rb   r   r   ru   r8   rz   rR   r#   r(   r(   r(   r)   r   D      
r   c                   @   r   )SubjectInformationAccessr   r   r    Nc                 C   r   )Nc                 s   r   r!   r   r   r(   r(   r)   r   l  r   z4SubjectInformationAccess.__init__.<locals>.<genexpr>r   r   r   r(   r(   r)   r@   h  r   z!SubjectInformationAccess.__init__r   c                 C   ra   )Nz<SubjectInformationAccess({})>r   r/   r(   r(   r)   rb   v  rc   z!SubjectInformationAccess.__repr__rq   c                 C   rr   r!   )r"   r   rs   r   rt   r(   r(   r)   ru   y  rv   zSubjectInformationAccess.__eq__c                 C   r   r!   r   r/   r(   r(   r)   rz     r3   z!SubjectInformationAccess.__hash__c                 C   r   r!   r   r/   r(   r(   r)   r#     r{   z%SubjectInformationAccess.public_bytes)rF   rG   rH   r   ZSUBJECT_INFORMATION_ACCESSr=   rO   rd   r@   r9   rf   rg   rh   rI   rb   r   r   ru   r8   rz   rR   r#   r(   r(   r(   r)   r   e  r   r   c                   @   st   e Zd ZdededdfddZdefddZd	ede	fd
dZ
defddZedefddZedefddZdS )r   access_methodaccess_locationr    Nc                 C   s4   t |ts	tdt |tstd|| _|| _d S )Nz)access_method must be an ObjectIdentifierz%access_location must be a GeneralName)r"   r   r^   r   _access_method_access_location)r0   r   r   r(   r(   r)   r@     s   


zAccessDescription.__init__c                 C   r   )NzY<AccessDescription(access_method={0.access_method}, access_location={0.access_location})>r   r/   r(   r(   r)   rb        zAccessDescription.__repr__rq   c                 C   &   t |tstS | j|jko| j|jkS r!   )r"   r   rs   r   r   rt   r(   r(   r)   ru     
   

zAccessDescription.__eq__c                 C      t | j| jfS r!   )ry   r   r   r/   r(   r(   r)   rz        zAccessDescription.__hash__c                 C   r|   r!   )r   r/   r(   r(   r)   r     r~   zAccessDescription.access_methodc                 C   r|   r!   )r   r/   r(   r(   r)   r     r~   z!AccessDescription.access_location)rF   rG   rH   r   r   r@   rI   rb   r   r   ru   r8   rz   r   r   r   r(   r(   r(   r)   r     s    
	r   c                   @   s   e Zd ZejZdedeje	 ddfddZ
edefddZedeje	 fd	d
ZdefddZdedefddZde	fddZdefddZdS )BasicConstraintscapath_lengthr    Nc                 C   sX   t |ts	td|d ur|std|d ur$t |tr |dk r$td|| _|| _d S )Nzca must be a boolean valuez)path_length must be None when ca is Falser   z2path_length must be a non-negative integer or None)r"   r   r^   r   r8   _ca_path_length)r0   r   r   r(   r(   r)   r@     s   

zBasicConstraints.__init__c                 C   r|   r!   )r   r/   r(   r(   r)   r     r~   zBasicConstraints.cac                 C   r|   r!   )r   r/   r(   r(   r)   r     r~   zBasicConstraints.path_lengthc                 C   r   )Nz:<BasicConstraints(ca={0.ca}, path_length={0.path_length})>r   r/   r(   r(   r)   rb     r   zBasicConstraints.__repr__rq   c                 C   r   r!   )r"   r   rs   r   r   rt   r(   r(   r)   ru        
zBasicConstraints.__eq__c                 C   r   r!   )ry   r   r   r/   r(   r(   r)   rz     r   zBasicConstraints.__hash__c                 C   r   r!   r   r/   r(   r(   r)   r#     r{   zBasicConstraints.public_bytes)rF   rG   rH   r   ZBASIC_CONSTRAINTSr=   r   rO   r   r8   r@   r   r   r   rI   rb   r   ru   rz   rR   r#   r(   r(   r(   r)   r     s    r   c                   @   sr   e Zd ZejZdeddfddZedefddZ	de
defd	d
ZdefddZdefddZdefddZdS )DeltaCRLIndicatorrj   r    Nc                 C   rk   rl   rm   ro   r(   r(   r)   r@     rp   zDeltaCRLIndicator.__init__c                 C   r|   r!   r}   r/   r(   r(   r)   rj     r~   zDeltaCRLIndicator.crl_numberrq   c                 C   rr   r!   )r"   r   rs   rj   rt   r(   r(   r)   ru     rv   zDeltaCRLIndicator.__eq__c                 C   rw   r!   rx   r/   r(   r(   r)   rz     r{   zDeltaCRLIndicator.__hash__c                 C   r   )Nz.<DeltaCRLIndicator(crl_number={0.crl_number})>r   r/   r(   r(   r)   rb     r{   zDeltaCRLIndicator.__repr__c                 C   r   r!   r   r/   r(   r(   r)   r#     r{   zDeltaCRLIndicator.public_bytes)rF   rG   rH   r   ZDELTA_CRL_INDICATORr=   r8   r@   r   rj   r   r   ru   rz   rI   rb   rR   r#   r(   r(   r(   r)   r     s    r   c                   @   r   )CRLDistributionPointsdistribution_pointsDistributionPointr    Nc                 C   r   )Nc                 s   r   r!   r"   r   r   r(   r(   r)   r      r   z1CRLDistributionPoints.__init__.<locals>.<genexpr>?distribution_points must be a list of DistributionPoint objectsrW   r   r^   _distribution_pointsr0   r   r(   r(   r)   r@        
zCRLDistributionPoints.__init__r   c                 C   ra   )Nz<CRLDistributionPoints({})>rN   r   r/   r(   r(   r)   rb     rc   zCRLDistributionPoints.__repr__rq   c                 C   rr   r!   )r"   r   rs   r   rt   r(   r(   r)   ru     rv   zCRLDistributionPoints.__eq__c                 C   r   r!   ry   r   r   r/   r(   r(   r)   rz     r3   zCRLDistributionPoints.__hash__c                 C   r   r!   r   r/   r(   r(   r)   r#     r{   z"CRLDistributionPoints.public_bytes)rF   rG   rH   r   ZCRL_DISTRIBUTION_POINTSr=   rO   rd   r@   r9   rf   rg   rh   rI   rb   r   r   ru   r8   rz   rR   r#   r(   r(   r(   r)   r         

r   c                   @   r   )FreshestCRLr   r   r    Nc                 C   r   )Nc                 s   r   r!   r   r   r(   r(   r)   r   %  r   z'FreshestCRL.__init__.<locals>.<genexpr>r   r   r   r(   r(   r)   r@   !  r   zFreshestCRL.__init__r   c                 C   ra   )Nz<FreshestCRL({})>r   r/   r(   r(   r)   rb   3  rc   zFreshestCRL.__repr__rq   c                 C   rr   r!   )r"   r   rs   r   rt   r(   r(   r)   ru   6  rv   zFreshestCRL.__eq__c                 C   r   r!   r   r/   r(   r(   r)   rz   <  r3   zFreshestCRL.__hash__c                 C   r   r!   r   r/   r(   r(   r)   r#   ?  r{   zFreshestCRL.public_bytes)rF   rG   rH   r   ZFRESHEST_CRLr=   rO   rd   r@   r9   rf   rg   rh   rI   rb   r   r   ru   r8   rz   rR   r#   r(   r(   r(   r)   r     r   r   c                
   @   s   e Zd Zdejeje  deje dejejd  dejeje  ddf
dd	Z	de
fd
dZdedefddZdefddZedejeje  fddZedeje fddZedejejd  fddZedejeje  fddZdS )r   	full_namerelative_namereasonsReasonFlags
crl_issuerr    Nc                 C   s   |r|rt d|d urt|}tdd |D std|r(t|ts(td|d ur=t|}tdd |D s=td|rQt|trMtdd |D sQtd	|ratj|v s]tj	|v rat d
|rm|sm|sm|smt d|| _
|| _|| _|| _d S )NzOYou cannot provide both full_name and relative_name, at least one must be None.c                 s   r   r!   r   r   r(   r(   r)   r   S  r   z-DistributionPoint.__init__.<locals>.<genexpr>z/full_name must be a list of GeneralName objectsz1relative_name must be a RelativeDistinguishedNamec                 s   r   r!   r   r   r(   r(   r)   r   `  r   z2crl_issuer must be None or a list of general namesc                 s   r   r!   r"   r   r   r(   r(   r)   r   g  r   z0reasons must be None or frozenset of ReasonFlagszLunspecified and remove_from_crl are not valid reasons in a DistributionPointzPYou must supply crl_issuer, full_name, or relative_name when reasons is not None)r   rW   r   r^   r"   r   	frozensetr   unspecifiedremove_from_crl
_full_name_relative_name_reasons_crl_issuer)r0   r   r   r   r   r(   r(   r)   r@   D  sV   

zDistributionPoint.__init__c                 C   r   )Nz}<DistributionPoint(full_name={0.full_name}, relative_name={0.relative_name}, reasons={0.reasons}, crl_issuer={0.crl_issuer})>r   r/   r(   r(   r)   rb        zDistributionPoint.__repr__rq   c                 C   s>   t |tstS | j|jko| j|jko| j|jko| j|jkS r!   )r"   r   rs   r   r   r   r   rt   r(   r(   r)   ru     s   



zDistributionPoint.__eq__c                 C   sH   | j d urt| j }nd }| jd urt| j}nd }t|| j| j|fS r!   )r   r   r   ry   r   r   )r0   fnr   r(   r(   r)   rz     s   

zDistributionPoint.__hash__c                 C   r|   r!   r   r/   r(   r(   r)   r     r~   zDistributionPoint.full_namec                 C   r|   r!   r   r/   r(   r(   r)   r     r~   zDistributionPoint.relative_namec                 C   r|   r!   )r   r/   r(   r(   r)   r     r~   zDistributionPoint.reasonsc                 C   r|   r!   )r   r/   r(   r(   r)   r     r~   zDistributionPoint.crl_issuer)rF   rG   rH   rO   r   rd   r   r   	FrozenSetr@   rI   rb   r   r   ru   r8   rz   r   r   r   r   r   r   r(   r(   r(   r)   r   C  s.    
; r   c                   @   s4   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdS )r   r   ZkeyCompromiseZcACompromiseZaffiliationChanged
supersededZcessationOfOperationZcertificateHoldZprivilegeWithdrawnZaACompromiseZremoveFromCRLN)rF   rG   rH   r   key_compromiseca_compromiseaffiliation_changedr   cessation_of_operationcertificate_holdprivilege_withdrawnaa_compromiser   r(   r(   r(   r)   r     s    r   )                        r   r   r   r   r   r   r   r   c                   @   s   e Zd ZejZdeje deje ddfddZ	de
fddZd	edefd
dZdefddZedeje fddZedeje fddZdefddZdS )PolicyConstraintsrequire_explicit_policyinhibit_policy_mappingr    Nc                 C   s\   |d urt |tstd|d urt |tstd|d u r&|d u r&td|| _|| _d S )Nz>require_explicit_policy must be a non-negative integer or Nonez=inhibit_policy_mapping must be a non-negative integer or NonezSAt least one of require_explicit_policy and inhibit_policy_mapping must not be None)r"   r8   r^   r   _require_explicit_policy_inhibit_policy_mapping)r0   r   r   r(   r(   r)   r@     s$   


zPolicyConstraints.__init__c                 C   r   )Nz{<PolicyConstraints(require_explicit_policy={0.require_explicit_policy}, inhibit_policy_mapping={0.inhibit_policy_mapping})>r   r/   r(   r(   r)   rb     r   zPolicyConstraints.__repr__rq   c                 C   r   r!   )r"   r   rs   r   r   rt   r(   r(   r)   ru   
  r   zPolicyConstraints.__eq__c                 C   r   r!   )ry   r   r   r/   r(   r(   r)   rz     s   
zPolicyConstraints.__hash__c                 C   r|   r!   )r   r/   r(   r(   r)   r     r~   z)PolicyConstraints.require_explicit_policyc                 C   r|   r!   )r   r/   r(   r(   r)   r     r~   z(PolicyConstraints.inhibit_policy_mappingc                 C   r   r!   r   r/   r(   r(   r)   r#      r{   zPolicyConstraints.public_bytes)rF   rG   rH   r   ZPOLICY_CONSTRAINTSr=   rO   r   r8   r@   rI   rb   r   r   ru   rz   r   r   r   rR   r#   r(   r(   r(   r)   r     s"    
	r   c                   @   r   )CertificatePoliciespoliciesPolicyInformationr    Nc                 C   r   )Nc                 s   r   r!   )r"   r   r   r(   r(   r)   r   )  r   z/CertificatePolicies.__init__.<locals>.<genexpr>z;Every item in the policies list must be a PolicyInformation)rW   r   r^   	_policies)r0   r   r(   r(   r)   r@   '     
zCertificatePolicies.__init__r   c                 C   ra   )Nz<CertificatePolicies({})>)rN   r   r/   r(   r(   r)   rb   3  rc   zCertificatePolicies.__repr__rq   c                 C   rr   r!   )r"   r   rs   r   rt   r(   r(   r)   ru   6  rv   zCertificatePolicies.__eq__c                 C   r   r!   )ry   r   r   r/   r(   r(   r)   rz   <  r3   zCertificatePolicies.__hash__c                 C   r   r!   r   r/   r(   r(   r)   r#   ?  r{   z CertificatePolicies.public_bytes)rF   rG   rH   r   ZCERTIFICATE_POLICIESr=   rO   rd   r@   r9   rf   rg   rh   rI   rb   r   r   ru   r8   rz   rR   r#   r(   r(   r(   r)   r   $  s    
r   c                   @   s   e Zd Zdedejejejedf   ddfddZ	defdd	Z
d
edefddZdefddZedefddZedejejejedf   fddZdS )r   policy_identifierpolicy_qualifiers
UserNoticer    Nc                 C   sL   t |ts	td|| _|d ur!t|}tdd |D s!td|| _d S )Nz-policy_identifier must be an ObjectIdentifierc                 s   s    | ]
}t |ttfV  qd S r!   )r"   rI   r  r   r(   r(   r)   r   R  s    
z-PolicyInformation.__init__.<locals>.<genexpr>zMpolicy_qualifiers must be a list of strings and/or UserNotice objects or None)r"   r   r^   _policy_identifierrW   r   _policy_qualifiers)r0   r  r  r(   r(   r)   r@   D  s   

zPolicyInformation.__init__c                 C   r   )Nze<PolicyInformation(policy_identifier={0.policy_identifier}, policy_qualifiers={0.policy_qualifiers})>r   r/   r(   r(   r)   rb   \  r   zPolicyInformation.__repr__rq   c                 C   r   r!   )r"   r   rs   r  r  rt   r(   r(   r)   ru   b  r   zPolicyInformation.__eq__c                 C   s(   | j d urt| j }nd }t| j|fS r!   )r  r   ry   r  )r0   Zpqr(   r(   r)   rz   k  s
   
zPolicyInformation.__hash__c                 C   r|   r!   )r  r/   r(   r(   r)   r  u  r~   z#PolicyInformation.policy_identifierc                 C   r|   r!   )r  r/   r(   r(   r)   r  y  r   z#PolicyInformation.policy_qualifiers)rF   rG   rH   r   rO   r   rd   UnionrI   r@   rb   r   r   ru   r8   rz   r   r  r   r  r(   r(   r(   r)   r   C  s&    
	
r   c                   @   s   e Zd Zdejd deje ddfddZdefdd	Zd
ede	fddZ
defddZedejd fddZedeje fddZdS )r  notice_referenceNoticeReferenceexplicit_textr    Nc                 C   s&   |rt |tstd|| _|| _d S )Nz2notice_reference must be None or a NoticeReference)r"   r  r^   _notice_reference_explicit_text)r0   r  r	  r(   r(   r)   r@     s   
zUserNotice.__init__c                 C   r   )NzV<UserNotice(notice_reference={0.notice_reference}, explicit_text={0.explicit_text!r})>r   r/   r(   r(   r)   rb     r   zUserNotice.__repr__rq   c                 C   r   r!   )r"   r  rs   r  r	  rt   r(   r(   r)   ru     r   zUserNotice.__eq__c                 C   r   r!   )ry   r  r	  r/   r(   r(   r)   rz     r   zUserNotice.__hash__c                 C   r|   r!   )r
  r/   r(   r(   r)   r    r~   zUserNotice.notice_referencec                 C   r|   r!   )r  r/   r(   r(   r)   r	    r~   zUserNotice.explicit_text)rF   rG   rH   rO   r   rI   r@   rb   r   r   ru   r8   rz   r   r  r	  r(   r(   r(   r)   r    s    
	r  c                   @   s   e Zd Zdeje deje ddfddZdefddZ	d	e
defd
dZdefddZedeje fddZedeje fddZdS )r  organizationnotice_numbersr    Nc                 C   s2   || _ t|}tdd |D std|| _d S )Nc                 s   r   r!   )r"   r8   r   r(   r(   r)   r     r   z+NoticeReference.__init__.<locals>.<genexpr>z)notice_numbers must be a list of integers)_organizationrW   r   r^   _notice_numbers)r0   r  r  r(   r(   r)   r@     s
   
zNoticeReference.__init__c                 C   r   )NzU<NoticeReference(organization={0.organization!r}, notice_numbers={0.notice_numbers})>r   r/   r(   r(   r)   rb     r   zNoticeReference.__repr__rq   c                 C   r   r!   )r"   r  rs   r  r  rt   r(   r(   r)   ru     r   zNoticeReference.__eq__c                 C   s   t | jt| jfS r!   )ry   r  r   r  r/   r(   r(   r)   rz        zNoticeReference.__hash__c                 C   r|   r!   )r  r/   r(   r(   r)   r    r~   zNoticeReference.organizationc                 C   r|   r!   )r  r/   r(   r(   r)   r    r~   zNoticeReference.notice_numbers)rF   rG   rH   rO   r   rI   rd   r8   r@   rb   r   r   ru   rz   r   r  r   r  r(   r(   r(   r)   r    s    
	r  c                   @   st   e Zd ZejZdeje ddfddZ	e
d\ZZZdefddZd	edefd
dZdefddZdefddZdS )ExtendedKeyUsageusagesr    Nc                 C   r   )Nc                 s   r   r!   )r"   r   r   r(   r(   r)   r     r   z,ExtendedKeyUsage.__init__.<locals>.<genexpr>z9Every item in the usages list must be an ObjectIdentifier)rW   r   r^   _usages)r0   r  r(   r(   r)   r@     s   
zExtendedKeyUsage.__init__r  c                 C   ra   )Nz<ExtendedKeyUsage({})>)rN   r  r/   r(   r(   r)   rb     rc   zExtendedKeyUsage.__repr__rq   c                 C   rr   r!   )r"   r  rs   r  rt   r(   r(   r)   ru     rv   zExtendedKeyUsage.__eq__c                 C   r   r!   )ry   r   r  r/   r(   r(   r)   rz     r3   zExtendedKeyUsage.__hash__c                 C   r   r!   r   r/   r(   r(   r)   r#     r{   zExtendedKeyUsage.public_bytes)rF   rG   rH   r   ZEXTENDED_KEY_USAGEr=   rO   rd   r   r@   r9   rf   rg   rh   rI   rb   r   r   ru   r8   rz   rR   r#   r(   r(   r(   r)   r    s    	r  c                   @   N   e Zd ZejZdedefddZde	fddZ
defddZdefd	d
ZdS )OCSPNoCheckrq   r    c                 C      t |tstS dS NT)r"   r  rs   rt   r(   r(   r)   ru        
zOCSPNoCheck.__eq__c                 C      t tS r!   )ry   r  r/   r(   r(   r)   rz        zOCSPNoCheck.__hash__c                 C      dS )Nz<OCSPNoCheck()>r(   r/   r(   r(   r)   rb        zOCSPNoCheck.__repr__c                 C   r   r!   r   r/   r(   r(   r)   r#      r{   zOCSPNoCheck.public_bytesN)rF   rG   rH   r   ZOCSP_NO_CHECKr=   r   r   ru   r8   rz   rI   rb   rR   r#   r(   r(   r(   r)   r        r  c                   @   r  )PrecertPoisonrq   r    c                 C   r  r  )r"   r  rs   rt   r(   r(   r)   ru     r  zPrecertPoison.__eq__c                 C   r  r!   )ry   r  r/   r(   r(   r)   rz     r  zPrecertPoison.__hash__c                 C   r  )Nz<PrecertPoison()>r(   r/   r(   r(   r)   rb     r  zPrecertPoison.__repr__c                 C   r   r!   r   r/   r(   r(   r)   r#     r{   zPrecertPoison.public_bytesN)rF   rG   rH   r   ZPRECERT_POISONr=   r   r   ru   r8   rz   rI   rb   rR   r#   r(   r(   r(   r)   r    r  r  c                   @   r   )
TLSFeaturefeaturesTLSFeatureTyper    Nc                 C   s8   t |}tdd |D rt|dkrtd|| _d S )Nc                 s   r   r!   )r"   r!  r   r(   r(   r)   r     r   z&TLSFeature.__init__.<locals>.<genexpr>r   z@features must be a list of elements from the TLSFeatureType enum)rW   r   r-   r^   	_features)r0   r   r(   r(   r)   r@     s   

zTLSFeature.__init__r"  c                 C   r   )Nz$<TLSFeature(features={0._features})>r   r/   r(   r(   r)   rb   )  r{   zTLSFeature.__repr__rq   c                 C   rr   r!   )r"   r  rs   r"  rt   r(   r(   r)   ru   ,  rv   zTLSFeature.__eq__c                 C   r   r!   )ry   r   r"  r/   r(   r(   r)   rz   2  r3   zTLSFeature.__hash__c                 C   r   r!   r   r/   r(   r(   r)   r#   5  r{   zTLSFeature.public_bytes)rF   rG   rH   r   ZTLS_FEATUREr=   rO   rd   r@   r9   rf   rg   rh   rI   rb   r   r   ru   r8   rz   rR   r#   r(   r(   r(   r)   r    s    r  c                   @   s   e Zd ZdZdZdS )r!  r      N)rF   rG   rH   Zstatus_requestZstatus_request_v2r(   r(   r(   r)   r!  9  s    r!  c                 C   s   i | ]}|j |qS r(   r_   r   r(   r(   r)   
<dictcomp>D      r%  c                   @   sr   e Zd ZejZdeddfddZdefddZ	de
defd	d
ZdefddZedefddZdefddZdS )InhibitAnyPolicy
skip_certsr    Nc                 C   s,   t |ts	td|dk rtd|| _d S )Nzskip_certs must be an integerr   z)skip_certs must be a non-negative integer)r"   r8   r^   r   _skip_certs)r0   r(  r(   r(   r)   r@   J  s
   

zInhibitAnyPolicy.__init__c                 C   r   )Nz-<InhibitAnyPolicy(skip_certs={0.skip_certs})>r   r/   r(   r(   r)   rb   S  r{   zInhibitAnyPolicy.__repr__rq   c                 C   rr   r!   )r"   r'  rs   r(  rt   r(   r(   r)   ru   V  rv   zInhibitAnyPolicy.__eq__c                 C   rw   r!   )ry   r(  r/   r(   r(   r)   rz   \  r{   zInhibitAnyPolicy.__hash__c                 C   r|   r!   )r)  r/   r(   r(   r)   r(  _  r~   zInhibitAnyPolicy.skip_certsc                 C   r   r!   r   r/   r(   r(   r)   r#   c  r{   zInhibitAnyPolicy.public_bytes)rF   rG   rH   r   ZINHIBIT_ANY_POLICYr=   r8   r@   rI   rb   r   r   ru   rz   r   r(  rR   r#   r(   r(   r(   r)   r'  G  s    	r'  c                   @   s"  e Zd ZejZdedededededededed	ed
dfddZed
efddZ	ed
efddZ
ed
efddZed
efddZed
efddZed
efddZed
efddZed
efddZed
efddZd
efd d!Zd"ed
efd#d$Zd
efd%d&Zd
efd'd(ZdS ))KeyUsagedigital_signaturecontent_commitmentkey_enciphermentdata_enciphermentkey_agreementkey_cert_signcrl_signencipher_onlydecipher_onlyr    Nc
           
      C   sN   |s
|s|	r
t d|| _|| _|| _|| _|| _|| _|| _|| _|	| _	d S )NzKencipher_only and decipher_only can only be true when key_agreement is true)
r   _digital_signature_content_commitment_key_encipherment_data_encipherment_key_agreement_key_cert_sign	_crl_sign_encipher_only_decipher_only)
r0   r+  r,  r-  r.  r/  r0  r1  r2  r3  r(   r(   r)   r@   j  s   
zKeyUsage.__init__c                 C   r|   r!   )r4  r/   r(   r(   r)   r+    r~   zKeyUsage.digital_signaturec                 C   r|   r!   )r5  r/   r(   r(   r)   r,    r~   zKeyUsage.content_commitmentc                 C   r|   r!   )r6  r/   r(   r(   r)   r-    r~   zKeyUsage.key_enciphermentc                 C   r|   r!   )r7  r/   r(   r(   r)   r.    r~   zKeyUsage.data_enciphermentc                 C   r|   r!   )r8  r/   r(   r(   r)   r/    r~   zKeyUsage.key_agreementc                 C   r|   r!   )r9  r/   r(   r(   r)   r0    r~   zKeyUsage.key_cert_signc                 C   r|   r!   )r:  r/   r(   r(   r)   r1    r~   zKeyUsage.crl_signc                 C      | j std| jS )Nz7encipher_only is undefined unless key_agreement is true)r/  r   r;  r/   r(   r(   r)   r2    
   zKeyUsage.encipher_onlyc                 C   r=  )Nz7decipher_only is undefined unless key_agreement is true)r/  r   r<  r/   r(   r(   r)   r3    r>  zKeyUsage.decipher_onlyc                 C   s:   z| j }| j}W n ty   d}d}Y nw d| ||S )NFa-  <KeyUsage(digital_signature={0.digital_signature}, content_commitment={0.content_commitment}, key_encipherment={0.key_encipherment}, data_encipherment={0.data_encipherment}, key_agreement={0.key_agreement}, key_cert_sign={0.key_cert_sign}, crl_sign={0.crl_sign}, encipher_only={1}, decipher_only={2})>)r2  r3  r   rN   )r0   r2  r3  r(   r(   r)   rb     s   

zKeyUsage.__repr__rq   c                 C   sz   t |tstS | j|jko<| j|jko<| j|jko<| j|jko<| j|jko<| j|jko<| j	|j	ko<| j
|j
ko<| j|jkS r!   )r"   r*  rs   r+  r,  r-  r.  r/  r0  r1  r;  r<  rt   r(   r(   r)   ru     s&   








zKeyUsage.__eq__c              
   C   s,   t | j| j| j| j| j| j| j| j| j	f	S r!   )
ry   r+  r,  r-  r.  r/  r0  r1  r;  r<  r/   r(   r(   r)   rz     s   zKeyUsage.__hash__c                 C   r   r!   r   r/   r(   r(   r)   r#     r{   zKeyUsage.public_bytes)rF   rG   rH   r   Z	KEY_USAGEr=   r   r@   r   r+  r,  r-  r.  r/  r0  r1  r2  r3  rI   rb   r   ru   r8   rz   rR   r#   r(   r(   r(   r)   r*  g  sZ    	

r*  c                   @   s   e Zd ZejZdejeje	  dejeje	  ddfddZ
dedefdd	Zd
eje	 ddfddZdefddZdefddZedejeje	  fddZedejeje	  fddZdefddZdS )NameConstraintspermitted_subtreesexcluded_subtreesr    Nc                 C   s   |d ur t |}|stdtdd |D std| | |d ur@t |}|s.tdtdd |D s;td| | |d u rL|d u rLtd|| _|| _d S )	Nz3permitted_subtrees must be a non-empty list or Nonec                 s   r   r!   r   r   r(   r(   r)   r     r   z+NameConstraints.__init__.<locals>.<genexpr>z@permitted_subtrees must be a list of GeneralName objects or Nonez2excluded_subtrees must be a non-empty list or Nonec                 s   r   r!   r   r   r(   r(   r)   r     r   z?excluded_subtrees must be a list of GeneralName objects or NonezIAt least one of permitted_subtrees and excluded_subtrees must not be None)rW   r   r   r^   _validate_ip_name_permitted_subtrees_excluded_subtrees)r0   r@  rA  r(   r(   r)   r@     s8   


zNameConstraints.__init__rq   c                 C   r   r!   )r"   r?  rs   rA  r@  rt   r(   r(   r)   ru     r   zNameConstraints.__eq__treec                 C   s   t dd |D rtdd S )Nc                 s   s0    | ]}t |tot |jtjtjf V  qd S r!   )r"   r   r_   	ipaddressIPv4NetworkIPv6Network)r   namer(   r(   r)   r   #  s    

z4NameConstraints._validate_ip_name.<locals>.<genexpr>zGIPAddress name constraints must be an IPv4Network or IPv6Network object)anyr^   )r0   rE  r(   r(   r)   rB  "  s   z!NameConstraints._validate_ip_namec                 C   r   )Nze<NameConstraints(permitted_subtrees={0.permitted_subtrees}, excluded_subtrees={0.excluded_subtrees})>r   r/   r(   r(   r)   rb   /  r   zNameConstraints.__repr__c                 C   s@   | j d urt| j }nd }| jd urt| j}nd }t||fS r!   )r@  r   rA  ry   )r0   Zpsesr(   r(   r)   rz   5  s   

zNameConstraints.__hash__c                 C   r|   r!   )rC  r/   r(   r(   r)   r@  F  r   z"NameConstraints.permitted_subtreesc                 C   r|   r!   )rD  r/   r(   r(   r)   rA  L  r   z!NameConstraints.excluded_subtreesc                 C   r   r!   r   r/   r(   r(   r)   r#   R  r{   zNameConstraints.public_bytes)rF   rG   rH   r   ZNAME_CONSTRAINTSr=   rO   r   rd   r   r@   r   r   ru   rB  rI   rb   r8   rz   r   r   r@  rA  rR   r#   r(   r(   r(   r)   r?    s,    
*	r?  c                   @   s   e Zd ZdedededdfddZedefdd	Zedefd
dZ	edefddZ
defddZdedefddZdefddZdS )	Extensionr=   criticalr_   r    Nc                 C   s:   t |ts	tdt |tstd|| _|| _|| _d S )Nz2oid argument must be an ObjectIdentifier instance.z critical must be a boolean value)r"   r   r^   r   _oid	_critical_value)r0   r=   rM  r_   r(   r(   r)   r@   W  s   


zExtension.__init__c                 C   r|   r!   rN  r/   r(   r(   r)   r=   f  r~   zExtension.oidc                 C   r|   r!   )rO  r/   r(   r(   r)   rM  j  r~   zExtension.criticalc                 C   r|   r!   rP  r/   r(   r(   r)   r_   n  r~   zExtension.valuec                 C   r   )Nz@<Extension(oid={0.oid}, critical={0.critical}, value={0.value})>r   r/   r(   r(   r)   rb   r  r   zExtension.__repr__rq   c                 C   r   r!   )r"   rL  rs   r=   rM  r_   rt   r(   r(   r)   ru   x  s   


zExtension.__eq__c                 C   s   t | j| j| jfS r!   )ry   r=   rM  r_   r/   r(   r(   r)   rz     r  zExtension.__hash__)rF   rG   rH   r   r   r   r@   r   r=   rM  r_   rI   rb   r   ru   r8   rz   r(   r(   r(   r)   rL  V  s&    

rL  c                
   @   s  e Zd Zdeje ddfddZed\ZZ	Z
ejdejeje eje eje f deje fdd	Zejdeje deje fd
d	Zejdeje deje fdd	Zejdeje deje fdd	Zejdeje deje fdd	Zdejeje eje eje eje eje eje eje f dejeje eje eje eje eje f fdd	ZdefddZdedefddZdefddZ dS )GeneralNamesgeneral_namesr    Nc                 C   r   )Nc                 s   r   r!   r   r   r(   r(   r)   r     r   z(GeneralNames.__init__.<locals>.<genexpr>z^Every item in the general_names list must be an object conforming to the GeneralName interface)rW   r   r^   _general_namesr0   rT  r(   r(   r)   r@     r   zGeneralNames.__init__rU  typec                 C      d S r!   r(   r0   rW  r(   r(   r)   get_values_for_type     	z GeneralNames.get_values_for_typec                 C   rX  r!   r(   rY  r(   r(   r)   rZ       c                 C   rX  r!   r(   rY  r(   r(   r)   rZ    r\  c                 C   rX  r!   r(   rY  r(   r(   r)   rZ       c                 C   rX  r!   r(   rY  r(   r(   r)   rZ    r]  c                    s0    fdd| D } t krdd |D S t|S )Nc                 3   s    | ]
}t | r|V  qd S r!   )r"   r   irW  r(   r)   r     s    z3GeneralNames.get_values_for_type.<locals>.<genexpr>c                 S   s   g | ]}|j qS r(   r$  r^  r(   r(   r)   
<listcomp>  s    z4GeneralNames.get_values_for_type.<locals>.<listcomp>)r   rW   )r0   rW  Zobjsr(   r`  r)   rZ    s   c                 C   ra   )Nz<GeneralNames({})>rN   rU  r/   r(   r(   r)   rb     rc   zGeneralNames.__repr__rq   c                 C   rr   r!   )r"   rS  rs   rU  rt   r(   r(   r)   ru     rv   zGeneralNames.__eq__c                 C   r   r!   )ry   r   rU  r/   r(   r(   r)   rz     r3   zGeneralNames.__hash__)!rF   rG   rH   rO   rd   r   r@   r9   rf   rg   rh   overloadr  re   r   r   r   r   rI   rZ  r   r   r   r   r   r   r   rb   r   r   ru   r8   rz   r(   r(   r(   r)   rS    s|    


rS  c                
   @     e Zd ZejZdeje ddfddZ	e
d\ZZZejdejeje eje eje f deje fdd	Zejdeje deje fd
d	Zejdeje deje fdd	Zejdeje deje fdd	Zejdeje deje fdd	Zdejeje eje eje eje eje eje eje f dejeje eje eje eje eje f fdd	ZdefddZdede fddZ!de"fddZ#de$fddZ%dS )SubjectAlternativeNamerT  r    Nc                 C   rV   r!   rS  rU  rV  r(   r(   r)   r@     r3   zSubjectAlternativeName.__init__rU  rW  c                 C   rX  r!   r(   rY  r(   r(   r)   rZ    r[  z*SubjectAlternativeName.get_values_for_typec                 C   rX  r!   r(   rY  r(   r(   r)   rZ    r\  c                 C   rX  r!   r(   rY  r(   r(   r)   rZ    r\  c                 C   rX  r!   r(   rY  r(   r(   r)   rZ     r]  c                 C   rX  r!   r(   rY  r(   r(   r)   rZ    r]  c                 C      | j |S r!   rU  rZ  rY  r(   r(   r)   rZ       c                 C   ra   )Nz<SubjectAlternativeName({})>rb  r/   r(   r(   r)   rb      rc   zSubjectAlternativeName.__repr__rq   c                 C   rr   r!   )r"   re  rs   rU  rt   r(   r(   r)   ru   #  rv   zSubjectAlternativeName.__eq__c                 C   rw   r!   ry   rU  r/   r(   r(   r)   rz   )  r{   zSubjectAlternativeName.__hash__c                 C   r   r!   r   r/   r(   r(   r)   r#   ,  r{   z#SubjectAlternativeName.public_bytes)&rF   rG   rH   r   ZSUBJECT_ALTERNATIVE_NAMEr=   rO   rd   r   r@   r9   rf   rg   rh   rc  r  re   r   r   r   r   rI   rZ  r   r   r   r   r   r   r   rb   r   r   ru   r8   rz   rR   r#   r(   r(   r(   r)   re        

re  c                
   @   rd  )IssuerAlternativeNamerT  r    Nc                 C   rV   r!   rf  rV  r(   r(   r)   r@   3  r3   zIssuerAlternativeName.__init__rU  rW  c                 C   rX  r!   r(   rY  r(   r(   r)   rZ  8  r[  z)IssuerAlternativeName.get_values_for_typec                 C   rX  r!   r(   rY  r(   r(   r)   rZ  C  r\  c                 C   rX  r!   r(   rY  r(   r(   r)   rZ  J  r\  c                 C   rX  r!   r(   rY  r(   r(   r)   rZ  Q  r]  c                 C   rX  r!   r(   rY  r(   r(   r)   rZ  W  r]  c                 C   rg  r!   rh  rY  r(   r(   r)   rZ  ]  ri  c                 C   ra   )Nz<IssuerAlternativeName({})>rb  r/   r(   r(   r)   rb   q  rc   zIssuerAlternativeName.__repr__rq   c                 C   rr   r!   )r"   rl  rs   rU  rt   r(   r(   r)   ru   t  rv   zIssuerAlternativeName.__eq__c                 C   rw   r!   rj  r/   r(   r(   r)   rz   z  r{   zIssuerAlternativeName.__hash__c                 C   r   r!   r   r/   r(   r(   r)   r#   }  r{   z"IssuerAlternativeName.public_bytes)&rF   rG   rH   r   ZISSUER_ALTERNATIVE_NAMEr=   rO   rd   r   r@   r9   rf   rg   rh   rc  r  re   r   r   r   r   rI   rZ  r   r   r   r   r   r   r   rb   r   r   ru   r8   rz   rR   r#   r(   r(   r(   r)   rl  0  rk  rl  c                
   @   rd  )CertificateIssuerrT  r    Nc                 C   rV   r!   rf  rV  r(   r(   r)   r@     r3   zCertificateIssuer.__init__rU  rW  c                 C   rX  r!   r(   rY  r(   r(   r)   rZ    r[  z%CertificateIssuer.get_values_for_typec                 C   rX  r!   r(   rY  r(   r(   r)   rZ    r\  c                 C   rX  r!   r(   rY  r(   r(   r)   rZ    r\  c                 C   rX  r!   r(   rY  r(   r(   r)   rZ    r]  c                 C   rX  r!   r(   rY  r(   r(   r)   rZ    r]  c                 C   rg  r!   rh  rY  r(   r(   r)   rZ    ri  c                 C   ra   )Nz<CertificateIssuer({})>rb  r/   r(   r(   r)   rb     rc   zCertificateIssuer.__repr__rq   c                 C   rr   r!   )r"   rm  rs   rU  rt   r(   r(   r)   ru     rv   zCertificateIssuer.__eq__c                 C   rw   r!   rj  r/   r(   r(   r)   rz     r{   zCertificateIssuer.__hash__c                 C   r   r!   r   r/   r(   r(   r)   r#     r{   zCertificateIssuer.public_bytes)&rF   rG   rH   r   ZCERTIFICATE_ISSUERr=   rO   rd   r   r@   r9   rf   rg   rh   rc  r  re   r   r   r   r   rI   rZ  r   r   r   r   r   r   r   rb   r   r   ru   r8   rz   rR   r#   r(   r(   r(   r)   rm    rk  rm  c                   @   sr   e Zd ZejZdeddfddZdefddZ	de
defd	d
ZdefddZedefddZdefddZdS )	CRLReasonreasonr    Nc                 C   rk   )Nz*reason must be an element from ReasonFlags)r"   r   r^   _reason)r0   ro  r(   r(   r)   r@     rp   zCRLReason.__init__c                 C   ra   )Nz<CRLReason(reason={})>)rN   rp  r/   r(   r(   r)   rb     rc   zCRLReason.__repr__rq   c                 C   rr   r!   )r"   rn  rs   ro  rt   r(   r(   r)   ru     rv   zCRLReason.__eq__c                 C   rw   r!   )ry   ro  r/   r(   r(   r)   rz     r{   zCRLReason.__hash__c                 C   r|   r!   )rp  r/   r(   r(   r)   ro    r~   zCRLReason.reasonc                 C   r   r!   r   r/   r(   r(   r)   r#     r{   zCRLReason.public_bytes)rF   rG   rH   r   Z
CRL_REASONr=   r   r@   rI   rb   r   r   ru   r8   rz   r   ro  rR   r#   r(   r(   r(   r)   rn    s    rn  c                   @   sv   e Zd ZejZdejddfddZdefddZ	de
defd	d
ZdefddZedejfddZdefddZdS )InvalidityDateinvalidity_dater    Nc                 C   s   t |tjs
td|| _d S )Nz+invalidity_date must be a datetime.datetime)r"   datetimer^   _invalidity_date)r0   rr  r(   r(   r)   r@     s   
zInvalidityDate.__init__c                 C   ra   )Nz$<InvalidityDate(invalidity_date={})>)rN   rt  r/   r(   r(   r)   rb     s   zInvalidityDate.__repr__rq   c                 C   rr   r!   )r"   rq  rs   rr  rt   r(   r(   r)   ru     rv   zInvalidityDate.__eq__c                 C   rw   r!   )ry   rr  r/   r(   r(   r)   rz     r{   zInvalidityDate.__hash__c                 C   r|   r!   )rt  r/   r(   r(   r)   rr    r~   zInvalidityDate.invalidity_datec                 C   r   r!   r   r/   r(   r(   r)   r#   
  r{   zInvalidityDate.public_bytes)rF   rG   rH   r   ZINVALIDITY_DATEr=   rs  r@   rI   rb   r   r   ru   r8   rz   r   rr  rR   r#   r(   r(   r(   r)   rq    s    rq  c                   @   t   e Zd ZejZdeje ddfddZ	e
d\ZZZdefddZdefd	d
ZdedefddZdefddZdS ))PrecertificateSignedCertificateTimestampssigned_certificate_timestampsr    Nc                 C   r   )Nc                 s   r   r!   r"   r   r   Zsctr(   r(   r)   r     
    
zEPrecertificateSignedCertificateTimestamps.__init__.<locals>.<genexpr>YEvery item in the signed_certificate_timestamps list must be a SignedCertificateTimestamprW   r   r^   _signed_certificate_timestampsr0   rw  r(   r(   r)   r@        
z2PrecertificateSignedCertificateTimestamps.__init__r}  c                 C      d t| S )Nz/<PrecertificateSignedCertificateTimestamps({})>rN   rW   r/   r(   r(   r)   rb   &  s   z2PrecertificateSignedCertificateTimestamps.__repr__c                 C   r   r!   ry   r   r}  r/   r(   r(   r)   rz   +  r3   z2PrecertificateSignedCertificateTimestamps.__hash__rq   c                 C   rr   r!   )r"   rv  rs   r}  rt   r(   r(   r)   ru   .     
z0PrecertificateSignedCertificateTimestamps.__eq__c                 C   r   r!   r   r/   r(   r(   r)   r#   7  r{   z6PrecertificateSignedCertificateTimestamps.public_bytes)rF   rG   rH   r   Z%PRECERT_SIGNED_CERTIFICATE_TIMESTAMPSr=   rO   rd   r   r@   r9   rf   rg   rh   rI   rb   r8   rz   r   r   ru   rR   r#   r(   r(   r(   r)   rv    s     

	rv  c                   @   ru  )SignedCertificateTimestampsrw  r    Nc                 C   r   )Nc                 s   r   r!   rx  ry  r(   r(   r)   r   E  rz  z7SignedCertificateTimestamps.__init__.<locals>.<genexpr>r{  r|  r~  r(   r(   r)   r@   >  r  z$SignedCertificateTimestamps.__init__r}  c                 C   r  )Nz!<SignedCertificateTimestamps({})>r  r/   r(   r(   r)   rb   S  r3   z$SignedCertificateTimestamps.__repr__c                 C   r   r!   r  r/   r(   r(   r)   rz   V  r3   z$SignedCertificateTimestamps.__hash__rq   c                 C   rr   r!   )r"   r  rs   r}  rt   r(   r(   r)   ru   Y  r  z"SignedCertificateTimestamps.__eq__c                 C   r   r!   r   r/   r(   r(   r)   r#   b  r{   z(SignedCertificateTimestamps.public_bytes)rF   rG   rH   r   ZSIGNED_CERTIFICATE_TIMESTAMPSr=   rO   rd   r   r@   r9   rf   rg   rh   rI   rb   r8   rz   r   r   ru   rR   r#   r(   r(   r(   r)   r  ;  s     

	r  c                   @   sr   e Zd ZejZdeddfddZdede	fddZ
defd	d
ZdefddZedefddZdefddZdS )	OCSPNoncenoncer    Nc                 C   rk   )Nznonce must be bytes)r"   rR   r^   _nonce)r0   r  r(   r(   r)   r@   i  rp   zOCSPNonce.__init__rq   c                 C   rr   r!   )r"   r  rs   r  rt   r(   r(   r)   ru   o  rv   zOCSPNonce.__eq__c                 C   rw   r!   )ry   r  r/   r(   r(   r)   rz   u  r{   zOCSPNonce.__hash__c                 C   r   )Nz<OCSPNonce(nonce={0.nonce!r})>r   r/   r(   r(   r)   rb   x  r{   zOCSPNonce.__repr__c                 C   r|   r!   )r  r/   r(   r(   r)   r  {  r~   zOCSPNonce.noncec                 C   r   r!   r   r/   r(   r(   r)   r#     r{   zOCSPNonce.public_bytes)rF   rG   rH   r   ZNONCEr=   rR   r@   r   r   ru   r8   rz   rI   rb   r   r  r#   r(   r(   r(   r)   r  f  r   r  c                   @   s2  e Zd ZejZdejeje	  deje
 dededejeje  dededd	fd
dZdefddZdedefddZdefddZedejeje	  fddZedeje
 fddZedefddZedefddZedejeje  fddZedefddZedefdd Zdefd!d"Zd	S )#IssuingDistributionPointr   r   only_contains_user_certsonly_contains_ca_certsonly_some_reasonsindirect_crlonly_contains_attribute_certsr    Nc           	      C   s   |d urt |}|rt|trtdd |D std|r,tj|v s(tj|v r,tdt|t	r@t|t	r@t|t	r@t|t	sDtd||||g}t
dd |D dkrYtd	t|||||||gshtd
|| _|| _|| _|| _|| _|| _|| _d S )Nc                 s   r   r!   r   r   r(   r(   r)   r     r   z4IssuingDistributionPoint.__init__.<locals>.<genexpr>z:only_some_reasons must be None or frozenset of ReasonFlagszTunspecified and remove_from_crl are not valid reasons in an IssuingDistributionPointzuonly_contains_user_certs, only_contains_ca_certs, indirect_crl and only_contains_attribute_certs must all be boolean.c                 S   s   g | ]}|r|qS r(   r(   r   r(   r(   r)   ra    r&  z5IssuingDistributionPoint.__init__.<locals>.<listcomp>r   zOnly one of the following can be set to True: only_contains_user_certs, only_contains_ca_certs, indirect_crl, only_contains_attribute_certszCannot create empty extension: if only_contains_user_certs, only_contains_ca_certs, indirect_crl, and only_contains_attribute_certs are all False, then either full_name, relative_name, or only_some_reasons must have a value.)rW   r"   r   r   r^   r   r   r   r   r   r-   rJ  _only_contains_user_certs_only_contains_ca_certs_indirect_crl_only_contains_attribute_certs_only_some_reasonsr   r   )	r0   r   r   r  r  r  r  r  Zcrl_constraintsr(   r(   r)   r@     st   

z!IssuingDistributionPoint.__init__c                 C   r   )NaG  <IssuingDistributionPoint(full_name={0.full_name}, relative_name={0.relative_name}, only_contains_user_certs={0.only_contains_user_certs}, only_contains_ca_certs={0.only_contains_ca_certs}, only_some_reasons={0.only_some_reasons}, indirect_crl={0.indirect_crl}, only_contains_attribute_certs={0.only_contains_attribute_certs})>r   r/   r(   r(   r)   rb     s   z!IssuingDistributionPoint.__repr__rq   c                 C   sb   t |tstS | j|jko0| j|jko0| j|jko0| j|jko0| j|jko0| j|jko0| j	|j	kS r!   )
r"   r  rs   r   r   r  r  r  r  r  rt   r(   r(   r)   ru     s"   





zIssuingDistributionPoint.__eq__c                 C   s$   t | j| j| j| j| j| j| jfS r!   )ry   r   r   r  r  r  r  r  r/   r(   r(   r)   rz     s   z!IssuingDistributionPoint.__hash__c                 C   r|   r!   r   r/   r(   r(   r)   r     r~   z"IssuingDistributionPoint.full_namec                 C   r|   r!   r   r/   r(   r(   r)   r     r~   z&IssuingDistributionPoint.relative_namec                 C   r|   r!   )r  r/   r(   r(   r)   r  	  r~   z1IssuingDistributionPoint.only_contains_user_certsc                 C   r|   r!   )r  r/   r(   r(   r)   r    r~   z/IssuingDistributionPoint.only_contains_ca_certsc                 C   r|   r!   )r  r/   r(   r(   r)   r    r   z*IssuingDistributionPoint.only_some_reasonsc                 C   r|   r!   )r  r/   r(   r(   r)   r    r~   z%IssuingDistributionPoint.indirect_crlc                 C   r|   r!   )r  r/   r(   r(   r)   r    r~   z6IssuingDistributionPoint.only_contains_attribute_certsc                 C   r   r!   r   r/   r(   r(   r)   r#     r{   z%IssuingDistributionPoint.public_bytes) rF   rG   rH   r   ZISSUING_DISTRIBUTION_POINTr=   rO   r   rd   r   r   r   r   r   r@   rI   rb   r   ru   r8   rz   r   r   r   r   r  r  r  r  r  rR   r#   r(   r(   r(   r)   r    sN    	
Sr  c                   @   s   e Zd ZdededdfddZedefddZedefd	d
Zde	fddZ
dedefddZdefddZdefddZdS )r]   r=   r_   r    Nc                 C   s"   t |ts	td|| _|| _d S )Nzoid must be an ObjectIdentifier)r"   r   r^   rN  rP  )r0   r=   r_   r(   r(   r)   r@   $  s   

zUnrecognizedExtension.__init__c                 C   r|   r!   rQ  r/   r(   r(   r)   r=   *  r~   zUnrecognizedExtension.oidc                 C   r|   r!   rR  r/   r(   r(   r)   r_   .  r~   zUnrecognizedExtension.valuec                 C   r   )Nz7<UnrecognizedExtension(oid={0.oid}, value={0.value!r})>r   r/   r(   r(   r)   rb   2  r   zUnrecognizedExtension.__repr__rq   c                 C   r   r!   )r"   r]   rs   r=   r_   rt   r(   r(   r)   ru   8  r   zUnrecognizedExtension.__eq__c                 C   r   r!   )ry   r=   r_   r/   r(   r(   r)   rz   >  r   zUnrecognizedExtension.__hash__c                 C   r|   r!   r$  r/   r(   r(   r)   r#   A  s   z"UnrecognizedExtension.public_bytes)rF   rG   rH   r   rR   r@   r   r=   r_   rI   rb   r   r   ru   r8   rz   r#   r(   r(   r(   r)   r]   #  s    r]   )gabcrs  r$   rF  rO   Zcryptographyr   Z"cryptography.hazmat.bindings._rustr   r   r   Zcryptography.hazmat.primitivesr   r   Z,cryptography.hazmat.primitives.asymmetric.ecr   Z-cryptography.hazmat.primitives.asymmetric.rsar   Z/cryptography.hazmat.primitives.asymmetric.typesr	   r
   Z*cryptography.x509.certificate_transparencyr   Zcryptography.x509.general_namer   r   r   r   r   r   r   r   r   Zcryptography.x509.namer   r   Zcryptography.x509.oidr   r   r   r   TypeVarr   rR   r*   rI   r9   	Exceptionr;   rL   ABCMetar   rT   ri   r   r   r   r   r   r   r   r   r   r   Enumr   r   r   r   r   r   r   r   r   Z_REASON_BIT_MAPPINGZ_CRLREASONFLAGSr   r   r   r  r  r  r  r  r  r!  Z_TLS_FEATURE_TYPE_TO_ENUMr'  r*  r?  GenericrL  rS  re  rl  rm  rn  rq  rv  r  r  r  r]   r(   r(   r(   r)   <module>   s   ,
'l$!!(.%%pA=+("  j0YQQQ-+ !