o
    CZh)                    @  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)bound	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hashlibsha1digest)r    dataZ
serialized r*   S/var/www/html/lang_env/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                   r0   r#   )iterr2   r3   r5   r*   r+   iter_methodN   r7   z+_make_sequence_methods.<locals>.iter_methodc                   s   t |  | S r#   )r2   )r4   idxr5   r*   r+   getitem_methodQ   r7   z._make_sequence_methods.<locals>.getitem_methodr!   r/   r*   )r-   r6   r9   r;   r*   r5   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__rA   r4   r@   rA   	__class__r*   r+   rF   X      
zDuplicateExtension.__init__r@   r.   rA   r   r!   rB   __name__
__module____qualname__rF   __classcell__r*   r*   rH   r+   r?   W       r?   c                      r>   )
ExtensionNotFoundr@   r.   rA   r   r!   rB   c                   rC   r#   rD   rG   rH   r*   r+   rF   ^   rJ   zExtensionNotFound.__init__rK   rL   r*   r*   rH   r+   rR   ]   rQ   rR   c                   @  s    e Zd ZU ded< dddZdS )	r   z!typing.ClassVar[ObjectIdentifier]rA   r!   r"   c                 C  s   t d| )z7
        Serializes the extension type to DER.
        z3public_bytes is not implemented for extension type )NotImplementedErrorr3   r*   r*   r+   r%   f   s   zExtensionType.public_bytesNr!   r"   )rM   rN   rO   __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!   rB   c                 C     t || _d S r#   )list_extensions)r4   rX   r*   r*   r+   rF   p   s   zExtensions.__init__rA   r   Extension[ExtensionType]c                 C  s.   | D ]}|j |kr|  S qtd| d|)NNo  extension was found)rA   rR   )r4   rA   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$   valuerR   rA   )r4   rb   r`   r*   r*   r+   get_extension_for_class~   s   z"Extensions.get_extension_for_classr\   r.   c                 C     d| j  dS )Nz<Extensions()>)r\   r3   r*   r*   r+   __repr__   r7   zExtensions.__repr__N)rX   rY   r!   rB   )rA   r   r!   r]   )rb   rc   r!   rd   r!   r.   )rM   rN   rO   rF   ra   rh   r=   __len____iter____getitem__rk   r*   r*   r*   r+   rW   o   s    


	rW   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!   rB   c                 C     t |ts	td|| _d S Nzcrl_number must be an integerr$   r/   rf   _crl_numberr4   rq   r*   r*   r+   rF         

zCRLNumber.__init__otherobjectboolc                 C     t |tstS | j|jkS r#   )r$   rp   NotImplementedrq   r4   rx   r*   r*   r+   __eq__      
zCRLNumber.__eq__c                 C  
   t | jS r#   hashrq   r3   r*   r*   r+   __hash__      
zCRLNumber.__hash__r.   c                 C  ri   )Nz<CRLNumber(rj   rq   r3   r*   r*   r+   rk      r7   zCRLNumber.__repr__c                 C     | j S r#   ru   r3   r*   r*   r+   rq         zCRLNumber.crl_numberr"   c                 C  
   t | S r#   	rust_x509Zencode_extension_valuer3   r*   r*   r+   r%      r   zCRLNumber.public_bytesNrq   r/   r!   rB   rx   ry   r!   rz   r<   rl   rT   )rM   rN   rO   r   Z
CRL_NUMBERrA   rF   r~   r   rk   propertyrq   r%   r*   r*   r*   r+   rp          



rp   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!   rB   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)	
ValueErrorr[   allrf   r$   r/   _key_identifier_authority_cert_issuer_authority_cert_serial_number)r4   r   r   r   r*   r*   r+   rF      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=rj   r   r3   r*   r*   r+   rk         
zAuthorityKeyIdentifier.__repr__rx   ry   rz   c                 C  2   t |tstS | j|jko| j|jko| j|jkS r#   )r$   r   r|   r   r   r   r}   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   )r4   Zacir*   r*   r+   r     s   

zAuthorityKeyIdentifier.__hash__c                 C  r   r#   )r   r3   r*   r*   r+   r     r   z%AuthorityKeyIdentifier.key_identifierlist[GeneralName] | Nonec                 C  r   r#   )r   r3   r*   r*   r+   r        z,AuthorityKeyIdentifier.authority_cert_issuerc                 C  r   r#   )r   r3   r*   r*   r+   r     r   z3AuthorityKeyIdentifier.authority_cert_serial_numberr"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   z#AuthorityKeyIdentifier.public_bytesN)r   r   r   r   r   r   r!   rB   )r    r
   r!   r   )r   r   r!   r   rl   r   r<   )r!   r   r!   r   r!   r   rT   )rM   rN   rO   r   ZAUTHORITY_KEY_IDENTIFIERrA   rF   classmethodr   r   rk   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!   rB   c                 C  s
   || _ d S r#   Z_digest)r4   r(   r*   r*   r+   rF   "  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   r3   r*   r*   r+   r(   +  r   zSubjectKeyIdentifier.digestc                 C  r   r#   r   r3   r*   r*   r+   r   /  r   z#SubjectKeyIdentifier.key_identifierr.   c                 C     d| j dS )Nz<SubjectKeyIdentifier(digest=rj   r   r3   r*   r*   r+   rk   3  r7   zSubjectKeyIdentifier.__repr__rx   ry   rz   c                 C  s   t |tstS t| j|jS r#   )r$   r   r|   r   Zbytes_eqr(   r}   r*   r*   r+   r~   6  s   
zSubjectKeyIdentifier.__eq__r/   c                 C  r   r#   )r   r(   r3   r*   r*   r+   r   <  r   zSubjectKeyIdentifier.__hash__c                 C  r   r#   r   r3   r*   r*   r+   r%   ?  r   z!SubjectKeyIdentifier.public_bytesN)r(   r"   r!   rB   )r    r   r!   r   rT   rl   r   r<   )rM   rN   rO   r   ZSUBJECT_KEY_IDENTIFIERrA   rF   r   r   r   r(   r   rk   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!   rB   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r[   r   rf   _descriptionsr4   r   r*   r*   r+   rF   F     
z#AuthorityInformationAccess.__init__r   r.   c                 C  ri   )Nz<AuthorityInformationAccess(rj   r   r3   r*   r*   r+   rk   T  r7   z#AuthorityInformationAccess.__repr__rx   ry   rz   c                 C  r{   r#   )r$   r   r|   r   r}   r*   r*   r+   r~   W  r   z!AuthorityInformationAccess.__eq__r/   c                 C     t t| jS r#   r   r   r   r3   r*   r*   r+   r   ]  r7   z#AuthorityInformationAccess.__hash__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%   `  r   z'AuthorityInformationAccess.public_bytesNr   r   r!   rB   rl   r   r<   rT   )rM   rN   rO   r   ZAUTHORITY_INFORMATION_ACCESSrA   rF   r=   rm   rn   ro   rk   r~   r   r%   r*   r*   r*   r+   r   C      



r   c                   @  r   )SubjectInformationAccessr   r   r!   rB   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+   rF   g  r   z!SubjectInformationAccess.__init__r   r.   c                 C  ri   )Nz<SubjectInformationAccess(rj   r   r3   r*   r*   r+   rk   u  r7   z!SubjectInformationAccess.__repr__rx   ry   rz   c                 C  r{   r#   )r$   r   r|   r   r}   r*   r*   r+   r~   x  r   zSubjectInformationAccess.__eq__r/   c                 C  r   r#   r   r3   r*   r*   r+   r   ~  r7   z!SubjectInformationAccess.__hash__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   z%SubjectInformationAccess.public_bytesNr   rl   r   r<   rT   )rM   rN   rO   r   ZSUBJECT_INFORMATION_ACCESSrA   rF   r=   rm   rn   ro   rk   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!   rB   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   rf   r   _access_method_access_location)r4   r   r   r*   r*   r+   rF     s   


zAccessDescription.__init__r.   c                 C  
   d | S )NzY<AccessDescription(access_method={0.access_method}, access_location={0.access_location})>formatr3   r*   r*   r+   rk        zAccessDescription.__repr__rx   ry   rz   c                 C  &   t |tstS | j|jko| j|jkS r#   )r$   r   r|   r   r   r}   r*   r*   r+   r~     
   

zAccessDescription.__eq__r/   c                 C     t | j| jfS r#   )r   r   r   r3   r*   r*   r+   r        zAccessDescription.__hash__c                 C  r   r#   )r   r3   r*   r*   r+   r     r   zAccessDescription.access_methodc                 C  r   r#   )r   r3   r*   r*   r+   r     r   z!AccessDescription.access_locationN)r   r   r   r   r!   rB   rl   r   r<   r!   r   )r!   r   )
rM   rN   rO   rF   rk   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carz   path_lengthr   r!   rB   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$   rz   rf   r   r/   _ca_path_length)r4   r   r   r*   r*   r+   rF     s   

zBasicConstraints.__init__c                 C  r   r#   )r   r3   r*   r*   r+   r     r   zBasicConstraints.cac                 C  r   r#   )r   r3   r*   r*   r+   r     r   zBasicConstraints.path_lengthr.   c                 C  r   )Nz:<BasicConstraints(ca={0.ca}, path_length={0.path_length})>r   r3   r*   r*   r+   rk     r   zBasicConstraints.__repr__rx   ry   c                 C  r   r#   )r$   r   r|   r   r   r}   r*   r*   r+   r~        
zBasicConstraints.__eq__r/   c                 C  r   r#   )r   r   r   r3   r*   r*   r+   r     r   zBasicConstraints.__hash__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   zBasicConstraints.public_bytesN)r   rz   r   r   r!   rB   r!   rz   r   rl   r   r<   rT   )rM   rN   rO   r   ZBASIC_CONSTRAINTSrA   rF   r   r   r   rk   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 )DeltaCRLIndicatorrq   r/   r!   rB   c                 C  rr   rs   rt   rv   r*   r*   r+   rF     rw   zDeltaCRLIndicator.__init__c                 C  r   r#   r   r3   r*   r*   r+   rq     r   zDeltaCRLIndicator.crl_numberrx   ry   rz   c                 C  r{   r#   )r$   r   r|   rq   r}   r*   r*   r+   r~     r   zDeltaCRLIndicator.__eq__c                 C  r   r#   r   r3   r*   r*   r+   r     r   zDeltaCRLIndicator.__hash__r.   c                 C  ri   )Nz<DeltaCRLIndicator(crl_number=rj   r   r3   r*   r*   r+   rk     r7   zDeltaCRLIndicator.__repr__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   zDeltaCRLIndicator.public_bytesNr   r<   r   rl   rT   )rM   rN   rO   r   ZDELTA_CRL_INDICATORrA   rF   r   rq   r~   r   rk   r%   r*   r*   r*   r+   r     s    



r   c                   @  r   )CRLDistributionPointsdistribution_points"typing.Iterable[DistributionPoint]r!   rB   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r[   r   rf   _distribution_pointsr4   r   r*   r*   r+   rF        
zCRLDistributionPoints.__init__r   r.   c                 C  ri   )Nz<CRLDistributionPoints(rj   r   r3   r*   r*   r+   rk     r7   zCRLDistributionPoints.__repr__rx   ry   rz   c                 C  r{   r#   )r$   r   r|   r   r}   r*   r*   r+   r~     r   zCRLDistributionPoints.__eq__r/   c                 C  r   r#   r   r   r   r3   r*   r*   r+   r     r7   zCRLDistributionPoints.__hash__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   z"CRLDistributionPoints.public_bytesNr   r   r!   rB   rl   r   r<   rT   )rM   rN   rO   r   ZCRL_DISTRIBUTION_POINTSrA   rF   r=   rm   rn   ro   rk   r~   r   r%   r*   r*   r*   r+   r         




r   c                   @  r   )FreshestCRLr   r   r!   rB   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+   rF      r   zFreshestCRL.__init__r   r.   c                 C  ri   )Nz<FreshestCRL(rj   r   r3   r*   r*   r+   rk   2  r7   zFreshestCRL.__repr__rx   ry   rz   c                 C  r{   r#   )r$   r   r|   r   r}   r*   r*   r+   r~   5  r   zFreshestCRL.__eq__r/   c                 C  r   r#   r   r3   r*   r*   r+   r   ;  r7   zFreshestCRL.__hash__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%   >  r   zFreshestCRL.public_bytesNr   rl   r   r<   rT   )rM   rN   rO   r   ZFRESHEST_CRLrA   rF   r=   rm   rn   ro   rk   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!   rB   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   r[   r   rf   r$   r   	frozensetr   unspecifiedremove_from_crl
_full_name_relative_name_reasons_crl_issuer)r4   r   r   r   r   r*   r*   r+   rF   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   r3   r*   r*   r+   rk   }     zDistributionPoint.__repr__rx   ry   rz   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   r|   r   r   r   r   r}   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   )r4   fnr   r*   r*   r+   r     s   

zDistributionPoint.__hash__r   c                 C  r   r#   r   r3   r*   r*   r+   r     r   zDistributionPoint.full_namec                 C  r   r#   r   r3   r*   r*   r+   r     r   zDistributionPoint.relative_namec                 C  r   r#   )r   r3   r*   r*   r+   r     r   zDistributionPoint.reasonsc                 C  r   r#   )r   r3   r*   r*   r+   r     r   zDistributionPoint.crl_issuerN)
r   r   r   r   r   r   r   r   r!   rB   rl   r   r<   r   r!   r   r!   r   )rM   rN   rO   rF   rk   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)rM   rN   rO   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!   rB   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/   rf   r   _require_explicit_policy_inhibit_policy_mapping)r4   r  r  r*   r*   r+   rF     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   r3   r*   r*   r+   rk     r   zPolicyConstraints.__repr__rx   ry   rz   c                 C  r   r#   )r$   r  r|   r  r  r}   r*   r*   r+   r~     r   zPolicyConstraints.__eq__r/   c                 C  r   r#   )r   r  r  r3   r*   r*   r+   r     s   
zPolicyConstraints.__hash__c                 C  r   r#   )r  r3   r*   r*   r+   r    r   z)PolicyConstraints.require_explicit_policyc                 C  r   r#   )r  r3   r*   r*   r+   r    r   z(PolicyConstraints.inhibit_policy_mappingr"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   zPolicyConstraints.public_bytesN)r  r   r  r   r!   rB   rl   r   r<   r   rT   )rM   rN   rO   r   ZPOLICY_CONSTRAINTSrA   rF   rk   r~   r   r   r  r  r%   r*   r*   r*   r+   r    s    



	r  c                   @  r   )CertificatePoliciespolicies"typing.Iterable[PolicyInformation]r!   rB   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)r[   r   rf   	_policies)r4   r  r*   r*   r+   rF   !     
zCertificatePolicies.__init__r  r.   c                 C  ri   )Nz<CertificatePolicies(rj   )r  r3   r*   r*   r+   rk   -  r7   zCertificatePolicies.__repr__rx   ry   rz   c                 C  r{   r#   )r$   r  r|   r  r}   r*   r*   r+   r~   0  r   zCertificatePolicies.__eq__r/   c                 C  r   r#   )r   r   r  r3   r*   r*   r+   r   6  r7   zCertificatePolicies.__hash__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%   9  r   z CertificatePolicies.public_bytesN)r  r  r!   rB   rl   r   r<   rT   )rM   rN   rO   r   ZCERTIFICATE_POLICIESrA   rF   r=   rm   rn   ro   rk   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!   rB   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   rf   _policy_identifierr[   r   _policy_qualifiers)r4   r!  r"  r*   r*   r+   rF   >  s   

zPolicyInformation.__init__r.   c                 C  r   )Nze<PolicyInformation(policy_identifier={0.policy_identifier}, policy_qualifiers={0.policy_qualifiers})>r   r3   r*   r*   r+   rk   T  r   zPolicyInformation.__repr__rx   ry   rz   c                 C  r   r#   )r$   r  r|   r!  r"  r}   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!  )r4   Zpqr*   r*   r+   r   c  s   
zPolicyInformation.__hash__c                 C  r   r#   )r%  r3   r*   r*   r+   r!  m  r   z#PolicyInformation.policy_identifierlist[str | UserNotice] | Nonec                 C  r   r#   )r&  r3   r*   r*   r+   r"  q  r   z#PolicyInformation.policy_qualifiersN)r!  r   r"  r#  r!   rB   rl   r   r<   r   )r!   r'  )
rM   rN   rO   rF   rk   r~   r   r   r!  r"  r*   r*   r*   r+   r  =  s    



	
r  c                   @  r   )r$  notice_referenceNoticeReference | Noneexplicit_text
str | Noner!   rB   c                 C  s&   |rt |tstd|| _|| _d S )Nz2notice_reference must be None or a NoticeReference)r$   NoticeReferencerf   _notice_reference_explicit_text)r4   r(  r*  r*   r*   r+   rF   y  s   
zUserNotice.__init__r.   c                 C  r   )NzV<UserNotice(notice_reference={0.notice_reference}, explicit_text={0.explicit_text!r})>r   r3   r*   r*   r+   rk     r   zUserNotice.__repr__rx   ry   rz   c                 C  r   r#   )r$   r$  r|   r(  r*  r}   r*   r*   r+   r~     r   zUserNotice.__eq__r/   c                 C  r   r#   )r   r(  r*  r3   r*   r*   r+   r     r   zUserNotice.__hash__c                 C  r   r#   )r-  r3   r*   r*   r+   r(    r   zUserNotice.notice_referencec                 C  r   r#   )r.  r3   r*   r*   r+   r*    r   zUserNotice.explicit_textN)r(  r)  r*  r+  r!   rB   rl   r   r<   )r!   r)  r!   r+  )
rM   rN   rO   rF   rk   r~   r   r   r(  r*  r*   r*   r*   r+   r$  x  s    



	r$  c                   @  r   ) r,  organizationr+  notice_numberstyping.Iterable[int]r!   rB   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)_organizationr[   r   rf   _notice_numbers)r4   r0  r1  r*   r*   r+   rF     s
   
zNoticeReference.__init__r.   c                 C  r   )NzU<NoticeReference(organization={0.organization!r}, notice_numbers={0.notice_numbers})>r   r3   r*   r*   r+   rk     r   zNoticeReference.__repr__rx   ry   rz   c                 C  r   r#   )r$   r,  r|   r0  r1  r}   r*   r*   r+   r~     r   zNoticeReference.__eq__r/   c                 C  s   t | jt| jfS r#   )r   r0  r   r1  r3   r*   r*   r+   r        zNoticeReference.__hash__c                 C  r   r#   )r3  r3   r*   r*   r+   r0    r   zNoticeReference.organization	list[int]c                 C  r   r#   )r4  r3   r*   r*   r+   r1    r   zNoticeReference.notice_numbersN)r0  r+  r1  r2  r!   rB   rl   r   r<   r/  )r!   r6  )
rM   rN   rO   rF   rk   r~   r   r   r0  r1  r*   r*   r*   r+   r,    r   r,  c                   @  r   )ExtendedKeyUsageusages!typing.Iterable[ObjectIdentifier]r!   rB   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)r[   r   rf   _usages)r4   r8  r*   r*   r+   rF     s   
zExtendedKeyUsage.__init__r;  r.   c                 C  ri   )Nz<ExtendedKeyUsage(rj   )r;  r3   r*   r*   r+   rk     r7   zExtendedKeyUsage.__repr__rx   ry   rz   c                 C  r{   r#   )r$   r7  r|   r;  r}   r*   r*   r+   r~     r   zExtendedKeyUsage.__eq__r/   c                 C  r   r#   )r   r   r;  r3   r*   r*   r+   r     r7   zExtendedKeyUsage.__hash__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   zExtendedKeyUsage.public_bytesN)r8  r9  r!   rB   rl   r   r<   rT   )rM   rN   rO   r   ZEXTENDED_KEY_USAGErA   rF   r=   rm   rn   ro   rk   r~   r   r%   r*   r*   r*   r+   r7    s    
	


r7  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 )OCSPNoCheckrx   ry   r!   rz   c                 C     t |tstS dS NT)r$   r=  r|   r}   r*   r*   r+   r~        
zOCSPNoCheck.__eq__r/   c                 C     t tS r#   )r   r=  r3   r*   r*   r+   r        zOCSPNoCheck.__hash__r.   c                 C     dS )Nz<OCSPNoCheck()>r*   r3   r*   r*   r+   rk        zOCSPNoCheck.__repr__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   zOCSPNoCheck.public_bytesNr   r<   rl   rT   )
rM   rN   rO   r   ZOCSP_NO_CHECKrA   r~   r   rk   r%   r*   r*   r*   r+   r=        


r=  c                   @  r<  )PrecertPoisonrx   ry   r!   rz   c                 C  r>  r?  )r$   rF  r|   r}   r*   r*   r+   r~     r@  zPrecertPoison.__eq__r/   c                 C  rA  r#   )r   rF  r3   r*   r*   r+   r     rB  zPrecertPoison.__hash__r.   c                 C  rC  )Nz<PrecertPoison()>r*   r3   r*   r*   r+   rk     rD  zPrecertPoison.__repr__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   zPrecertPoison.public_bytesNr   r<   rl   rT   )
rM   rN   rO   r   ZPRECERT_POISONrA   r~   r   rk   r%   r*   r*   r*   r+   rF    rE  rF  c                   @  r   )
TLSFeaturefeaturestyping.Iterable[TLSFeatureType]r!   rB   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)r[   r   r1   rf   	_features)r4   rH  r*   r*   r+   rF     s   
zTLSFeature.__init__rK  r.   c                 C  ri   )Nz<TLSFeature(features=rj   )rK  r3   r*   r*   r+   rk   !  r7   zTLSFeature.__repr__rx   ry   rz   c                 C  r{   r#   )r$   rG  r|   rK  r}   r*   r*   r+   r~   $  r   zTLSFeature.__eq__r/   c                 C  r   r#   )r   r   rK  r3   r*   r*   r+   r   *  r7   zTLSFeature.__hash__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%   -  r   zTLSFeature.public_bytesN)rH  rI  r!   rB   rl   r   r<   rT   )rM   rN   rO   r   ZTLS_FEATURErA   rF   r=   rm   rn   ro   rk   r~   r   r%   r*   r*   r*   r+   rG    s    



rG  c                   @  s   e Zd ZdZdZdS )rJ  r     N)rM   rN   rO   Zstatus_requestZstatus_request_v2r*   r*   r*   r+   rJ  1  s    rJ  c                 C  s   i | ]}|j |qS r*   rg   r   r*   r*   r+   
<dictcomp><      rN  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!   rB   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/   rf   r   _skip_certs)r4   rQ  r*   r*   r+   rF   B  s
   

zInhibitAnyPolicy.__init__r.   c                 C  ri   )Nz<InhibitAnyPolicy(skip_certs=rj   )rQ  r3   r*   r*   r+   rk   K  r7   zInhibitAnyPolicy.__repr__rx   ry   rz   c                 C  r{   r#   )r$   rP  r|   rQ  r}   r*   r*   r+   r~   N  r   zInhibitAnyPolicy.__eq__c                 C  r   r#   )r   rQ  r3   r*   r*   r+   r   T  r   zInhibitAnyPolicy.__hash__c                 C  r   r#   )rR  r3   r*   r*   r+   rQ  W  r   zInhibitAnyPolicy.skip_certsr"   c                 C  r   r#   r   r3   r*   r*   r+   r%   [  r   zInhibitAnyPolicy.public_bytesN)rQ  r/   r!   rB   rl   r   r<   rT   )rM   rN   rO   r   ZINHIBIT_ANY_POLICYrA   rF   rk   r~   r   r   rQ  r%   r*   r*   r*   r+   rP  ?  s    

	

rP  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_signaturerz   content_commitmentkey_enciphermentdata_enciphermentkey_agreementkey_cert_signcrl_signencipher_onlydecipher_onlyr!   rB   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)
r4   rT  rU  rV  rW  rX  rY  rZ  r[  r\  r*   r*   r+   rF   b  s   
zKeyUsage.__init__c                 C  r   r#   )r]  r3   r*   r*   r+   rT  ~  r   zKeyUsage.digital_signaturec                 C  r   r#   )r^  r3   r*   r*   r+   rU    r   zKeyUsage.content_commitmentc                 C  r   r#   )r_  r3   r*   r*   r+   rV    r   zKeyUsage.key_enciphermentc                 C  r   r#   )r`  r3   r*   r*   r+   rW    r   zKeyUsage.data_enciphermentc                 C  r   r#   )ra  r3   r*   r*   r+   rX    r   zKeyUsage.key_agreementc                 C  r   r#   )rb  r3   r*   r*   r+   rY    r   zKeyUsage.key_cert_signc                 C  r   r#   )rc  r3   r*   r*   r+   rZ    r   zKeyUsage.crl_signc                 C     | j std| jS )Nz7encipher_only is undefined unless key_agreement is true)rX  r   rd  r3   r*   r*   r+   r[    
   zKeyUsage.encipher_onlyc                 C  rf  )Nz7decipher_only is undefined unless key_agreement is true)rX  r   re  r3   r*   r*   r+   r\    rg  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=rj   )
r[  r\  r   rT  rU  rV  rW  rX  rY  rZ  )r4   r[  r\  r*   r*   r+   rk     s2   

zKeyUsage.__repr__rx   ry   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$   rS  r|   rT  rU  rV  rW  rX  rY  rZ  rd  re  r}   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   rT  rU  rV  rW  rX  rY  rZ  rd  re  r3   r*   r*   r+   r     s   zKeyUsage.__hash__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   zKeyUsage.public_bytesN)rT  rz   rU  rz   rV  rz   rW  rz   rX  rz   rY  rz   rZ  rz   r[  rz   r\  rz   r!   rB   r   rl   r   r<   rT   )rM   rN   rO   r   Z	KEY_USAGErA   rF   r   rT  rU  rV  rW  rX  rY  rZ  r[  r\  rk   r~   r   r%   r*   r*   r*   r+   rS  _  s2    



rS  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!   rB   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)r[   r   r   rf   _validate_tree_permitted_subtrees_excluded_subtrees)r4   ri  rj  r*   r*   r+   rF     s8   


zNameConstraints.__init__rx   ry   rz   c                 C  r   r#   )r$   rh  r|   rj  ri  r}   r*   r*   r+   r~     r   zNameConstraints.__eq__treetyping.Iterable[GeneralName]c                 C  s   |  | | | d S r#   )_validate_ip_name_validate_dns_namer4   rn  r*   r*   r+   rk    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   rg   	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)anyrf   rr  r*   r*   r+   rp    s   z!NameConstraints._validate_ip_namec                 C  rs  )Nc                 s  s$    | ]}t |tod |jv V  qdS )*N)r$   r   rg   rw  r*   r*   r+   r   ,  s    
z5NameConstraints._validate_dns_name.<locals>.<genexpr>zDDNSName name constraints must not contain the '*' wildcard character)ry  r   rr  r*   r*   r+   rq  +  s   z"NameConstraints._validate_dns_namer.   c                 C  s   d| j  d| j dS )Nz$<NameConstraints(permitted_subtrees=z, excluded_subtrees=rj   )ri  rj  r3   r*   r*   r+   rk   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#   )ri  r   rj  r   )r4   Zpsesr*   r*   r+   r   :  s   

zNameConstraints.__hash__r   c                 C  r   r#   )rl  r3   r*   r*   r+   ri  G  r   z"NameConstraints.permitted_subtreesc                 C  r   r#   )rm  r3   r*   r*   r+   rj  M  r   z!NameConstraints.excluded_subtreesr"   c                 C  r   r#   r   r3   r*   r*   r+   r%   S  r   zNameConstraints.public_bytesN)ri  r   rj  r   r!   rB   r   )rn  ro  r!   rB   rl   r<   r   rT   )rM   rN   rO   r   ZNAME_CONSTRAINTSrA   rF   r~   rk  rp  rq  rk   r   r   ri  rj  r%   r*   r*   r*   r+   rh    s    

*
	


	
rh  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 )#	ExtensionrA   r   criticalrz   rg   r   r!   rB   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   rf   rz   _oid	_critical_value)r4   rA   r~  rg   r*   r*   r+   rF   X  s   


zExtension.__init__c                 C  r   r#   r  r3   r*   r*   r+   rA   g  r   zExtension.oidc                 C  r   r#   )r  r3   r*   r*   r+   r~  k  r   zExtension.criticalc                 C  r   r#   r  r3   r*   r*   r+   rg   o  r   zExtension.valuer.   c                 C     d| j  d| j d| j dS )Nz<Extension(oid=z, critical=, value=rj   )rA   r~  rg   r3   r*   r*   r+   rk   s  s   zExtension.__repr__rx   ry   c                 C  r   r#   )r$   r}  r|   rA   r~  rg   r}   r*   r*   r+   r~   y     


zExtension.__eq__r/   c                 C     t | j| j| jfS r#   )r   rA   r~  rg   r3   r*   r*   r+   r     r5  zExtension.__hash__N)rA   r   r~  rz   rg   r   r!   rB   r   r   )r!   r   rl   r   r<   )rM   rN   rO   rF   r   rA   r~  rg   rk   r~   r   r*   r*   r*   r+   r}  W  s    



r}  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_namesro  r!   rB   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)r[   r   rf   _general_namesr4   r  r*   r*   r+   rF     r  zGeneralNames.__init__r  typeBtype[DNSName] | type[UniformResourceIdentifier] | type[RFC822Name]	list[str]c                 C     d S r#   r*   r4   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*   rM  r  r*   r*   r+   
<listcomp>  s    z4GeneralNames.get_values_for_type.<locals>.<listcomp>)r   r[   )r4   r  Zobjsr*   r  r+   r    s   r.   c                 C  ri   )Nz<GeneralNames(rj   r  r3   r*   r*   r+   rk     r7   zGeneralNames.__repr__rx   ry   rz   c                 C  r{   r#   )r$   r  r|   r  r}   r*   r*   r+   r~     r   zGeneralNames.__eq__r/   c                 C  r   r#   )r   r   r  r3   r*   r*   r+   r     r7   zGeneralNames.__hash__Nr  ro  r!   rB   r  r  r!   r  r  r  r!   r  r  r  r!   r  r  r  r!   r  r  r  r!   r  r  r  r!   r  rl   r   r<   )rM   rN   rO   rF   r=   rm   rn   ro   typingoverloadr  rk   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  ro  r!   rB   c                 C  rZ   r#   r  r  r  r*   r*   r+   rF     r7   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  ri   )Nz<SubjectAlternativeName(rj   r  r3   r*   r*   r+   rk     r7   zSubjectAlternativeName.__repr__rx   ry   rz   c                 C  r{   r#   )r$   r  r|   r  r}   r*   r*   r+   r~     r   zSubjectAlternativeName.__eq__r/   c                 C  r   r#   r   r  r3   r*   r*   r+   r     r   zSubjectAlternativeName.__hash__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%   !  r   z#SubjectAlternativeName.public_bytesNr  r  r  r  r  r  r  rl   r   r<   rT   )rM   rN   rO   r   ZSUBJECT_ALTERNATIVE_NAMErA   rF   r=   rm   rn   ro   r  r  r  rk   r~   r   r%   r*   r*   r*   r+   r    &    




r  c                   @  r  )6IssuerAlternativeNamer  ro  r!   rB   c                 C  rZ   r#   r  r  r*   r*   r+   rF   (  r7   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  ri   )Nz<IssuerAlternativeName(rj   r  r3   r*   r*   r+   rk   `  r7   zIssuerAlternativeName.__repr__rx   ry   rz   c                 C  r{   r#   )r$   r  r|   r  r}   r*   r*   r+   r~   c  r   zIssuerAlternativeName.__eq__r/   c                 C  r   r#   r  r3   r*   r*   r+   r   i  r   zIssuerAlternativeName.__hash__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%   l  r   z"IssuerAlternativeName.public_bytesNr  r  r  r  r  r  r  rl   r   r<   rT   )rM   rN   rO   r   ZISSUER_ALTERNATIVE_NAMErA   rF   r=   rm   rn   ro   r  r  r  rk   r~   r   r%   r*   r*   r*   r+   r  %  r  r  c                   @  r  )6CertificateIssuerr  ro  r!   rB   c                 C  rZ   r#   r  r  r*   r*   r+   rF   s  r7   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  ri   )Nz<CertificateIssuer(rj   r  r3   r*   r*   r+   rk     r7   zCertificateIssuer.__repr__rx   ry   rz   c                 C  r{   r#   )r$   r  r|   r  r}   r*   r*   r+   r~     r   zCertificateIssuer.__eq__r/   c                 C  r   r#   r  r3   r*   r*   r+   r     r   zCertificateIssuer.__hash__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   zCertificateIssuer.public_bytesNr  r  r  r  r  r  r  rl   r   r<   rT   )rM   rN   rO   r   ZCERTIFICATE_ISSUERrA   rF   r=   rm   rn   ro   r  r  r  rk   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!   rB   c                 C  rr   )Nz*reason must be an element from ReasonFlags)r$   r   rf   _reason)r4   r  r*   r*   r+   rF     rw   zCRLReason.__init__r.   c                 C  ri   )Nz<CRLReason(reason=rj   r  r3   r*   r*   r+   rk     r7   zCRLReason.__repr__rx   ry   rz   c                 C  r{   r#   )r$   r  r|   r  r}   r*   r*   r+   r~     r   zCRLReason.__eq__r/   c                 C  r   r#   )r   r  r3   r*   r*   r+   r     r   zCRLReason.__hash__c                 C  r   r#   r  r3   r*   r*   r+   r    r   zCRLReason.reasonr"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   zCRLReason.public_bytesN)r  r   r!   rB   rl   r   r<   )r!   r   rT   )rM   rN   rO   r   Z
CRL_REASONrA   rF   rk   r~   r   r   r  r%   r*   r*   r*   r+   r        



r  c                   @  r  )InvalidityDateinvalidity_datedatetime.datetimer!   rB   c                 C  s   t |tjs
td|| _d S )Nz+invalidity_date must be a datetime.datetime)r$   datetimerf   _invalidity_date)r4   r  r*   r*   r+   rF     s   
zInvalidityDate.__init__r.   c                 C  ri   )Nz <InvalidityDate(invalidity_date=rj   r  r3   r*   r*   r+   rk     r7   zInvalidityDate.__repr__rx   ry   rz   c                 C  r{   r#   )r$   r  r|   r  r}   r*   r*   r+   r~     r   zInvalidityDate.__eq__r/   c                 C  r   r#   )r   r  r3   r*   r*   r+   r     r   zInvalidityDate.__hash__c                 C  r   r#   r  r3   r*   r*   r+   r    r   zInvalidityDate.invalidity_dater"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   zInvalidityDate.public_bytesN)r  r  r!   rB   rl   r   r<   )r!   r  rT   )rM   rN   rO   r   ZINVALIDITY_DATErA   rF   rk   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!   rB   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r[   r   rf   _signed_certificate_timestampsr4   r  r*   r*   r+   rF        
z2PrecertificateSignedCertificateTimestamps.__init__r  r.   c                 C     dt |  dS )Nz+<PrecertificateSignedCertificateTimestamps(rj   r[   r3   r*   r*   r+   rk     r   z2PrecertificateSignedCertificateTimestamps.__repr__r/   c                 C  r   r#   r   r   r  r3   r*   r*   r+   r     r7   z2PrecertificateSignedCertificateTimestamps.__hash__rx   ry   rz   c                 C  r{   r#   )r$   r  r|   r  r}   r*   r*   r+   r~        
z0PrecertificateSignedCertificateTimestamps.__eq__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   z6PrecertificateSignedCertificateTimestamps.public_bytesNr  r  r!   rB   rl   r<   r   rT   )rM   rN   rO   r   Z%PRECERT_SIGNED_CERTIFICATE_TIMESTAMPSrA   rF   r=   rm   rn   ro   rk   r   r~   r%   r*   r*   r*   r+   r        




	r  c                   @  r  )SignedCertificateTimestampsr  r  r!   rB   c                 C  r   )Nc                 s  r   r#   r  r  r*   r*   r+   r   *  r  z7SignedCertificateTimestamps.__init__.<locals>.<genexpr>r  r  r  r*   r*   r+   rF   #  r  z$SignedCertificateTimestamps.__init__r  r.   c                 C  r  )Nz<SignedCertificateTimestamps(rj   r  r3   r*   r*   r+   rk   8  r   z$SignedCertificateTimestamps.__repr__r/   c                 C  r   r#   r  r3   r*   r*   r+   r   ;  r7   z$SignedCertificateTimestamps.__hash__rx   ry   rz   c                 C  r{   r#   )r$   r  r|   r  r}   r*   r*   r+   r~   >  r  z"SignedCertificateTimestamps.__eq__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%   G  r   z(SignedCertificateTimestamps.public_bytesNr  rl   r<   r   rT   )rM   rN   rO   r   ZSIGNED_CERTIFICATE_TIMESTAMPSrA   rF   r=   rm   rn   ro   rk   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!   rB   c                 C  rr   )Nznonce must be bytes)r$   r"   rf   _nonce)r4   r  r*   r*   r+   rF   N  rw   zOCSPNonce.__init__rx   ry   rz   c                 C  r{   r#   )r$   r  r|   r  r}   r*   r*   r+   r~   T  r   zOCSPNonce.__eq__r/   c                 C  r   r#   )r   r  r3   r*   r*   r+   r   Z  r   zOCSPNonce.__hash__r.   c                 C  r   )Nz<OCSPNonce(nonce=rj   )r  r3   r*   r*   r+   rk   ]  r7   zOCSPNonce.__repr__c                 C  r   r#   )r  r3   r*   r*   r+   r  `  r   zOCSPNonce.noncec                 C  r   r#   r   r3   r*   r*   r+   r%   d  r   zOCSPNonce.public_bytesN)r  r"   r!   rB   r   r<   rl   rT   )rM   rN   rO   r   ZNONCErA   rF   r~   r   rk   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	responsesr9  r!   rB   c                 C  s,   t |}tdd |D rtd|| _d S )Nc                 s  s    | ]	}t |t V  qd S r#   r:  )r   rr*   r*   r+   r   m  s    z3OCSPAcceptableResponses.__init__.<locals>.<genexpr>z'All responses must be ObjectIdentifiers)r[   ry  rf   
_responses)r4   r  r*   r*   r+   rF   k  s   
z OCSPAcceptableResponses.__init__rx   ry   rz   c                 C  r{   r#   )r$   r  r|   r  r}   r*   r*   r+   r~   r  r   zOCSPAcceptableResponses.__eq__r/   c                 C  r   r#   )r   r   r  r3   r*   r*   r+   r   x  r7   z OCSPAcceptableResponses.__hash__r.   c                 C  ri   )Nz#<OCSPAcceptableResponses(responses=rj   )r  r3   r*   r*   r+   rk   {  r7   z OCSPAcceptableResponses.__repr__!typing.Iterator[ObjectIdentifier]c                 C  r   r#   )r8   r  r3   r*   r*   r+   rn   ~  r   z OCSPAcceptableResponses.__iter__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%     r   z$OCSPAcceptableResponses.public_bytesN)r  r9  r!   rB   r   r<   rl   )r!   r  rT   )rM   rN   rO   r   ZACCEPTABLE_RESPONSESrA   rF   r~   r   rk   rn   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_certsrz   only_contains_ca_certsonly_some_reasonsr   indirect_crlonly_contains_attribute_certsr!   rB   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    rO  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.)r[   r$   r   r   rf   r   r   r   r   rz   r1   ry  _only_contains_user_certs_only_contains_ca_certs_indirect_crl_only_contains_attribute_certs_only_some_reasonsr   r   )	r4   r   r   r  r  r  r  r  Zcrl_constraintsr*   r*   r+   rF     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=rj   )r   r   r  r  r  r  r  r3   r*   r*   r+   rk     s   
z!IssuingDistributionPoint.__repr__rx   ry   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  r|   r   r   r  r  r  r  r  r}   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  r3   r*   r*   r+   r     s   z!IssuingDistributionPoint.__hash__r   c                 C  r   r#   r  r3   r*   r*   r+   r     r   z"IssuingDistributionPoint.full_namec                 C  r   r#   r  r3   r*   r*   r+   r     r   z&IssuingDistributionPoint.relative_namec                 C  r   r#   )r  r3   r*   r*   r+   r    r   z1IssuingDistributionPoint.only_contains_user_certsc                 C  r   r#   )r  r3   r*   r*   r+   r    r   z/IssuingDistributionPoint.only_contains_ca_certsc                 C  r   r#   )r  r3   r*   r*   r+   r    r   z*IssuingDistributionPoint.only_some_reasonsc                 C  r   r#   )r  r3   r*   r*   r+   r    r   z%IssuingDistributionPoint.indirect_crlc                 C  r   r#   )r  r3   r*   r*   r+   r    r   z6IssuingDistributionPoint.only_contains_attribute_certsr"   c                 C  r   r#   r   r3   r*   r*   r+   r%   !  r   z%IssuingDistributionPoint.public_bytesN)r   r   r   r   r  rz   r  rz   r  r   r  rz   r  rz   r!   rB   rl   r   r<   r   r  r   r  rT   )rM   rN   rO   r   ZISSUING_DISTRIBUTION_POINTrA   rF   rk   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!   rB   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   rf   _template_idr/   _major_version_minor_version)r4   r  r  r  r*   r*   r+   rF   (  s   

zMSCertificateTemplate.__init__c                 C  r   r#   )r  r3   r*   r*   r+   r  <  r   z!MSCertificateTemplate.template_idc                 C  r   r#   )r  r3   r*   r*   r+   r  @  r   z#MSCertificateTemplate.major_versionc                 C  r   r#   )r  r3   r*   r*   r+   r  D  r   z#MSCertificateTemplate.minor_versionr.   c                 C  r  )Nz#<MSCertificateTemplate(template_id=z, major_version=z, minor_version=rj   )r  r  r  r3   r*   r*   r+   rk   H  r   zMSCertificateTemplate.__repr__rx   ry   rz   c                 C  r   r#   )r$   r  r|   r  r  r  r}   r*   r*   r+   r~   O  r  zMSCertificateTemplate.__eq__r/   c                 C  r  r#   )r   r  r  r  r3   r*   r*   r+   r   Y  r5  zMSCertificateTemplate.__hash__r"   c                 C  r   r#   r   r3   r*   r*   r+   r%   \  r   z"MSCertificateTemplate.public_bytesN)r  r   r  r   r  r   r!   rB   r   r   rl   r   r<   rT   )rM   rN   rO   r   ZMS_CERTIFICATE_TEMPLATErA   rF   r   r  r  r  rk   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 )!re   rA   r   rg   r"   r!   rB   c                 C  s"   t |ts	td|| _|| _d S )Nr  )r$   r   rf   r  r  )r4   rA   rg   r*   r*   r+   rF   a  s   

zUnrecognizedExtension.__init__c                 C  r   r#   r  r3   r*   r*   r+   rA   g  r   zUnrecognizedExtension.oidc                 C  r   r#   r  r3   r*   r*   r+   rg   k  r   zUnrecognizedExtension.valuer.   c                 C  s   d| j  d| jdS )Nz<UnrecognizedExtension(oid=r  rj   )rA   rg   r3   r*   r*   r+   rk   o  r{  zUnrecognizedExtension.__repr__rx   ry   rz   c                 C  r   r#   )r$   re   r|   rA   rg   r}   r*   r*   r+   r~   u  r   zUnrecognizedExtension.__eq__r/   c                 C  r   r#   )r   rA   rg   r3   r*   r*   r+   r   {  r   zUnrecognizedExtension.__hash__c                 C  r   r#   rM  r3   r*   r*   r+   r%   ~  s   z"UnrecognizedExtension.public_bytesN)rA   r   rg   r"   r!   rB   r   rT   rl   r   r<   )rM   rN   rO   rF   r   rA   rg   rk   r~   r   r%   r*   r*   r*   r+   re   `  s    



re   )r    r   r!   r"   )r-   r.   )i
__future__r   abcr  r&   rt  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?   rR   ABCMetar   rW   rp   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,  r7  r=  rF  rG  rJ  Z_TLS_FEATURE_TYPE_TO_ENUMrP  rS  rh  Genericr}  r  r  r  r  r  r  r  r  r  r  r  r  re   r*   r*   r*   r+   <module>   s   ,

'l$!!(.%%kA;+("  s0SKKK++ !;