o
    9f)                    @  s0  d dl mZ 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}ddZ-d~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 d0d1 d1e3Z;G d2d3 d3e3Z<G d4d5 d5e3Z=G d6d7 d7e3Z>G d8d9 d9Z?G d:d; d;ej@ZAeAjBeAjCeAjDeAjEeAjFeAjGeAjHeAjId<ZJeAjBd=eAjCd>eAjDd?eAjEd@eAjFdAeAjGdBeAjHdCeAjIdDiZKG dEdF dFe3ZLG dGdH dHe3ZMG dIdJ dJZNG dKdL dLZOG dMdN dNZPG dOdP dPe3ZQG dQdR dRe3ZRG dSdT dTe3ZSG dUdV dVe3ZTG dWdX dXej@ZUdYdZ eUD ZVG d[d\ d\e3ZWG d]d^ d^e3ZXG d_d` d`e3ZYG dadb dbejZe, Z[G dcdd ddZ\G dedf dfe3Z]G dgdh dhe3Z^G didj dje3Z_G dkdl dle3Z`G dmdn dne3ZaG dodp dpe3ZbG dqdr dre3ZcG dsdt dte3ZdG dudv dve3ZeG dwdx dxe3ZfG dydz dze3ZgG d{d| d|e3ZhdS )    )annotationsN)utils)asn1)x509)constant_timeserialization)EllipticCurvePublicKey)RSAPublicKey)CertificateIssuerPublicKeyTypesCertificatePublicKeyTypes)SignedCertificateTimestamp)	DirectoryNameDNSNameGeneralName	IPAddress	OtherNameRegisteredID
RFC822NameUniformResourceIdentifier_IPAddressTypes)NameRelativeDistinguishedName)CRLEntryExtensionOIDExtensionOIDObjectIdentifierOCSPExtensionOIDExtensionTypeVarExtensionTypeT)ZboundZ	covariant
public_keyr   returnbytesc                 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hashlibZsha1digest)r   dataZ
serialized r'   <lib/python3.10/site-packages/cryptography/x509/extensions.py_key_identifier_from_public_key2   s    


r)   
field_namestrc                   s0   d	 fdd} fdd} fdd}|||fS )
Nr   intc                      t t|  S r!   )lengetattrselfr*   r'   r(   
len_methodK      z*_make_sequence_methods.<locals>.len_methodc                   r-   r!   )iterr/   r0   r2   r'   r(   iter_methodN   r4   z+_make_sequence_methods.<locals>.iter_methodc                   s   t |  | S r!   )r/   )r1   idxr2   r'   r(   getitem_methodQ   r4   z._make_sequence_methods.<locals>.getitem_methodr   r,   r'   )r*   r3   r6   r8   r'   r2   r(   _make_sequence_methodsJ   s   
r:   c                         e Zd Zd	 fddZ  ZS )
DuplicateExtensionmsgr+   oidr   r   Nonec                      t  | || _d S r!   super__init__r>   r1   r=   r>   	__class__r'   r(   rC   X      
zDuplicateExtension.__init__r=   r+   r>   r   r   r?   __name__
__module____qualname__rC   __classcell__r'   r'   rE   r(   r<   W       r<   c                      r;   )
ExtensionNotFoundr=   r+   r>   r   r   r?   c                   r@   r!   rA   rD   rE   r'   r(   rC   ^   rG   zExtensionNotFound.__init__rH   rI   r'   r'   rE   r(   rO   ]   rN   rO   c                   @  s    e Zd ZU ded< dddZdS )	r   z!typing.ClassVar[ObjectIdentifier]r>   r   r    c                 C  s   t d| )z7
        Serializes the extension type to DER.
        z3public_bytes is not implemented for extension type )NotImplementedErrorr0   r'   r'   r(   r#   f   s   zExtensionType.public_bytesNr   r    )rJ   rK   rL   __annotations__r#   r'   r'   r'   r(   r   c   s   
 )	metaclassc                   @  sB   e Zd ZdddZdd
dZdddZed\ZZZ	dddZ
dS )
Extensions
extensions)typing.Iterable[Extension[ExtensionType]]r   r?   c                 C     t || _d S r!   )list_extensions)r1   rU   r'   r'   r(   rC   p   s   zExtensions.__init__r>   r   Extension[ExtensionType]c                 C  s.   | D ]}|j |kr|  S qtd| d|)NNo  extension was found)r>   rO   )r1   r>   extr'   r'   r(   get_extension_for_oidu   s
   
z Extensions.get_extension_for_oidextclasstype[ExtensionTypeVar]Extension[ExtensionTypeVar]c                 C  sB   |t u rtd| D ]}t|j|r|  S q
td| d|j)Nz|UnrecognizedExtension can't be used with get_extension_for_class because more than one instance of the class may be present.r[   r\   )UnrecognizedExtension	TypeErrorr"   valuerO   r>   )r1   r_   r]   r'   r'   r(   get_extension_for_class~   s   z"Extensions.get_extension_for_classrY   r+   c                 C     d| j  dS )Nz<Extensions()>)rY   r0   r'   r'   r(   __repr__   r4   zExtensions.__repr__N)rU   rV   r   r?   )r>   r   r   rZ   )r_   r`   r   ra   r   r+   )rJ   rK   rL   rC   r^   re   r:   __len____iter____getitem__rh   r'   r'   r'   r(   rT   o   s    


	rT   c                   @  sR   e Zd ZejZdddZdd
dZdddZdddZ	e
dddZdddZdS )	CRLNumber
crl_numberr,   r   r?   c                 C     t |ts	td|| _d S Nzcrl_number must be an integerr"   r,   rc   _crl_numberr1   rn   r'   r'   r(   rC         

zCRLNumber.__init__otherobjectboolc                 C     t |tstS | j|jkS r!   )r"   rm   NotImplementedrn   r1   ru   r'   r'   r(   __eq__      
zCRLNumber.__eq__c                 C  
   t | jS r!   hashrn   r0   r'   r'   r(   __hash__      
zCRLNumber.__hash__r+   c                 C  rf   )Nz<CRLNumber(rg   rn   r0   r'   r'   r(   rh      r4   zCRLNumber.__repr__c                 C     | j S r!   rr   r0   r'   r'   r(   rn         zCRLNumber.crl_numberr    c                 C  
   t | S r!   	rust_x509Zencode_extension_valuer0   r'   r'   r(   r#      r   zCRLNumber.public_bytesNrn   r,   r   r?   ru   rv   r   rw   r9   ri   rQ   )rJ   rK   rL   r   Z
CRL_NUMBERr>   rC   r{   r   rh   propertyrn   r#   r'   r'   r'   r(   rm          



rm   c                   @  s   e Zd ZejZd)d	d
Zed*ddZed+ddZ	d,ddZ
d-ddZd.ddZed/ddZed0d!d"Zed1d#d$Zd2d&d'Zd(S )3AuthorityKeyIdentifierkey_identifierbytes | Noneauthority_cert_issuer#typing.Iterable[GeneralName] | Noneauthority_cert_serial_number
int | Noner   r?   c                 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)	
ValueErrorrX   allrc   r"   r,   _key_identifier_authority_cert_issuer_authority_cert_serial_number)r1   r   r   r   r'   r'   r(   rC      s*   

zAuthorityKeyIdentifier.__init__r   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_identifierr+   c                 C  s   d| j d| j d| j dS )Nz'<AuthorityKeyIdentifier(key_identifier=z, authority_cert_issuer=z, authority_cert_serial_number=rg   r   r0   r'   r'   r(   rh         
zAuthorityKeyIdentifier.__repr__ru   rv   rw   c                 C  2   t |tstS | j|jko| j|jko| j|jkS r!   )r"   r   ry   r   r   r   rz   r'   r'   r(   r{      s   

zAuthorityKeyIdentifier.__eq__r,   c                 C  s,   | j d u rd }nt| j }t| j|| jfS r!   )r   tupler   r   r   )r1   Zacir'   r'   r(   r     s   

zAuthorityKeyIdentifier.__hash__c                 C  r   r!   )r   r0   r'   r'   r(   r     r   z%AuthorityKeyIdentifier.key_identifierlist[GeneralName] | Nonec                 C  r   r!   )r   r0   r'   r'   r(   r        z,AuthorityKeyIdentifier.authority_cert_issuerc                 C  r   r!   )r   r0   r'   r'   r(   r     r   z3AuthorityKeyIdentifier.authority_cert_serial_numberr    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   z#AuthorityKeyIdentifier.public_bytesN)r   r   r   r   r   r   r   r?   )r   r
   r   r   )r   r   r   r   ri   r   r9   )r   r   r   r   r   r   rQ   )rJ   rK   rL   r   ZAUTHORITY_KEY_IDENTIFIERr>   rC   classmethodr   r   rh   r{   r   r   r   r   r   r#   r'   r'   r'   r(   r      s"    
&

	

	r   c                   @  sn   e Zd ZejZdddZedd	d
Ze	dddZ
e	dddZd ddZd!ddZd"ddZdddZdS )#r   r%   r    r   r?   c                 C  s
   || _ d S r!   Z_digest)r1   r%   r'   r'   r(   rC   "  r   zSubjectKeyIdentifier.__init__r   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   r0   r'   r'   r(   r%   +  r   zSubjectKeyIdentifier.digestc                 C  r   r!   r   r0   r'   r'   r(   r   /  r   z#SubjectKeyIdentifier.key_identifierr+   c                 C     d| j dS )Nz<SubjectKeyIdentifier(digest=rg   r   r0   r'   r'   r(   rh   3  r4   zSubjectKeyIdentifier.__repr__ru   rv   rw   c                 C  s   t |tstS t| j|jS r!   )r"   r   ry   r   Zbytes_eqr%   rz   r'   r'   r(   r{   6  s   
zSubjectKeyIdentifier.__eq__r,   c                 C  r}   r!   )r   r%   r0   r'   r'   r(   r   <  r   zSubjectKeyIdentifier.__hash__c                 C  r   r!   r   r0   r'   r'   r(   r#   ?  r   z!SubjectKeyIdentifier.public_bytesN)r%   r    r   r?   )r   r   r   r   rQ   ri   r   r9   )rJ   rK   rL   r   ZSUBJECT_KEY_IDENTIFIERr>   rC   r   r   r   r%   r   rh   r{   r   r#   r'   r'   r'   r(   r     s    



r   c                   @  R   e Zd ZejZdddZed\ZZ	Z
dd	d
ZdddZdddZdddZdS )AuthorityInformationAccessdescriptions"typing.Iterable[AccessDescription]r   r?   c                 C  ,   t |}tdd |D std|| _d S )Nc                 s  r   r!   r"   AccessDescriptionr   r'   r'   r(   r   J      z6AuthorityInformationAccess.__init__.<locals>.<genexpr>@Every item in the descriptions list must be an AccessDescriptionrX   r   rc   _descriptionsr1   r   r'   r'   r(   rC   F     
z#AuthorityInformationAccess.__init__r   r+   c                 C  rf   )Nz<AuthorityInformationAccess(rg   r   r0   r'   r'   r(   rh   T  r4   z#AuthorityInformationAccess.__repr__ru   rv   rw   c                 C  rx   r!   )r"   r   ry   r   rz   r'   r'   r(   r{   W  r|   z!AuthorityInformationAccess.__eq__r,   c                 C     t t| jS r!   r   r   r   r0   r'   r'   r(   r   ]  r4   z#AuthorityInformationAccess.__hash__r    c                 C  r   r!   r   r0   r'   r'   r(   r#   `  r   z'AuthorityInformationAccess.public_bytesNr   r   r   r?   ri   r   r9   rQ   )rJ   rK   rL   r   ZAUTHORITY_INFORMATION_ACCESSr>   rC   r:   rj   rk   rl   rh   r{   r   r#   r'   r'   r'   r(   r   C      



r   c                   @  r   )SubjectInformationAccessr   r   r   r?   c                 C  r   )Nc                 s  r   r!   r   r   r'   r'   r(   r   k  r   z4SubjectInformationAccess.__init__.<locals>.<genexpr>r   r   r   r'   r'   r(   rC   g  r   z!SubjectInformationAccess.__init__r   r+   c                 C  rf   )Nz<SubjectInformationAccess(rg   r   r0   r'   r'   r(   rh   u  r4   z!SubjectInformationAccess.__repr__ru   rv   rw   c                 C  rx   r!   )r"   r   ry   r   rz   r'   r'   r(   r{   x  r|   zSubjectInformationAccess.__eq__r,   c                 C  r   r!   r   r0   r'   r'   r(   r   ~  r4   z!SubjectInformationAccess.__hash__r    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   z%SubjectInformationAccess.public_bytesNr   ri   r   r9   rQ   )rJ   rK   rL   r   ZSUBJECT_INFORMATION_ACCESSr>   rC   r:   rj   rk   rl   rh   r{   r   r#   r'   r'   r'   r(   r   d  r   r   c                   @  P   e Zd ZdddZdd
dZdddZdddZedddZedddZ	dS )r   access_methodr   access_locationr   r   r?   c                 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   rc   r   _access_method_access_location)r1   r   r   r'   r'   r(   rC     s   


zAccessDescription.__init__r+   c                 C  
   d | S )NzY<AccessDescription(access_method={0.access_method}, access_location={0.access_location})>formatr0   r'   r'   r(   rh        zAccessDescription.__repr__ru   rv   rw   c                 C  &   t |tstS | j|jko| j|jkS r!   )r"   r   ry   r   r   rz   r'   r'   r(   r{     
   

zAccessDescription.__eq__r,   c                 C     t | j| jfS r!   )r   r   r   r0   r'   r'   r(   r        zAccessDescription.__hash__c                 C  r   r!   )r   r0   r'   r'   r(   r     r   zAccessDescription.access_methodc                 C  r   r!   )r   r0   r'   r'   r(   r     r   z!AccessDescription.access_locationN)r   r   r   r   r   r?   ri   r   r9   r   r   )r   r   )
rJ   rK   rL   rC   rh   r{   r   r   r   r   r'   r'   r'   r(   r         



	r   c                   @  s`   e Zd ZejZdddZedd	d
ZedddZ	dddZ
dddZd ddZd!ddZdS )"BasicConstraintscarw   path_lengthr   r   r?   c                 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"   rw   rc   r   r,   _ca_path_length)r1   r   r   r'   r'   r(   rC     s   

zBasicConstraints.__init__c                 C  r   r!   )r   r0   r'   r'   r(   r     r   zBasicConstraints.cac                 C  r   r!   )r   r0   r'   r'   r(   r     r   zBasicConstraints.path_lengthr+   c                 C  r   )Nz:<BasicConstraints(ca={0.ca}, path_length={0.path_length})>r   r0   r'   r'   r(   rh     r   zBasicConstraints.__repr__ru   rv   c                 C  r   r!   )r"   r   ry   r   r   rz   r'   r'   r(   r{        
zBasicConstraints.__eq__r,   c                 C  r   r!   )r   r   r   r0   r'   r'   r(   r     r   zBasicConstraints.__hash__r    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   zBasicConstraints.public_bytesN)r   rw   r   r   r   r?   r   rw   r   ri   r   r9   rQ   )rJ   rK   rL   r   ZBASIC_CONSTRAINTSr>   rC   r   r   r   rh   r{   r   r#   r'   r'   r'   r(   r     s    



r   c                   @  sR   e Zd ZejZdddZedddZdddZ	dddZ
dddZdddZdS )DeltaCRLIndicatorrn   r,   r   r?   c                 C  ro   rp   rq   rs   r'   r'   r(   rC     rt   zDeltaCRLIndicator.__init__c                 C  r   r!   r   r0   r'   r'   r(   rn     r   zDeltaCRLIndicator.crl_numberru   rv   rw   c                 C  rx   r!   )r"   r   ry   rn   rz   r'   r'   r(   r{     r|   zDeltaCRLIndicator.__eq__c                 C  r}   r!   r~   r0   r'   r'   r(   r     r   zDeltaCRLIndicator.__hash__r+   c                 C  rf   )Nz<DeltaCRLIndicator(crl_number=rg   r   r0   r'   r'   r(   rh     r4   zDeltaCRLIndicator.__repr__r    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   zDeltaCRLIndicator.public_bytesNr   r9   r   ri   rQ   )rJ   rK   rL   r   ZDELTA_CRL_INDICATORr>   rC   r   rn   r{   r   rh   r#   r'   r'   r'   r(   r     s    



r   c                   @  r   )CRLDistributionPointsdistribution_points"typing.Iterable[DistributionPoint]r   r?   c                 C  r   )Nc                 s  r   r!   r"   DistributionPointr   r'   r'   r(   r     r   z1CRLDistributionPoints.__init__.<locals>.<genexpr>?distribution_points must be a list of DistributionPoint objectsrX   r   rc   _distribution_pointsr1   r   r'   r'   r(   rC        
zCRLDistributionPoints.__init__r   r+   c                 C  rf   )Nz<CRLDistributionPoints(rg   r   r0   r'   r'   r(   rh     r4   zCRLDistributionPoints.__repr__ru   rv   rw   c                 C  rx   r!   )r"   r   ry   r   rz   r'   r'   r(   r{     r|   zCRLDistributionPoints.__eq__r,   c                 C  r   r!   r   r   r   r0   r'   r'   r(   r     r4   zCRLDistributionPoints.__hash__r    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   z"CRLDistributionPoints.public_bytesNr   r   r   r?   ri   r   r9   rQ   )rJ   rK   rL   r   ZCRL_DISTRIBUTION_POINTSr>   rC   r:   rj   rk   rl   rh   r{   r   r#   r'   r'   r'   r(   r         




r   c                   @  r   )FreshestCRLr   r   r   r?   c                 C  r   )Nc                 s  r   r!   r   r   r'   r'   r(   r   $  r   z'FreshestCRL.__init__.<locals>.<genexpr>r   r   r   r'   r'   r(   rC      r   zFreshestCRL.__init__r   r+   c                 C  rf   )Nz<FreshestCRL(rg   r   r0   r'   r'   r(   rh   2  r4   zFreshestCRL.__repr__ru   rv   rw   c                 C  rx   r!   )r"   r   ry   r   rz   r'   r'   r(   r{   5  r|   zFreshestCRL.__eq__r,   c                 C  r   r!   r   r0   r'   r'   r(   r   ;  r4   zFreshestCRL.__hash__r    c                 C  r   r!   r   r0   r'   r'   r(   r#   >  r   zFreshestCRL.public_bytesNr   ri   r   r9   rQ   )rJ   rK   rL   r   ZFRESHEST_CRLr>   rC   r:   rj   rk   rl   rh   r{   r   r#   r'   r'   r'   r(   r     r   r   c                   @  sl   e Zd Zd!d
dZd"ddZd#ddZd$ddZed%ddZed&ddZ	ed'ddZ
ed%ddZd S )(r   	full_namer   relative_name RelativeDistinguishedName | Nonereasonsfrozenset[ReasonFlags] | None
crl_issuerr   r?   c                 C  s   |r|rt d|s|s|st d|d ur't|}tdd |D s'td|r2t|ts2td|d urGt|}tdd |D sGtd|r[t|trWtd	d |D s[td
|rktj|v sgtj	|v rkt d|| _
|| _|| _|| _d S )NzOYou cannot provide both full_name and relative_name, at least one must be None.z?Either full_name, relative_name or crl_issuer must be provided.c                 s  r   r!   r   r   r'   r'   r(   r   W  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   d  r   z2crl_issuer must be None or a list of general namesc                 s  r   r!   r"   ReasonFlagsr   r'   r'   r(   r   k  r   z0reasons must be None or frozenset of ReasonFlagszLunspecified and remove_from_crl are not valid reasons in a DistributionPoint)r   rX   r   rc   r"   r   	frozensetr   unspecifiedremove_from_crl
_full_name_relative_name_reasons_crl_issuer)r1   r   r   r   r   r'   r'   r(   rC   C  sR   



zDistributionPoint.__init__r+   c                 C  r   )Nz}<DistributionPoint(full_name={0.full_name}, relative_name={0.relative_name}, reasons={0.reasons}, crl_issuer={0.crl_issuer})>r   r0   r'   r'   r(   rh   }     zDistributionPoint.__repr__ru   rv   rw   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   ry   r   r   r   r   rz   r'   r'   r(   r{     s   



zDistributionPoint.__eq__r,   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   r   r   r   )r1   fnr   r'   r'   r(   r     s   

zDistributionPoint.__hash__r   c                 C  r   r!   r   r0   r'   r'   r(   r     r   zDistributionPoint.full_namec                 C  r   r!   r   r0   r'   r'   r(   r     r   zDistributionPoint.relative_namec                 C  r   r!   )r   r0   r'   r'   r(   r     r   zDistributionPoint.reasonsc                 C  r   r!   )r   r0   r'   r'   r(   r     r   zDistributionPoint.crl_issuerN)
r   r   r   r   r   r   r   r   r   r?   ri   r   r9   r   r   r   r   r   )rJ   rK   rL   rC   rh   r{   r   r   r   r   r   r   r'   r'   r'   r(   r   B  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)rJ   rK   rL   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ddZdd	d
ZdddZdddZ	e
dddZe
dddZd ddZdS )!PolicyConstraintsrequire_explicit_policyr   inhibit_policy_mappingr   r?   c                 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"   r,   rc   r   _require_explicit_policy_inhibit_policy_mapping)r1   r  r  r'   r'   r(   rC     s$   


zPolicyConstraints.__init__r+   c                 C  r   )Nz{<PolicyConstraints(require_explicit_policy={0.require_explicit_policy}, inhibit_policy_mapping={0.inhibit_policy_mapping})>r   r0   r'   r'   r(   rh     r   zPolicyConstraints.__repr__ru   rv   rw   c                 C  r   r!   )r"   r  ry   r  r  rz   r'   r'   r(   r{     r   zPolicyConstraints.__eq__r,   c                 C  r   r!   )r   r  r  r0   r'   r'   r(   r     s   
zPolicyConstraints.__hash__c                 C  r   r!   )r  r0   r'   r'   r(   r    r   z)PolicyConstraints.require_explicit_policyc                 C  r   r!   )r  r0   r'   r'   r(   r    r   z(PolicyConstraints.inhibit_policy_mappingr    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   zPolicyConstraints.public_bytesN)r  r   r  r   r   r?   ri   r   r9   r   rQ   )rJ   rK   rL   r   ZPOLICY_CONSTRAINTSr>   rC   rh   r{   r   r   r  r  r#   r'   r'   r'   r(   r    s    



	r  c                   @  r   )CertificatePoliciespolicies"typing.Iterable[PolicyInformation]r   r?   c                 C  r   )Nc                 s  r   r!   )r"   PolicyInformationr   r'   r'   r(   r   #  r   z/CertificatePolicies.__init__.<locals>.<genexpr>z;Every item in the policies list must be a PolicyInformation)rX   r   rc   	_policies)r1   r  r'   r'   r(   rC   !     
zCertificatePolicies.__init__r  r+   c                 C  rf   )Nz<CertificatePolicies(rg   )r  r0   r'   r'   r(   rh   -  r4   zCertificatePolicies.__repr__ru   rv   rw   c                 C  rx   r!   )r"   r  ry   r  rz   r'   r'   r(   r{   0  r|   zCertificatePolicies.__eq__r,   c                 C  r   r!   )r   r   r  r0   r'   r'   r(   r   6  r4   zCertificatePolicies.__hash__r    c                 C  r   r!   r   r0   r'   r'   r(   r#   9  r   z CertificatePolicies.public_bytesN)r  r  r   r?   ri   r   r9   rQ   )rJ   rK   rL   r   ZCERTIFICATE_POLICIESr>   rC   r:   rj   rk   rl   rh   r{   r   r#   r'   r'   r'   r(   r    s    




r  c                   @  P   e Zd ZdddZdd
dZdddZdddZedddZedddZ	dS ) r  policy_identifierr   policy_qualifiers(typing.Iterable[str | UserNotice] | Noner   r?   c                 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"   r+   
UserNoticer   r'   r'   r(   r   J  s    
z-PolicyInformation.__init__.<locals>.<genexpr>zMpolicy_qualifiers must be a list of strings and/or UserNotice objects or None)r"   r   rc   _policy_identifierrX   r   _policy_qualifiers)r1   r  r  r'   r'   r(   rC   >  s   

zPolicyInformation.__init__r+   c                 C  r   )Nze<PolicyInformation(policy_identifier={0.policy_identifier}, policy_qualifiers={0.policy_qualifiers})>r   r0   r'   r'   r(   rh   T  r   zPolicyInformation.__repr__ru   rv   rw   c                 C  r   r!   )r"   r  ry   r  r  rz   r'   r'   r(   r{   Z  r   zPolicyInformation.__eq__r,   c                 C  s(   | j d urt| j }nd }t| j|fS r!   )r  r   r   r  )r1   Zpqr'   r'   r(   r   c  s   
zPolicyInformation.__hash__c                 C  r   r!   )r"  r0   r'   r'   r(   r  m  r   z#PolicyInformation.policy_identifierlist[str | UserNotice] | Nonec                 C  r   r!   )r#  r0   r'   r'   r(   r  q  r   z#PolicyInformation.policy_qualifiersN)r  r   r  r   r   r?   ri   r   r9   r   )r   r$  )
rJ   rK   rL   rC   rh   r{   r   r   r  r  r'   r'   r'   r(   r  =  s    



	
r  c                   @  r   )r!  notice_referenceNoticeReference | Noneexplicit_text
str | Noner   r?   c                 C  s&   |rt |tstd|| _|| _d S )Nz2notice_reference must be None or a NoticeReference)r"   NoticeReferencerc   _notice_reference_explicit_text)r1   r%  r'  r'   r'   r(   rC   y  s   
zUserNotice.__init__r+   c                 C  r   )NzV<UserNotice(notice_reference={0.notice_reference}, explicit_text={0.explicit_text!r})>r   r0   r'   r'   r(   rh     r   zUserNotice.__repr__ru   rv   rw   c                 C  r   r!   )r"   r!  ry   r%  r'  rz   r'   r'   r(   r{     r   zUserNotice.__eq__r,   c                 C  r   r!   )r   r%  r'  r0   r'   r'   r(   r     r   zUserNotice.__hash__c                 C  r   r!   )r*  r0   r'   r'   r(   r%    r   zUserNotice.notice_referencec                 C  r   r!   )r+  r0   r'   r'   r(   r'    r   zUserNotice.explicit_textN)r%  r&  r'  r(  r   r?   ri   r   r9   )r   r&  r   r(  )
rJ   rK   rL   rC   rh   r{   r   r   r%  r'  r'   r'   r'   r(   r!  x  s    



	r!  c                   @  r  ) r)  organizationr(  notice_numberstyping.Iterable[int]r   r?   c                 C  s2   || _ t|}tdd |D std|| _d S )Nc                 s  r   r!   )r"   r,   r   r'   r'   r(   r     r   z+NoticeReference.__init__.<locals>.<genexpr>z)notice_numbers must be a list of integers)_organizationrX   r   rc   _notice_numbers)r1   r-  r.  r'   r'   r(   rC     s
   
zNoticeReference.__init__r+   c                 C  r   )NzU<NoticeReference(organization={0.organization!r}, notice_numbers={0.notice_numbers})>r   r0   r'   r'   r(   rh     r   zNoticeReference.__repr__ru   rv   rw   c                 C  r   r!   )r"   r)  ry   r-  r.  rz   r'   r'   r(   r{     r   zNoticeReference.__eq__r,   c                 C  s   t | jt| jfS r!   )r   r-  r   r.  r0   r'   r'   r(   r        zNoticeReference.__hash__c                 C  r   r!   )r0  r0   r'   r'   r(   r-    r   zNoticeReference.organization	list[int]c                 C  r   r!   )r1  r0   r'   r'   r(   r.    r   zNoticeReference.notice_numbersN)r-  r(  r.  r/  r   r?   ri   r   r9   r,  )r   r3  )
rJ   rK   rL   rC   rh   r{   r   r   r-  r.  r'   r'   r'   r(   r)    r   r)  c                   @  r   )ExtendedKeyUsageusages!typing.Iterable[ObjectIdentifier]r   r?   c                 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)rX   r   rc   _usages)r1   r5  r'   r'   r(   rC     s   
zExtendedKeyUsage.__init__r8  r+   c                 C  rf   )Nz<ExtendedKeyUsage(rg   )r8  r0   r'   r'   r(   rh     r4   zExtendedKeyUsage.__repr__ru   rv   rw   c                 C  rx   r!   )r"   r4  ry   r8  rz   r'   r'   r(   r{     r|   zExtendedKeyUsage.__eq__r,   c                 C  r   r!   )r   r   r8  r0   r'   r'   r(   r     r4   zExtendedKeyUsage.__hash__r    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   zExtendedKeyUsage.public_bytesN)r5  r6  r   r?   ri   r   r9   rQ   )rJ   rK   rL   r   ZEXTENDED_KEY_USAGEr>   rC   r:   rj   rk   rl   rh   r{   r   r#   r'   r'   r'   r(   r4    s    
	


r4  c                   @  :   e Zd ZejZdddZddd	ZdddZdddZ	dS )OCSPNoCheckru   rv   r   rw   c                 C     t |tstS dS NT)r"   r:  ry   rz   r'   r'   r(   r{        
zOCSPNoCheck.__eq__r,   c                 C     t tS r!   )r   r:  r0   r'   r'   r(   r        zOCSPNoCheck.__hash__r+   c                 C     dS )Nz<OCSPNoCheck()>r'   r0   r'   r'   r(   rh        zOCSPNoCheck.__repr__r    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   zOCSPNoCheck.public_bytesNr   r9   ri   rQ   )
rJ   rK   rL   r   ZOCSP_NO_CHECKr>   r{   r   rh   r#   r'   r'   r'   r(   r:        


r:  c                   @  r9  )PrecertPoisonru   rv   r   rw   c                 C  r;  r<  )r"   rC  ry   rz   r'   r'   r(   r{     r=  zPrecertPoison.__eq__r,   c                 C  r>  r!   )r   rC  r0   r'   r'   r(   r     r?  zPrecertPoison.__hash__r+   c                 C  r@  )Nz<PrecertPoison()>r'   r0   r'   r'   r(   rh     rA  zPrecertPoison.__repr__r    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   zPrecertPoison.public_bytesNr   r9   ri   rQ   )
rJ   rK   rL   r   ZPRECERT_POISONr>   r{   r   rh   r#   r'   r'   r'   r(   rC    rB  rC  c                   @  r   )
TLSFeaturefeaturestyping.Iterable[TLSFeatureType]r   r?   c                 C  s8   t |}tdd |D rt|dkrtd|| _d S )Nc                 s  r   r!   )r"   TLSFeatureTyper   r'   r'   r(   r     r   z&TLSFeature.__init__.<locals>.<genexpr>r   z@features must be a list of elements from the TLSFeatureType enum)rX   r   r.   rc   	_features)r1   rE  r'   r'   r(   rC     s   
zTLSFeature.__init__rH  r+   c                 C  rf   )Nz<TLSFeature(features=rg   )rH  r0   r'   r'   r(   rh   !  r4   zTLSFeature.__repr__ru   rv   rw   c                 C  rx   r!   )r"   rD  ry   rH  rz   r'   r'   r(   r{   $  r|   zTLSFeature.__eq__r,   c                 C  r   r!   )r   r   rH  r0   r'   r'   r(   r   *  r4   zTLSFeature.__hash__r    c                 C  r   r!   r   r0   r'   r'   r(   r#   -  r   zTLSFeature.public_bytesN)rE  rF  r   r?   ri   r   r9   rQ   )rJ   rK   rL   r   ZTLS_FEATUREr>   rC   r:   rj   rk   rl   rh   r{   r   r#   r'   r'   r'   r(   rD    s    



rD  c                   @  s   e Zd ZdZdZdS )rG  r     N)rJ   rK   rL   Zstatus_requestZstatus_request_v2r'   r'   r'   r(   rG  1  s    rG  c                 C  s   i | ]}|j |qS r'   rd   r   r'   r'   r(   
<dictcomp><      rK  c                   @  sR   e Zd ZejZdddZddd	ZdddZdddZ	e
dddZdddZdS )InhibitAnyPolicy
skip_certsr,   r   r?   c                 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"   r,   rc   r   _skip_certs)r1   rN  r'   r'   r(   rC   B  s
   

zInhibitAnyPolicy.__init__r+   c                 C  rf   )Nz<InhibitAnyPolicy(skip_certs=rg   )rN  r0   r'   r'   r(   rh   K  r4   zInhibitAnyPolicy.__repr__ru   rv   rw   c                 C  rx   r!   )r"   rM  ry   rN  rz   r'   r'   r(   r{   N  r|   zInhibitAnyPolicy.__eq__c                 C  r}   r!   )r   rN  r0   r'   r'   r(   r   T  r   zInhibitAnyPolicy.__hash__c                 C  r   r!   )rO  r0   r'   r'   r(   rN  W  r   zInhibitAnyPolicy.skip_certsr    c                 C  r   r!   r   r0   r'   r'   r(   r#   [  r   zInhibitAnyPolicy.public_bytesN)rN  r,   r   r?   ri   r   r9   rQ   )rJ   rK   rL   r   ZINHIBIT_ANY_POLICYr>   rC   rh   r{   r   r   rN  r#   r'   r'   r'   r(   rM  ?  s    

	

rM  c                   @  s   e Zd ZejZd/ddZed0ddZed0ddZ	ed0ddZ
ed0ddZed0ddZed0ddZed0ddZed0ddZed0dd Zd1d"d#Zd2d&d'Zd3d)d*Zd4d,d-Zd.S )5KeyUsagedigital_signaturerw   content_commitmentkey_enciphermentdata_enciphermentkey_agreementkey_cert_signcrl_signencipher_onlydecipher_onlyr   r?   c
           
      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)
r1   rQ  rR  rS  rT  rU  rV  rW  rX  rY  r'   r'   r(   rC   b  s   
zKeyUsage.__init__c                 C  r   r!   )rZ  r0   r'   r'   r(   rQ  ~  r   zKeyUsage.digital_signaturec                 C  r   r!   )r[  r0   r'   r'   r(   rR    r   zKeyUsage.content_commitmentc                 C  r   r!   )r\  r0   r'   r'   r(   rS    r   zKeyUsage.key_enciphermentc                 C  r   r!   )r]  r0   r'   r'   r(   rT    r   zKeyUsage.data_enciphermentc                 C  r   r!   )r^  r0   r'   r'   r(   rU    r   zKeyUsage.key_agreementc                 C  r   r!   )r_  r0   r'   r'   r(   rV    r   zKeyUsage.key_cert_signc                 C  r   r!   )r`  r0   r'   r'   r(   rW    r   zKeyUsage.crl_signc                 C     | j std| jS )Nz7encipher_only is undefined unless key_agreement is true)rU  r   ra  r0   r'   r'   r(   rX    
   zKeyUsage.encipher_onlyc                 C  rc  )Nz7decipher_only is undefined unless key_agreement is true)rU  r   rb  r0   r'   r'   r(   rY    rd  zKeyUsage.decipher_onlyr+   c                 C  sv   z| j }| j}W n ty   d}d}Y nw d| j d| j d| j d| j d| j d| j d| j	 d	| d
| dS )NFz<KeyUsage(digital_signature=z, content_commitment=z, key_encipherment=z, data_encipherment=z, key_agreement=z, key_cert_sign=z, crl_sign=z, encipher_only=z, decipher_only=rg   )
rX  rY  r   rQ  rR  rS  rT  rU  rV  rW  )r1   rX  rY  r'   r'   r(   rh     s2   

zKeyUsage.__repr__ru   rv   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"   rP  ry   rQ  rR  rS  rT  rU  rV  rW  ra  rb  rz   r'   r'   r(   r{     s&   








zKeyUsage.__eq__r,   c              
   C  s,   t | j| j| j| j| j| j| j| j| j	f	S r!   )
r   rQ  rR  rS  rT  rU  rV  rW  ra  rb  r0   r'   r'   r(   r     s   zKeyUsage.__hash__r    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   zKeyUsage.public_bytesN)rQ  rw   rR  rw   rS  rw   rT  rw   rU  rw   rV  rw   rW  rw   rX  rw   rY  rw   r   r?   r   ri   r   r9   rQ   )rJ   rK   rL   r   Z	KEY_USAGEr>   rC   r   rQ  rR  rS  rT  rU  rV  rW  rX  rY  rh   r{   r   r#   r'   r'   r'   r(   rP  _  s2    



rP  c                   @  s~   e Zd ZejZd$ddZd%ddZd&ddZd&ddZ	d&ddZ
d'ddZd(ddZed)ddZed)ddZd*d!d"Zd#S )+NameConstraintspermitted_subtreesr   excluded_subtreesr   r?   c                 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)rX   r   r   rc   _validate_tree_permitted_subtrees_excluded_subtrees)r1   rf  rg  r'   r'   r(   rC     s8   


zNameConstraints.__init__ru   rv   rw   c                 C  r   r!   )r"   re  ry   rg  rf  rz   r'   r'   r(   r{     r   zNameConstraints.__eq__treetyping.Iterable[GeneralName]c                 C  s   |  | | | d S r!   )_validate_ip_name_validate_dns_namer1   rk  r'   r'   r(   rh    s   
zNameConstraints._validate_treec                 C     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   rd   	ipaddressZIPv4NetworkZIPv6Networkr   namer'   r'   r(   r     s    

z4NameConstraints._validate_ip_name.<locals>.<genexpr>zGIPAddress name constraints must be an IPv4Network or IPv6Network object)anyrc   ro  r'   r'   r(   rm    s   z!NameConstraints._validate_ip_namec                 C  rp  )Nc                 s  s$    | ]}t |tod |jv V  qdS )*N)r"   r   rd   rr  r'   r'   r(   r   ,  s    
z5NameConstraints._validate_dns_name.<locals>.<genexpr>zDDNSName name constraints must not contain the '*' wildcard character)rt  r   ro  r'   r'   r(   rn  +  s   z"NameConstraints._validate_dns_namer+   c                 C  s   d| j  d| j dS )Nz$<NameConstraints(permitted_subtrees=z, excluded_subtrees=rg   )rf  rg  r0   r'   r'   r(   rh   4     
zNameConstraints.__repr__r,   c                 C  s@   | j d urt| j }nd }| jd urt| j}nd }t||fS r!   )rf  r   rg  r   )r1   Zpsesr'   r'   r(   r   :  s   

zNameConstraints.__hash__r   c                 C  r   r!   )ri  r0   r'   r'   r(   rf  G  r   z"NameConstraints.permitted_subtreesc                 C  r   r!   )rj  r0   r'   r'   r(   rg  M  r   z!NameConstraints.excluded_subtreesr    c                 C  r   r!   r   r0   r'   r'   r(   r#   S  r   zNameConstraints.public_bytesN)rf  r   rg  r   r   r?   r   )rk  rl  r   r?   ri   r9   r   rQ   )rJ   rK   rL   r   ZNAME_CONSTRAINTSr>   rC   r{   rh  rm  rn  rh   r   r   rf  rg  r#   r'   r'   r'   r(   re    s    

*
	


	
re  c                   @  s^   e Zd Zdd	d
ZedddZedddZedddZd ddZd!ddZ	d"ddZ
dS )#	Extensionr>   r   criticalrw   rd   r   r   r?   c                 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   rc   rw   _oid	_critical_value)r1   r>   ry  rd   r'   r'   r(   rC   X  s   


zExtension.__init__c                 C  r   r!   rz  r0   r'   r'   r(   r>   g  r   zExtension.oidc                 C  r   r!   )r{  r0   r'   r'   r(   ry  k  r   zExtension.criticalc                 C  r   r!   r|  r0   r'   r'   r(   rd   o  r   zExtension.valuer+   c                 C     d| j  d| j d| j dS )Nz<Extension(oid=z, critical=, value=rg   )r>   ry  rd   r0   r'   r'   r(   rh   s  s   zExtension.__repr__ru   rv   c                 C  r   r!   )r"   rx  ry   r>   ry  rd   rz   r'   r'   r(   r{   y     


zExtension.__eq__r,   c                 C     t | j| j| jfS r!   )r   r>   ry  rd   r0   r'   r'   r(   r     r2  zExtension.__hash__N)r>   r   ry  rw   rd   r   r   r?   r   r   )r   r   ri   r   r9   )rJ   rK   rL   rC   r   r>   ry  rd   rh   r{   r   r'   r'   r'   r(   rx  W  s    



rx  c                   @  s   e Zd Zd(ddZed\ZZZej	d)ddZ
ej	d*ddZ
ej	d+ddZ
ej	d,ddZ
ej	d-ddZ
d.ddZ
d/ddZd0d"d#Zd1d%d&Zd'S )2GeneralNamesgeneral_namesrl  r   r?   c                 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)rX   r   rc   _general_namesr1   r  r'   r'   r(   rC     r  zGeneralNames.__init__r  typeBtype[DNSName] | type[UniformResourceIdentifier] | type[RFC822Name]	list[str]c                 C     d S r!   r'   r1   r  r'   r'   r(   get_values_for_type     z GeneralNames.get_values_for_typetype[DirectoryName]
list[Name]c                 C  r  r!   r'   r  r'   r'   r(   r       type[RegisteredID]list[ObjectIdentifier]c                 C  r  r!   r'   r  r'   r'   r(   r    r  type[IPAddress]list[_IPAddressTypes]c                 C  r  r!   r'   r  r'   r'   r(   r       type[OtherName]list[OtherName]c                 C  r  r!   r'   r  r'   r'   r(   r       type[DNSName] | type[DirectoryName] | type[IPAddress] | type[OtherName] | type[RFC822Name] | type[RegisteredID] | type[UniformResourceIdentifier]Ylist[_IPAddressTypes] | list[str] | list[OtherName] | list[Name] | list[ObjectIdentifier]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r  r'   r(   r     s    z3GeneralNames.get_values_for_type.<locals>.<genexpr>c                 S  s   g | ]}|j qS r'   rJ  r  r'   r'   r(   
<listcomp>  s    z4GeneralNames.get_values_for_type.<locals>.<listcomp>)r   rX   )r1   r  Zobjsr'   r  r(   r    s   r+   c                 C  rf   )Nz<GeneralNames(rg   r  r0   r'   r'   r(   rh     r4   zGeneralNames.__repr__ru   rv   rw   c                 C  rx   r!   )r"   r  ry   r  rz   r'   r'   r(   r{     r|   zGeneralNames.__eq__r,   c                 C  r   r!   )r   r   r  r0   r'   r'   r(   r     r4   zGeneralNames.__hash__Nr  rl  r   r?   r  r  r   r  r  r  r   r  r  r  r   r  r  r  r   r  r  r  r   r  r  r  r   r  ri   r   r9   )rJ   rK   rL   rC   r:   rj   rk   rl   typingoverloadr  rh   r{   r   r'   r'   r'   r(   r    s"    




r  c                   @     e Zd ZejZd+ddZed\ZZ	Z
ejd,ddZejd-ddZejd.ddZejd/ddZejd0ddZd1ddZd2ddZd3d"d#Zd4d%d&Zd5d(d)Zd*S )6SubjectAlternativeNamer  rl  r   r?   c                 C  rW   r!   r  r  r  r'   r'   r(   rC     r4   zSubjectAlternativeName.__init__r  r  r  r  c                 C  r  r!   r'   r  r'   r'   r(   r    r  z*SubjectAlternativeName.get_values_for_typer  r  c                 C  r  r!   r'   r  r'   r'   r(   r    r  r  r  c                 C  r  r!   r'   r  r'   r'   r(   r    r  r  r  c                 C  r  r!   r'   r  r'   r'   r(   r    r  r  r  c                 C  r  r!   r'   r  r'   r'   r(   r    r  r  r  c                 C     | j |S r!   r  r  r  r'   r'   r(   r       r+   c                 C  rf   )Nz<SubjectAlternativeName(rg   r  r0   r'   r'   r(   rh     r4   zSubjectAlternativeName.__repr__ru   rv   rw   c                 C  rx   r!   )r"   r  ry   r  rz   r'   r'   r(   r{     r|   zSubjectAlternativeName.__eq__r,   c                 C  r}   r!   r   r  r0   r'   r'   r(   r     r   zSubjectAlternativeName.__hash__r    c                 C  r   r!   r   r0   r'   r'   r(   r#   !  r   z#SubjectAlternativeName.public_bytesNr  r  r  r  r  r  r  ri   r   r9   rQ   )rJ   rK   rL   r   ZSUBJECT_ALTERNATIVE_NAMEr>   rC   r:   rj   rk   rl   r  r  r  rh   r{   r   r#   r'   r'   r'   r(   r    &    




r  c                   @  r  )6IssuerAlternativeNamer  rl  r   r?   c                 C  rW   r!   r  r  r'   r'   r(   rC   (  r4   zIssuerAlternativeName.__init__r  r  r  r  c                 C  r  r!   r'   r  r'   r'   r(   r  -  r  z)IssuerAlternativeName.get_values_for_typer  r  c                 C  r  r!   r'   r  r'   r'   r(   r  6  r  r  r  c                 C  r  r!   r'   r  r'   r'   r(   r  =  r  r  r  c                 C  r  r!   r'   r  r'   r'   r(   r  D  r  r  r  c                 C  r  r!   r'   r  r'   r'   r(   r  J  r  r  r  c                 C  r  r!   r  r  r'   r'   r(   r  N  r  r+   c                 C  rf   )Nz<IssuerAlternativeName(rg   r  r0   r'   r'   r(   rh   `  r4   zIssuerAlternativeName.__repr__ru   rv   rw   c                 C  rx   r!   )r"   r  ry   r  rz   r'   r'   r(   r{   c  r|   zIssuerAlternativeName.__eq__r,   c                 C  r}   r!   r  r0   r'   r'   r(   r   i  r   zIssuerAlternativeName.__hash__r    c                 C  r   r!   r   r0   r'   r'   r(   r#   l  r   z"IssuerAlternativeName.public_bytesNr  r  r  r  r  r  r  ri   r   r9   rQ   )rJ   rK   rL   r   ZISSUER_ALTERNATIVE_NAMEr>   rC   r:   rj   rk   rl   r  r  r  rh   r{   r   r#   r'   r'   r'   r(   r  %  r  r  c                   @  r  )6CertificateIssuerr  rl  r   r?   c                 C  rW   r!   r  r  r'   r'   r(   rC   s  r4   zCertificateIssuer.__init__r  r  r  r  c                 C  r  r!   r'   r  r'   r'   r(   r  x  r  z%CertificateIssuer.get_values_for_typer  r  c                 C  r  r!   r'   r  r'   r'   r(   r    r  r  r  c                 C  r  r!   r'   r  r'   r'   r(   r    r  r  r  c                 C  r  r!   r'   r  r'   r'   r(   r    r  r  r  c                 C  r  r!   r'   r  r'   r'   r(   r    r  r  r  c                 C  r  r!   r  r  r'   r'   r(   r    r  r+   c                 C  rf   )Nz<CertificateIssuer(rg   r  r0   r'   r'   r(   rh     r4   zCertificateIssuer.__repr__ru   rv   rw   c                 C  rx   r!   )r"   r  ry   r  rz   r'   r'   r(   r{     r|   zCertificateIssuer.__eq__r,   c                 C  r}   r!   r  r0   r'   r'   r(   r     r   zCertificateIssuer.__hash__r    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   zCertificateIssuer.public_bytesNr  r  r  r  r  r  r  ri   r   r9   rQ   )rJ   rK   rL   r   ZCERTIFICATE_ISSUERr>   rC   r:   rj   rk   rl   r  r  r  rh   r{   r   r#   r'   r'   r'   r(   r  p  r  r  c                   @  R   e Zd ZejZdddZddd	ZdddZdddZ	e
dddZdddZdS )	CRLReasonreasonr   r   r?   c                 C  ro   )Nz*reason must be an element from ReasonFlags)r"   r   rc   _reason)r1   r  r'   r'   r(   rC     rt   zCRLReason.__init__r+   c                 C  rf   )Nz<CRLReason(reason=rg   r  r0   r'   r'   r(   rh     r4   zCRLReason.__repr__ru   rv   rw   c                 C  rx   r!   )r"   r  ry   r  rz   r'   r'   r(   r{     r|   zCRLReason.__eq__r,   c                 C  r}   r!   )r   r  r0   r'   r'   r(   r     r   zCRLReason.__hash__c                 C  r   r!   r  r0   r'   r'   r(   r    r   zCRLReason.reasonr    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   zCRLReason.public_bytesN)r  r   r   r?   ri   r   r9   )r   r   rQ   )rJ   rK   rL   r   Z
CRL_REASONr>   rC   rh   r{   r   r   r  r#   r'   r'   r'   r(   r        



r  c                   @  r  )InvalidityDateinvalidity_datedatetime.datetimer   r?   c                 C  s   t |tjs
td|| _d S )Nz+invalidity_date must be a datetime.datetime)r"   datetimerc   _invalidity_date)r1   r  r'   r'   r(   rC     s   
zInvalidityDate.__init__r+   c                 C  rf   )Nz <InvalidityDate(invalidity_date=rg   r  r0   r'   r'   r(   rh     r4   zInvalidityDate.__repr__ru   rv   rw   c                 C  rx   r!   )r"   r  ry   r  rz   r'   r'   r(   r{     r|   zInvalidityDate.__eq__r,   c                 C  r}   r!   )r   r  r0   r'   r'   r(   r     r   zInvalidityDate.__hash__c                 C  r   r!   r  r0   r'   r'   r(   r    r   zInvalidityDate.invalidity_dater    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   zInvalidityDate.public_bytesN)r  r  r   r?   ri   r   r9   )r   r  rQ   )rJ   rK   rL   r   ZINVALIDITY_DATEr>   rC   rh   r{   r   r   r  r#   r'   r'   r'   r(   r    r  r  c                   @  R   e Zd ZejZdddZed\ZZ	Z
dd	d
ZdddZdddZdddZdS ))PrecertificateSignedCertificateTimestampssigned_certificate_timestamps+typing.Iterable[SignedCertificateTimestamp]r   r?   c                 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rX   r   rc   _signed_certificate_timestampsr1   r  r'   r'   r(   rC        
z2PrecertificateSignedCertificateTimestamps.__init__r  r+   c                 C     dt |  dS )Nz+<PrecertificateSignedCertificateTimestamps(rg   rX   r0   r'   r'   r(   rh     r   z2PrecertificateSignedCertificateTimestamps.__repr__r,   c                 C  r   r!   r   r   r  r0   r'   r'   r(   r     r4   z2PrecertificateSignedCertificateTimestamps.__hash__ru   rv   rw   c                 C  rx   r!   )r"   r  ry   r  rz   r'   r'   r(   r{        
z0PrecertificateSignedCertificateTimestamps.__eq__r    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   z6PrecertificateSignedCertificateTimestamps.public_bytesNr  r  r   r?   ri   r9   r   rQ   )rJ   rK   rL   r   Z%PRECERT_SIGNED_CERTIFICATE_TIMESTAMPSr>   rC   r:   rj   rk   rl   rh   r   r{   r#   r'   r'   r'   r(   r        




	r  c                   @  r  )SignedCertificateTimestampsr  r  r   r?   c                 C  r   )Nc                 s  r   r!   r  r  r'   r'   r(   r   *  r  z7SignedCertificateTimestamps.__init__.<locals>.<genexpr>r  r  r  r'   r'   r(   rC   #  r  z$SignedCertificateTimestamps.__init__r  r+   c                 C  r  )Nz<SignedCertificateTimestamps(rg   r  r0   r'   r'   r(   rh   8  r   z$SignedCertificateTimestamps.__repr__r,   c                 C  r   r!   r  r0   r'   r'   r(   r   ;  r4   z$SignedCertificateTimestamps.__hash__ru   rv   rw   c                 C  rx   r!   )r"   r  ry   r  rz   r'   r'   r(   r{   >  r  z"SignedCertificateTimestamps.__eq__r    c                 C  r   r!   r   r0   r'   r'   r(   r#   G  r   z(SignedCertificateTimestamps.public_bytesNr  ri   r9   r   rQ   )rJ   rK   rL   r   ZSIGNED_CERTIFICATE_TIMESTAMPSr>   rC   r:   rj   rk   rl   rh   r   r{   r#   r'   r'   r'   r(   r     r  r  c                   @  sR   e Zd ZejZdddZdd
dZdddZdddZ	e
dddZdddZdS )	OCSPNoncenoncer    r   r?   c                 C  ro   )Nznonce must be bytes)r"   r    rc   _nonce)r1   r  r'   r'   r(   rC   N  rt   zOCSPNonce.__init__ru   rv   rw   c                 C  rx   r!   )r"   r  ry   r  rz   r'   r'   r(   r{   T  r|   zOCSPNonce.__eq__r,   c                 C  r}   r!   )r   r  r0   r'   r'   r(   r   Z  r   zOCSPNonce.__hash__r+   c                 C  r   )Nz<OCSPNonce(nonce=rg   )r  r0   r'   r'   r(   rh   ]  r4   zOCSPNonce.__repr__c                 C  r   r!   )r  r0   r'   r'   r(   r  `  r   zOCSPNonce.noncec                 C  r   r!   r   r0   r'   r'   r(   r#   d  r   zOCSPNonce.public_bytesN)r  r    r   r?   r   r9   ri   rQ   )rJ   rK   rL   r   ZNONCEr>   rC   r{   r   rh   r   r  r#   r'   r'   r'   r(   r  K  r   r  c                   @  sN   e Zd ZejZdddZdd
dZdddZdddZ	dddZ
dddZdS )OCSPAcceptableResponses	responsesr6  r   r?   c                 C  s,   t |}tdd |D rtd|| _d S )Nc                 s  s    | ]	}t |t V  qd S r!   r7  )r   rr'   r'   r(   r   m  s    z3OCSPAcceptableResponses.__init__.<locals>.<genexpr>z'All responses must be ObjectIdentifiers)rX   rt  rc   
_responses)r1   r  r'   r'   r(   rC   k  s   
z OCSPAcceptableResponses.__init__ru   rv   rw   c                 C  rx   r!   )r"   r  ry   r  rz   r'   r'   r(   r{   r  r|   zOCSPAcceptableResponses.__eq__r,   c                 C  r   r!   )r   r   r  r0   r'   r'   r(   r   x  r4   z OCSPAcceptableResponses.__hash__r+   c                 C  rf   )Nz#<OCSPAcceptableResponses(responses=rg   )r  r0   r'   r'   r(   rh   {  r4   z OCSPAcceptableResponses.__repr__!typing.Iterator[ObjectIdentifier]c                 C  r}   r!   )r5   r  r0   r'   r'   r(   rk   ~  r   z OCSPAcceptableResponses.__iter__r    c                 C  r   r!   r   r0   r'   r'   r(   r#     r   z$OCSPAcceptableResponses.public_bytesN)r  r6  r   r?   r   r9   ri   )r   r  rQ   )rJ   rK   rL   r   ZACCEPTABLE_RESPONSESr>   rC   r{   r   rh   rk   r#   r'   r'   r'   r(   r  h  s    




r  c                   @  s   e Zd ZejZd-ddZd.ddZd/ddZd0ddZ	e
d1ddZe
d2ddZe
d3dd Ze
d3d!d"Ze
d4d#d$Ze
d3d%d&Ze
d3d'd(Zd5d*d+Zd,S )6IssuingDistributionPointr   r   r   r   only_contains_user_certsrw   only_contains_ca_certsonly_some_reasonsr   indirect_crlonly_contains_attribute_certsr   r?   c           	      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(   r    rL  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.)rX   r"   r   r   rc   r   r   r   r   rw   r.   rt  _only_contains_user_certs_only_contains_ca_certs_indirect_crl_only_contains_attribute_certs_only_some_reasonsr   r   )	r1   r   r   r  r  r  r  r  Zcrl_constraintsr'   r'   r(   rC     sp   



z!IssuingDistributionPoint.__init__r+   c                 C  s>   d| j  d| j d| j d| j d| j d| j d| j dS )	Nz$<IssuingDistributionPoint(full_name=z, relative_name=z, only_contains_user_certs=z, only_contains_ca_certs=z, only_some_reasons=z, indirect_crl=z , only_contains_attribute_certs=rg   )r   r   r  r  r  r  r  r0   r'   r'   r(   rh     s   
z!IssuingDistributionPoint.__repr__ru   rv   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  ry   r   r   r  r  r  r  r  rz   r'   r'   r(   r{     s"   





zIssuingDistributionPoint.__eq__r,   c                 C  s$   t | j| j| j| j| j| j| jfS r!   )r   r   r   r  r  r  r  r  r0   r'   r'   r(   r     s   z!IssuingDistributionPoint.__hash__r   c                 C  r   r!   r   r0   r'   r'   r(   r     r   z"IssuingDistributionPoint.full_namec                 C  r   r!   r   r0   r'   r'   r(   r     r   z&IssuingDistributionPoint.relative_namec                 C  r   r!   )r  r0   r'   r'   r(   r    r   z1IssuingDistributionPoint.only_contains_user_certsc                 C  r   r!   )r  r0   r'   r'   r(   r    r   z/IssuingDistributionPoint.only_contains_ca_certsc                 C  r   r!   )r  r0   r'   r'   r(   r    r   z*IssuingDistributionPoint.only_some_reasonsc                 C  r   r!   )r  r0   r'   r'   r(   r    r   z%IssuingDistributionPoint.indirect_crlc                 C  r   r!   )r  r0   r'   r'   r(   r    r   z6IssuingDistributionPoint.only_contains_attribute_certsr    c                 C  r   r!   r   r0   r'   r'   r(   r#   !  r   z%IssuingDistributionPoint.public_bytesN)r   r   r   r   r  rw   r  rw   r  r   r  rw   r  rw   r   r?   ri   r   r9   r   r   r   r  rQ   )rJ   rK   rL   r   ZISSUING_DISTRIBUTION_POINTr>   rC   rh   r{   r   r   r   r   r  r  r  r  r  r#   r'   r'   r'   r(   r    s*    

S

r  c                   @  sn   e Zd ZejZddd	Zed d
dZed!ddZ	ed!ddZ
d"ddZd#ddZd$ddZd%ddZdS )&MSCertificateTemplatetemplate_idr   major_versionr   minor_versionr   r?   c                 C  sT   t |ts	td|| _|d urt |tr|d ur"t |ts"td|| _|| _d S )Noid must be an ObjectIdentifierz8major_version and minor_version must be integers or None)r"   r   rc   _template_idr,   _major_version_minor_version)r1   r  r  r  r'   r'   r(   rC   (  s   

zMSCertificateTemplate.__init__c                 C  r   r!   )r  r0   r'   r'   r(   r  <  r   z!MSCertificateTemplate.template_idc                 C  r   r!   )r  r0   r'   r'   r(   r  @  r   z#MSCertificateTemplate.major_versionc                 C  r   r!   )r  r0   r'   r'   r(   r  D  r   z#MSCertificateTemplate.minor_versionr+   c                 C  r  )Nz#<MSCertificateTemplate(template_id=z, major_version=z, minor_version=rg   )r  r  r  r0   r'   r'   r(   rh   H  r   zMSCertificateTemplate.__repr__ru   rv   rw   c                 C  r   r!   )r"   r  ry   r  r  r  rz   r'   r'   r(   r{   O  r  zMSCertificateTemplate.__eq__r,   c                 C  r  r!   )r   r  r  r  r0   r'   r'   r(   r   Y  r2  zMSCertificateTemplate.__hash__r    c                 C  r   r!   r   r0   r'   r'   r(   r#   \  r   z"MSCertificateTemplate.public_bytesN)r  r   r  r   r  r   r   r?   r   r   ri   r   r9   rQ   )rJ   rK   rL   r   ZMS_CERTIFICATE_TEMPLATEr>   rC   r   r  r  r  rh   r{   r   r#   r'   r'   r'   r(   r  %  s    




r  c                   @  sZ   e Zd ZdddZedd	d
ZedddZdddZdddZd ddZ	dddZ
dS )!rb   r>   r   rd   r    r   r?   c                 C  s"   t |ts	td|| _|| _d S )Nr  )r"   r   rc   rz  r|  )r1   r>   rd   r'   r'   r(   rC   a  s   

zUnrecognizedExtension.__init__c                 C  r   r!   r}  r0   r'   r'   r(   r>   g  r   zUnrecognizedExtension.oidc                 C  r   r!   r~  r0   r'   r'   r(   rd   k  r   zUnrecognizedExtension.valuer+   c                 C  s   d| j  d| jdS )Nz<UnrecognizedExtension(oid=r  rg   )r>   rd   r0   r'   r'   r(   rh   o  rv  zUnrecognizedExtension.__repr__ru   rv   rw   c                 C  r   r!   )r"   rb   ry   r>   rd   rz   r'   r'   r(   r{   u  r   zUnrecognizedExtension.__eq__r,   c                 C  r   r!   )r   r>   rd   r0   r'   r'   r(   r   {  r   zUnrecognizedExtension.__hash__c                 C  r   r!   rJ  r0   r'   r'   r(   r#   ~  s   z"UnrecognizedExtension.public_bytesN)r>   r   rd   r    r   r?   r   rQ   ri   r   r9   )rJ   rK   rL   rC   r   r>   rd   rh   r{   r   r#   r'   r'   r'   r(   rb   `  s    



rb   )r   r   r   r    )r*   r+   )iZ
__future__r   abcr  r$   rq  r  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   r)   r:   	Exceptionr<   rO   ABCMetar   rT   rm   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)  r4  r:  rC  rD  rG  Z_TLS_FEATURE_TYPE_TO_ENUMrM  rP  re  ZGenericrx  r  r  r  r  r  r  r  r  r  r  r  r  rb   r'   r'   r'   r(   <module>   s   ,

'l$!!(.%%kA;+("  s0SKKK++ !;