o
    c	                     @   s  d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z
 d dlmZmZ d dlmZ d dlmZ d dlmZmZ d d	lmZ d d
lmZmZmZmZmZmZmZmZm Z  d dl!m"Z"m#Z# d dl$m%Z%m&Z&m'Z'm(Z( ej)ddddZ*dede+fddZ,de-fddZ.G dd de/Z0G dd de/Z1G dd de j2dZ3G dd dZ4G d d! d!e3Z5G d"d# d#e3Z6G d$d% d%e3Z7G d&d' d'e3Z8G d(d) d)e3Z9G d*d+ d+Z:G d,d- d-e3Z;G d.d/ d/e3Z<G d0d1 d1e3Z=G d2d3 d3e3Z>G d4d5 d5Z?G d6d7 d7ej@ZAeAjBeAjCeAjDeAjEeAjFeAjGeAjHeAjId8ZJeAjBd9eAjCd:eAjDd;eAjEd<eAjFd=eAjGd>eAjHd?eAjId@iZKG dAdB dBe3ZLG dCdD dDe3ZMG dEdF dFZNG dGdH dHZOG dIdJ dJZPG dKdL dLe3ZQG dMdN dNe3ZRG dOdP dPe3ZSG dQdR dRe3ZTG dSdT dTej@ZUdUdV eUD ZVG dWdX dXe3ZWG dYdZ dZe3ZXG d[d\ d\e3ZYG d]d^ d^ejZe* Z[G d_d` d`Z\G dadb dbe3Z]G dcdd dde3Z^G dedf dfe3Z_G dgdh dhe3Z`G didj dje3ZaG dkdl dle3ZbG dmdn dne3ZcG dodp dpe3ZdG dqdr dre3ZeG dsdt dte3ZfdS )u    N)utils)asn1)x509)constant_timeserialization)EllipticCurvePublicKey)RSAPublicKey)#CERTIFICATE_ISSUER_PUBLIC_KEY_TYPESCERTIFICATE_PUBLIC_KEY_TYPES)SignedCertificateTimestamp)	_IPADDRESS_TYPESDirectoryNameDNSNameGeneralName	IPAddress	OtherNameRegisteredID
RFC822NameUniformResourceIdentifier)NameRelativeDistinguishedName)CRLEntryExtensionOIDExtensionOIDObjectIdentifierOCSPExtensionOIDExtensionTypeVarExtensionTypeT)bound	covariant
public_keyreturnc                 C   sl   t | tr| tjjtjj}nt | tr | tjj	tjj
}n| tjjtjj}t|}t| S N)
isinstancer   public_bytesr   EncodingDERPublicFormatPKCS1r   X962UncompressedPointSubjectPublicKeyInfor   parse_spki_for_datahashlibsha1digest)r   data
serialized r1   I/opt/certbot/lib/python3.10/site-packages/cryptography/x509/extensions.py_key_identifier_from_public_key1   s    


r3   
field_namec                    s4   dt f fdd} fdd} fdd}|||fS )Nr    c                       t t|  S r!   )lengetattrselfr4   r1   r2   
len_methodJ      z*_make_sequence_methods.<locals>.len_methodc                    r5   r!   )iterr7   r8   r:   r1   r2   iter_methodM   r<   z+_make_sequence_methods.<locals>.iter_methodc                    s   t |  | S r!   )r7   )r9   idxr:   r1   r2   getitem_methodP   r<   z._make_sequence_methods.<locals>.getitem_method)int)r4   r;   r>   r@   r1   r:   r2   _make_sequence_methodsI   s   
rB   c                       *   e Zd Zdededdf fddZ  ZS )DuplicateExtensionmsgoidr    Nc                       t t| | || _d S r!   )superrD   __init__rF   r9   rE   rF   	__class__r1   r2   rI   W      
zDuplicateExtension.__init____name__
__module____qualname__strr   rI   __classcell__r1   r1   rK   r2   rD   V       "rD   c                       rC   )ExtensionNotFoundrE   rF   r    Nc                    rG   r!   )rH   rU   rI   rF   rJ   rK   r1   r2   rI   ]   rM   zExtensionNotFound.__init__rN   r1   r1   rK   r2   rU   \   rT   rU   c                   @   s*   e Zd ZU eje ed< defddZdS )r   rF   r    c                 C   s   t d| )z7
        Serializes the extension type to DER.
        z8public_bytes is not implemented for extension type {0!r})NotImplementedErrorformatr8   r1   r1   r2   r#   e   s
   zExtensionType.public_bytesN)	rO   rP   rQ   typingClassVarr   __annotations__bytesr#   r1   r1   r1   r2   r   b   s   
 )	metaclassc                   @   sj   e Zd Zdejd ddfddZdeddfdd	Zd
eje	 ddfddZ
ed\ZZZdefddZdS )
Extensions
extensionszExtension[ExtensionType]r    Nc                 C      t || _d S r!   )list_extensions)r9   r^   r1   r1   r2   rI   q   s   zExtensions.__init__rF   c                 C   s,   | D ]}|j |kr|  S qtd||)NNo {} extension was found)rF   rU   rW   )r9   rF   extr1   r1   r2   get_extension_for_oidv   s
   
z Extensions.get_extension_for_oidextclasszExtension[ExtensionTypeVar]c                 C   s@   |t u rtd| D ]}t|j|r|  S q
td||j)Nz|UnrecognizedExtension can't be used with get_extension_for_class because more than one instance of the class may be present.rb   )UnrecognizedExtension	TypeErrorr"   valuerU   rW   rF   )r9   re   rc   r1   r1   r2   get_extension_for_class   s   z"Extensions.get_extension_for_classra   c                 C      d | jS )Nz<Extensions({})>)rW   ra   r8   r1   r1   r2   __repr__      zExtensions.__repr__)rO   rP   rQ   rX   IterablerI   r   rd   Typer   ri   rB   __len____iter____getitem__rR   rk   r1   r1   r1   r2   r]   p   s$    

	
r]   c                   @   sr   e Zd ZejZdeddfddZdede	fddZ
defd	d
ZdefddZedefddZdefddZdS )	CRLNumber
crl_numberr    Nc                 C      t |ts	td|| _d S Nzcrl_number must be an integerr"   rA   rg   _crl_numberr9   rs   r1   r1   r2   rI         

zCRLNumber.__init__otherc                 C      t |tstS | j|jkS r!   )r"   rr   NotImplementedrs   r9   rz   r1   r1   r2   __eq__      
zCRLNumber.__eq__c                 C   
   t | jS r!   hashrs   r8   r1   r1   r2   __hash__      
zCRLNumber.__hash__c                 C   rj   )Nz<CRLNumber({})>)rW   rs   r8   r1   r1   r2   rk      rl   zCRLNumber.__repr__c                 C      | j S r!   rw   r8   r1   r1   r2   rs         zCRLNumber.crl_numberc                 C   
   t | S r!   	rust_x509encode_extension_valuer8   r1   r1   r2   r#      r   zCRLNumber.public_bytes)rO   rP   rQ   r   
CRL_NUMBERrF   rA   rI   objectboolr~   r   rR   rk   propertyrs   r[   r#   r1   r1   r1   r2   rr          rr   c                   @   s   e Zd ZejZdeje dejej	e
  deje ddfddZededd fd	d
Ze				 dddZdefddZdedefddZdefddZedeje fddZedejeje
  fddZedeje fddZdefddZdS )AuthorityKeyIdentifierkey_identifierauthority_cert_issuerauthority_cert_serial_numberr    Nc                 C   sr   |d u |d u krt d|d ur!t|}tdd |D s!td|d ur.t|ts.td|| _|| _|| _d S )NzXauthority_cert_issuer and authority_cert_serial_number must both be present or both Nonec                 s       | ]}t |tV  qd S r!   r"   r   .0xr1   r1   r2   	<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`   allrg   r"   rA   _key_identifier_authority_cert_issuer_authority_cert_serial_number)r9   r   r   r   r1   r1   r2   rI      s*   

zAuthorityKeyIdentifier.__init__r   c                 C   s   t |}| |d d dS N)r   r   r   r3   )clsr   r.   r1   r1   r2   from_issuer_public_key   s   z-AuthorityKeyIdentifier.from_issuer_public_keyskiSubjectKeyIdentifierc                 C   s   | |j d d dS r   )r.   )r   r   r1   r1   r2   "from_issuer_subject_key_identifier   s
   z9AuthorityKeyIdentifier.from_issuer_subject_key_identifierc                 C   
   d | S )Nz<AuthorityKeyIdentifier(key_identifier={0.key_identifier!r}, authority_cert_issuer={0.authority_cert_issuer}, authority_cert_serial_number={0.authority_cert_serial_number})>rW   r8   r1   r1   r2   rk      s   zAuthorityKeyIdentifier.__repr__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}   r1   r1   r2   r~      s   

zAuthorityKeyIdentifier.__eq__c                 C   s,   | j d u rd }nt| j }t| j|| jfS r!   )r   tupler   r   r   )r9   acir1   r1   r2   r     s   

zAuthorityKeyIdentifier.__hash__c                 C   r   r!   )r   r8   r1   r1   r2   r     r   z%AuthorityKeyIdentifier.key_identifierc                 C   r   r!   )r   r8   r1   r1   r2   r        z,AuthorityKeyIdentifier.authority_cert_issuerc                 C   r   r!   )r   r8   r1   r1   r2   r     r   z3AuthorityKeyIdentifier.authority_cert_serial_numberc                 C   r   r!   r   r8   r1   r1   r2   r#     r   z#AuthorityKeyIdentifier.public_bytes)r   r   r    r   )rO   rP   rQ   r   AUTHORITY_KEY_IDENTIFIERrF   rX   Optionalr[   rm   r   rA   rI   classmethodr	   r   r   rR   rk   r   r   r~   r   r   r   Listr   r   r#   r1   r1   r1   r2   r      sF    
&
		r   c                   @   s   e Zd ZejZdeddfddZede	dd fddZ
edefd	d
ZedefddZdefddZdedefddZdefddZdefddZdS )r   r.   r    Nc                 C   s
   || _ d S r!   _digest)r9   r.   r1   r1   r2   rI   #  r   zSubjectKeyIdentifier.__init__r   c                 C   s   | t |S r!   r   )r   r   r1   r1   r2   from_public_key&  s   z$SubjectKeyIdentifier.from_public_keyc                 C   r   r!   r   r8   r1   r1   r2   r.   ,  r   zSubjectKeyIdentifier.digestc                 C   r   r!   r   r8   r1   r1   r2   r   0  r   z#SubjectKeyIdentifier.key_identifierc                 C   rj   )Nz$<SubjectKeyIdentifier(digest={0!r})>)rW   r.   r8   r1   r1   r2   rk   4  rl   zSubjectKeyIdentifier.__repr__rz   c                 C   s   t |tstS t| j|jS r!   )r"   r   r|   r   bytes_eqr.   r}   r1   r1   r2   r~   7  s   
zSubjectKeyIdentifier.__eq__c                 C   r   r!   )r   r.   r8   r1   r1   r2   r   =  r   zSubjectKeyIdentifier.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r#   @  r   z!SubjectKeyIdentifier.public_bytes)rO   rP   rQ   r   SUBJECT_KEY_IDENTIFIERrF   r[   rI   r   r
   r   r   r.   r   rR   rk   r   r   r~   rA   r   r#   r1   r1   r1   r2   r      s"    r   c                   @   t   e Zd ZejZdejd ddfddZe	d\Z
ZZdefdd	Zd
edefddZdefddZdefddZdS )AuthorityInformationAccessdescriptionsAccessDescriptionr    Nc                 C   ,   t |}tdd |D std|| _d S )Nc                 s   r   r!   r"   r   r   r1   r1   r2   r   K      z6AuthorityInformationAccess.__init__.<locals>.<genexpr>@Every item in the descriptions list must be an AccessDescriptionr`   r   rg   _descriptionsr9   r   r1   r1   r2   rI   G     
z#AuthorityInformationAccess.__init__r   c                 C   rj   )Nz <AuthorityInformationAccess({})>rW   r   r8   r1   r1   r2   rk   U  rl   z#AuthorityInformationAccess.__repr__rz   c                 C   r{   r!   )r"   r   r|   r   r}   r1   r1   r2   r~   X  r   z!AuthorityInformationAccess.__eq__c                 C      t t| jS r!   r   r   r   r8   r1   r1   r2   r   ^  r<   z#AuthorityInformationAccess.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r#   a  r   z'AuthorityInformationAccess.public_bytes)rO   rP   rQ   r   AUTHORITY_INFORMATION_ACCESSrF   rX   rm   rI   rB   ro   rp   rq   rR   rk   r   r   r~   rA   r   r[   r#   r1   r1   r1   r2   r   D      
r   c                   @   r   )SubjectInformationAccessr   r   r    Nc                 C   r   )Nc                 s   r   r!   r   r   r1   r1   r2   r   l  r   z4SubjectInformationAccess.__init__.<locals>.<genexpr>r   r   r   r1   r1   r2   rI   h  r   z!SubjectInformationAccess.__init__r   c                 C   rj   )Nz<SubjectInformationAccess({})>r   r8   r1   r1   r2   rk   v  rl   z!SubjectInformationAccess.__repr__rz   c                 C   r{   r!   )r"   r   r|   r   r}   r1   r1   r2   r~   y  r   zSubjectInformationAccess.__eq__c                 C   r   r!   r   r8   r1   r1   r2   r     r<   z!SubjectInformationAccess.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r#     r   z%SubjectInformationAccess.public_bytes)rO   rP   rQ   r   SUBJECT_INFORMATION_ACCESSrF   rX   rm   rI   rB   ro   rp   rq   rR   rk   r   r   r~   rA   r   r[   r#   r1   r1   r1   r2   r   e  r   r   c                   @   st   e Zd ZdededdfddZdefddZd	ede	fd
dZ
defddZedefddZedefddZdS )r   access_methodaccess_locationr    Nc                 C   s4   t |ts	tdt |tstd|| _|| _d S )Nz)access_method must be an ObjectIdentifierz%access_location must be a GeneralName)r"   r   rg   r   _access_method_access_location)r9   r   r   r1   r1   r2   rI     s   


zAccessDescription.__init__c                 C   r   )NzY<AccessDescription(access_method={0.access_method}, access_location={0.access_location})>r   r8   r1   r1   r2   rk        zAccessDescription.__repr__rz   c                 C   &   t |tstS | j|jko| j|jkS r!   )r"   r   r|   r   r   r}   r1   r1   r2   r~     
   

zAccessDescription.__eq__c                 C      t | j| jfS r!   )r   r   r   r8   r1   r1   r2   r        zAccessDescription.__hash__c                 C   r   r!   )r   r8   r1   r1   r2   r     r   zAccessDescription.access_methodc                 C   r   r!   )r   r8   r1   r1   r2   r     r   z!AccessDescription.access_location)rO   rP   rQ   r   r   rI   rR   rk   r   r   r~   rA   r   r   r   r   r1   r1   r1   r2   r     s    
	r   c                   @   s   e Zd ZejZdedeje	 ddfddZ
edefddZedeje	 fd	d
ZdefddZdedefddZde	fddZdefddZdS )BasicConstraintscapath_lengthr    Nc                 C   sX   t |ts	td|d ur|std|d ur$t |tr |dk r$td|| _|| _d S )Nzca must be a boolean valuez)path_length must be None when ca is Falser   z2path_length must be a non-negative integer or None)r"   r   rg   r   rA   _ca_path_length)r9   r   r   r1   r1   r2   rI     s   

zBasicConstraints.__init__c                 C   r   r!   )r   r8   r1   r1   r2   r     r   zBasicConstraints.cac                 C   r   r!   )r   r8   r1   r1   r2   r     r   zBasicConstraints.path_lengthc                 C   r   )Nz:<BasicConstraints(ca={0.ca}, path_length={0.path_length})>r   r8   r1   r1   r2   rk     r   zBasicConstraints.__repr__rz   c                 C   r   r!   )r"   r   r|   r   r   r}   r1   r1   r2   r~        
zBasicConstraints.__eq__c                 C   r   r!   )r   r   r   r8   r1   r1   r2   r     r   zBasicConstraints.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r#     r   zBasicConstraints.public_bytes)rO   rP   rQ   r   BASIC_CONSTRAINTSrF   r   rX   r   rA   rI   r   r   r   rR   rk   r   r~   r   r[   r#   r1   r1   r1   r2   r     s    r   c                   @   sr   e Zd ZejZdeddfddZedefddZ	de
defd	d
ZdefddZdefddZdefddZdS )DeltaCRLIndicatorrs   r    Nc                 C   rt   ru   rv   rx   r1   r1   r2   rI     ry   zDeltaCRLIndicator.__init__c                 C   r   r!   r   r8   r1   r1   r2   rs     r   zDeltaCRLIndicator.crl_numberrz   c                 C   r{   r!   )r"   r   r|   rs   r}   r1   r1   r2   r~     r   zDeltaCRLIndicator.__eq__c                 C   r   r!   r   r8   r1   r1   r2   r     r   zDeltaCRLIndicator.__hash__c                 C   r   )Nz.<DeltaCRLIndicator(crl_number={0.crl_number})>r   r8   r1   r1   r2   rk     r   zDeltaCRLIndicator.__repr__c                 C   r   r!   r   r8   r1   r1   r2   r#     r   zDeltaCRLIndicator.public_bytes)rO   rP   rQ   r   DELTA_CRL_INDICATORrF   rA   rI   r   rs   r   r   r~   r   rR   rk   r[   r#   r1   r1   r1   r2   r     s    r   c                   @   r   )CRLDistributionPointsdistribution_pointsDistributionPointr    Nc                 C   r   )Nc                 s   r   r!   r"   r   r   r1   r1   r2   r      r   z1CRLDistributionPoints.__init__.<locals>.<genexpr>?distribution_points must be a list of DistributionPoint objectsr`   r   rg   _distribution_pointsr9   r   r1   r1   r2   rI        
zCRLDistributionPoints.__init__r   c                 C   rj   )Nz<CRLDistributionPoints({})>rW   r   r8   r1   r1   r2   rk     rl   zCRLDistributionPoints.__repr__rz   c                 C   r{   r!   )r"   r   r|   r   r}   r1   r1   r2   r~     r   zCRLDistributionPoints.__eq__c                 C   r   r!   r   r   r   r8   r1   r1   r2   r     r<   zCRLDistributionPoints.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r#     r   z"CRLDistributionPoints.public_bytes)rO   rP   rQ   r   CRL_DISTRIBUTION_POINTSrF   rX   rm   rI   rB   ro   rp   rq   rR   rk   r   r   r~   rA   r   r[   r#   r1   r1   r1   r2   r         

r   c                   @   r   )FreshestCRLr   r   r    Nc                 C   r   )Nc                 s   r   r!   r   r   r1   r1   r2   r   %  r   z'FreshestCRL.__init__.<locals>.<genexpr>r   r   r   r1   r1   r2   rI   !  r   zFreshestCRL.__init__r   c                 C   rj   )Nz<FreshestCRL({})>r   r8   r1   r1   r2   rk   3  rl   zFreshestCRL.__repr__rz   c                 C   r{   r!   )r"   r   r|   r   r}   r1   r1   r2   r~   6  r   zFreshestCRL.__eq__c                 C   r   r!   r   r8   r1   r1   r2   r   <  r<   zFreshestCRL.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r#   ?  r   zFreshestCRL.public_bytes)rO   rP   rQ   r   FRESHEST_CRLrF   rX   rm   rI   rB   ro   rp   rq   rR   rk   r   r   r~   rA   r   r[   r#   r1   r1   r1   r2   r     r   r   c                
   @   s   e Zd Zdejeje  deje dejejd  dejeje  ddf
dd	Z	de
fd
dZdedefddZdefddZedejeje  fddZedeje fddZedejejd  fddZedejeje  fddZdS )r   	full_namerelative_namereasonsReasonFlags
crl_issuerr    Nc                 C   s   |r|rt d|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   r1   r1   r2   r   X  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   r1   r1   r2   r   e  r   z2crl_issuer must be None or a list of general namesc                 s   r   r!   r"   r   r   r1   r1   r2   r   l  r   z0reasons must be None or frozenset of ReasonFlagszLunspecified and remove_from_crl are not valid reasons in a DistributionPoint)r   r`   r   rg   r"   r   	frozensetr   unspecifiedremove_from_crl
_full_name_relative_name_reasons_crl_issuer)r9   r   r   r   r   r1   r1   r2   rI   D  sV   

zDistributionPoint.__init__c                 C   r   )Nz}<DistributionPoint(full_name={0.full_name}, relative_name={0.relative_name}, reasons={0.reasons}, crl_issuer={0.crl_issuer})>r   r8   r1   r1   r2   rk   ~     zDistributionPoint.__repr__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}   r1   r1   r2   r~     s   



zDistributionPoint.__eq__c                 C   sH   | j d urt| j }nd }| jd urt| j}nd }t|| j| j|fS r!   )r   r   r   r   r   r   )r9   fnr   r1   r1   r2   r     s   

zDistributionPoint.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r     r   zDistributionPoint.full_namec                 C   r   r!   r   r8   r1   r1   r2   r     r   zDistributionPoint.relative_namec                 C   r   r!   )r   r8   r1   r1   r2   r     r   zDistributionPoint.reasonsc                 C   r   r!   )r   r8   r1   r1   r2   r     r   zDistributionPoint.crl_issuer)rO   rP   rQ   rX   r   rm   r   r   	FrozenSetrI   rR   rk   r   r   r~   rA   r   r   r   r   r   r   r   r1   r1   r1   r2   r   C  s.    
: r   c                   @   s4   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdS )r   r   keyCompromisecACompromiseaffiliationChanged
supersededcessationOfOperationcertificateHoldprivilegeWithdrawnaACompromiseremoveFromCRLN)rO   rP   rQ   r   key_compromiseca_compromiseaffiliation_changedr   cessation_of_operationcertificate_holdprivilege_withdrawnaa_compromiser   r1   r1   r1   r2   r     s    r   )                        r  r  r  r  r  r  r  r  c                   @   s   e Zd ZejZdeje deje ddfddZ	de
fddZd	edefd
dZdefddZedeje fddZedeje fddZdefddZdS )PolicyConstraintsrequire_explicit_policyinhibit_policy_mappingr    Nc                 C   s\   |d urt |tstd|d urt |tstd|d u r&|d u r&td|| _|| _d S )Nz>require_explicit_policy must be a non-negative integer or Nonez=inhibit_policy_mapping must be a non-negative integer or NonezSAt least one of require_explicit_policy and inhibit_policy_mapping must not be None)r"   rA   rg   r   _require_explicit_policy_inhibit_policy_mapping)r9   r  r  r1   r1   r2   rI     s$   


zPolicyConstraints.__init__c                 C   r   )Nz{<PolicyConstraints(require_explicit_policy={0.require_explicit_policy}, inhibit_policy_mapping={0.inhibit_policy_mapping})>r   r8   r1   r1   r2   rk     r   zPolicyConstraints.__repr__rz   c                 C   r   r!   )r"   r  r|   r  r  r}   r1   r1   r2   r~   	  r   zPolicyConstraints.__eq__c                 C   r   r!   )r   r  r  r8   r1   r1   r2   r     s   
zPolicyConstraints.__hash__c                 C   r   r!   )r  r8   r1   r1   r2   r    r   z)PolicyConstraints.require_explicit_policyc                 C   r   r!   )r  r8   r1   r1   r2   r    r   z(PolicyConstraints.inhibit_policy_mappingc                 C   r   r!   r   r8   r1   r1   r2   r#     r   zPolicyConstraints.public_bytes)rO   rP   rQ   r   POLICY_CONSTRAINTSrF   rX   r   rA   rI   rR   rk   r   r   r~   r   r   r  r  r[   r#   r1   r1   r1   r2   r    s"    
	r  c                   @   r   )CertificatePoliciespoliciesPolicyInformationr    Nc                 C   r   )Nc                 s   r   r!   )r"   r  r   r1   r1   r2   r   (  r   z/CertificatePolicies.__init__.<locals>.<genexpr>z;Every item in the policies list must be a PolicyInformation)r`   r   rg   	_policies)r9   r  r1   r1   r2   rI   &     
zCertificatePolicies.__init__r  c                 C   rj   )Nz<CertificatePolicies({})>)rW   r  r8   r1   r1   r2   rk   2  rl   zCertificatePolicies.__repr__rz   c                 C   r{   r!   )r"   r  r|   r  r}   r1   r1   r2   r~   5  r   zCertificatePolicies.__eq__c                 C   r   r!   )r   r   r  r8   r1   r1   r2   r   ;  r<   zCertificatePolicies.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r#   >  r   z CertificatePolicies.public_bytes)rO   rP   rQ   r   CERTIFICATE_POLICIESrF   rX   rm   rI   rB   ro   rp   rq   rR   rk   r   r   r~   rA   r   r[   r#   r1   r1   r1   r2   r  #  s    
r  c                   @   s   e Zd Zdedejejejedf   ddfddZ	defdd	Z
d
edefddZdefddZedefddZedejejejedf   fddZdS )r  policy_identifierpolicy_qualifiers
UserNoticer    Nc                 C   sL   t |ts	td|| _|d ur!t|}tdd |D s!td|| _d S )Nz-policy_identifier must be an ObjectIdentifierc                 s   s    | ]
}t |ttfV  qd S r!   )r"   rR   r#  r   r1   r1   r2   r   Q  s    
z-PolicyInformation.__init__.<locals>.<genexpr>zMpolicy_qualifiers must be a list of strings and/or UserNotice objects or None)r"   r   rg   _policy_identifierr`   r   _policy_qualifiers)r9   r!  r"  r1   r1   r2   rI   C  s   

zPolicyInformation.__init__c                 C   r   )Nze<PolicyInformation(policy_identifier={0.policy_identifier}, policy_qualifiers={0.policy_qualifiers})>r   r8   r1   r1   r2   rk   [  r   zPolicyInformation.__repr__rz   c                 C   r   r!   )r"   r  r|   r!  r"  r}   r1   r1   r2   r~   a  r   zPolicyInformation.__eq__c                 C   s(   | j d urt| j }nd }t| j|fS r!   )r"  r   r   r!  )r9   pqr1   r1   r2   r   j  s
   
zPolicyInformation.__hash__c                 C   r   r!   )r$  r8   r1   r1   r2   r!  t  r   z#PolicyInformation.policy_identifierc                 C   r   r!   )r%  r8   r1   r1   r2   r"  x  r   z#PolicyInformation.policy_qualifiers)rO   rP   rQ   r   rX   r   rm   UnionrR   rI   rk   r   r   r~   rA   r   r   r!  r   r"  r1   r1   r1   r2   r  B  s&    
	
r  c                   @   s   e Zd Zdejd deje ddfddZdefdd	Zd
ede	fddZ
defddZedejd fddZedeje fddZdS )r#  notice_referenceNoticeReferenceexplicit_textr    Nc                 C   s&   |rt |tstd|| _|| _d S )Nz2notice_reference must be None or a NoticeReference)r"   r)  rg   _notice_reference_explicit_text)r9   r(  r*  r1   r1   r2   rI     s   
zUserNotice.__init__c                 C   r   )NzV<UserNotice(notice_reference={0.notice_reference}, explicit_text={0.explicit_text!r})>r   r8   r1   r1   r2   rk     r   zUserNotice.__repr__rz   c                 C   r   r!   )r"   r#  r|   r(  r*  r}   r1   r1   r2   r~     r   zUserNotice.__eq__c                 C   r   r!   )r   r(  r*  r8   r1   r1   r2   r     r   zUserNotice.__hash__c                 C   r   r!   )r+  r8   r1   r1   r2   r(    r   zUserNotice.notice_referencec                 C   r   r!   )r,  r8   r1   r1   r2   r*    r   zUserNotice.explicit_text)rO   rP   rQ   rX   r   rR   rI   rk   r   r   r~   rA   r   r   r(  r*  r1   r1   r1   r2   r#    s    
	r#  c                   @   s   e Zd Zdeje deje ddfddZdefddZ	d	e
defd
dZdefddZedeje fddZedeje fddZdS )r)  organizationnotice_numbersr    Nc                 C   s2   || _ t|}tdd |D std|| _d S )Nc                 s   r   r!   )r"   rA   r   r1   r1   r2   r     r   z+NoticeReference.__init__.<locals>.<genexpr>z)notice_numbers must be a list of integers)_organizationr`   r   rg   _notice_numbers)r9   r-  r.  r1   r1   r2   rI     s
   
zNoticeReference.__init__c                 C   r   )NzU<NoticeReference(organization={0.organization!r}, notice_numbers={0.notice_numbers})>r   r8   r1   r1   r2   rk     r   zNoticeReference.__repr__rz   c                 C   r   r!   )r"   r)  r|   r-  r.  r}   r1   r1   r2   r~     r   zNoticeReference.__eq__c                 C   s   t | jt| jfS r!   )r   r-  r   r.  r8   r1   r1   r2   r        zNoticeReference.__hash__c                 C   r   r!   )r/  r8   r1   r1   r2   r-    r   zNoticeReference.organizationc                 C   r   r!   )r0  r8   r1   r1   r2   r.    r   zNoticeReference.notice_numbers)rO   rP   rQ   rX   r   rR   rm   rA   rI   rk   r   r   r~   r   r   r-  r   r.  r1   r1   r1   r2   r)    s    
	r)  c                   @   st   e Zd ZejZdeje ddfddZ	e
d\ZZZdefddZd	edefd
dZdefddZdefddZdS )ExtendedKeyUsageusagesr    Nc                 C   r   )Nc                 s   r   r!   )r"   r   r   r1   r1   r2   r     r   z,ExtendedKeyUsage.__init__.<locals>.<genexpr>z9Every item in the usages list must be an ObjectIdentifier)r`   r   rg   _usages)r9   r3  r1   r1   r2   rI     s   
zExtendedKeyUsage.__init__r4  c                 C   rj   )Nz<ExtendedKeyUsage({})>)rW   r4  r8   r1   r1   r2   rk     rl   zExtendedKeyUsage.__repr__rz   c                 C   r{   r!   )r"   r2  r|   r4  r}   r1   r1   r2   r~     r   zExtendedKeyUsage.__eq__c                 C   r   r!   )r   r   r4  r8   r1   r1   r2   r     r<   zExtendedKeyUsage.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r#     r   zExtendedKeyUsage.public_bytes)rO   rP   rQ   r   EXTENDED_KEY_USAGErF   rX   rm   r   rI   rB   ro   rp   rq   rR   rk   r   r   r~   rA   r   r[   r#   r1   r1   r1   r2   r2    s    	r2  c                   @   N   e Zd ZejZdedefddZde	fddZ
defddZdefd	d
ZdS )OCSPNoCheckrz   r    c                 C      t |tstS dS NT)r"   r7  r|   r}   r1   r1   r2   r~        
zOCSPNoCheck.__eq__c                 C      t tS r!   )r   r7  r8   r1   r1   r2   r        zOCSPNoCheck.__hash__c                 C      dS )Nz<OCSPNoCheck()>r1   r8   r1   r1   r2   rk        zOCSPNoCheck.__repr__c                 C   r   r!   r   r8   r1   r1   r2   r#     r   zOCSPNoCheck.public_bytesN)rO   rP   rQ   r   OCSP_NO_CHECKrF   r   r   r~   rA   r   rR   rk   r[   r#   r1   r1   r1   r2   r7        r7  c                   @   r6  )PrecertPoisonrz   r    c                 C   r8  r9  )r"   rA  r|   r}   r1   r1   r2   r~     r:  zPrecertPoison.__eq__c                 C   r;  r!   )r   rA  r8   r1   r1   r2   r     r<  zPrecertPoison.__hash__c                 C   r=  )Nz<PrecertPoison()>r1   r8   r1   r1   r2   rk     r>  zPrecertPoison.__repr__c                 C   r   r!   r   r8   r1   r1   r2   r#     r   zPrecertPoison.public_bytesN)rO   rP   rQ   r   PRECERT_POISONrF   r   r   r~   rA   r   rR   rk   r[   r#   r1   r1   r1   r2   rA    r@  rA  c                   @   r   )
TLSFeaturefeaturesTLSFeatureTyper    Nc                 C   s8   t |}tdd |D rt|dkrtd|| _d S )Nc                 s   r   r!   )r"   rE  r   r1   r1   r2   r     r   z&TLSFeature.__init__.<locals>.<genexpr>r   z@features must be a list of elements from the TLSFeatureType enum)r`   r   r6   rg   	_features)r9   rD  r1   r1   r2   rI     s   

zTLSFeature.__init__rF  c                 C   r   )Nz$<TLSFeature(features={0._features})>r   r8   r1   r1   r2   rk   (  r   zTLSFeature.__repr__rz   c                 C   r{   r!   )r"   rC  r|   rF  r}   r1   r1   r2   r~   +  r   zTLSFeature.__eq__c                 C   r   r!   )r   r   rF  r8   r1   r1   r2   r   1  r<   zTLSFeature.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r#   4  r   zTLSFeature.public_bytes)rO   rP   rQ   r   TLS_FEATURErF   rX   rm   rI   rB   ro   rp   rq   rR   rk   r   r   r~   rA   r   r[   r#   r1   r1   r1   r2   rC    s    rC  c                   @   s   e Zd ZdZdZdS )rE  r     N)rO   rP   rQ   status_requeststatus_request_v2r1   r1   r1   r2   rE  8  s    rE  c                 C   s   i | ]}|j |qS r1   rh   r   r1   r1   r2   
<dictcomp>C      rL  c                   @   sr   e Zd ZejZdeddfddZdefddZ	de
defd	d
ZdefddZedefddZdefddZdS )InhibitAnyPolicy
skip_certsr    Nc                 C   s,   t |ts	td|dk rtd|| _d S )Nzskip_certs must be an integerr   z)skip_certs must be a non-negative integer)r"   rA   rg   r   _skip_certs)r9   rO  r1   r1   r2   rI   I  s
   

zInhibitAnyPolicy.__init__c                 C   r   )Nz-<InhibitAnyPolicy(skip_certs={0.skip_certs})>r   r8   r1   r1   r2   rk   R  r   zInhibitAnyPolicy.__repr__rz   c                 C   r{   r!   )r"   rN  r|   rO  r}   r1   r1   r2   r~   U  r   zInhibitAnyPolicy.__eq__c                 C   r   r!   )r   rO  r8   r1   r1   r2   r   [  r   zInhibitAnyPolicy.__hash__c                 C   r   r!   )rP  r8   r1   r1   r2   rO  ^  r   zInhibitAnyPolicy.skip_certsc                 C   r   r!   r   r8   r1   r1   r2   r#   b  r   zInhibitAnyPolicy.public_bytes)rO   rP   rQ   r   INHIBIT_ANY_POLICYrF   rA   rI   rR   rk   r   r   r~   r   r   rO  r[   r#   r1   r1   r1   r2   rN  F  s    	rN  c                   @   s"  e Zd ZejZdedededededededed	ed
dfddZed
efddZ	ed
efddZ
ed
efddZed
efddZed
efddZed
efddZed
efddZed
efddZed
efddZd
efd d!Zd"ed
efd#d$Zd
efd%d&Zd
efd'd(ZdS ))KeyUsagedigital_signaturecontent_commitmentkey_enciphermentdata_enciphermentkey_agreementkey_cert_signcrl_signencipher_onlydecipher_onlyr    Nc
           
      C   sN   |s
|s|	r
t d|| _|| _|| _|| _|| _|| _|| _|| _|	| _	d S )NzKencipher_only and decipher_only can only be true when key_agreement is true)
r   _digital_signature_content_commitment_key_encipherment_data_encipherment_key_agreement_key_cert_sign	_crl_sign_encipher_only_decipher_only)
r9   rS  rT  rU  rV  rW  rX  rY  rZ  r[  r1   r1   r2   rI   i  s   
zKeyUsage.__init__c                 C   r   r!   )r\  r8   r1   r1   r2   rS    r   zKeyUsage.digital_signaturec                 C   r   r!   )r]  r8   r1   r1   r2   rT    r   zKeyUsage.content_commitmentc                 C   r   r!   )r^  r8   r1   r1   r2   rU    r   zKeyUsage.key_enciphermentc                 C   r   r!   )r_  r8   r1   r1   r2   rV    r   zKeyUsage.data_enciphermentc                 C   r   r!   )r`  r8   r1   r1   r2   rW    r   zKeyUsage.key_agreementc                 C   r   r!   )ra  r8   r1   r1   r2   rX    r   zKeyUsage.key_cert_signc                 C   r   r!   )rb  r8   r1   r1   r2   rY    r   zKeyUsage.crl_signc                 C      | j std| jS )Nz7encipher_only is undefined unless key_agreement is true)rW  r   rc  r8   r1   r1   r2   rZ    
   zKeyUsage.encipher_onlyc                 C   re  )Nz7decipher_only is undefined unless key_agreement is true)rW  r   rd  r8   r1   r1   r2   r[    rf  zKeyUsage.decipher_onlyc                 C   s:   z| j }| j}W n ty   d}d}Y nw d| ||S )NFa-  <KeyUsage(digital_signature={0.digital_signature}, content_commitment={0.content_commitment}, key_encipherment={0.key_encipherment}, data_encipherment={0.data_encipherment}, key_agreement={0.key_agreement}, key_cert_sign={0.key_cert_sign}, crl_sign={0.crl_sign}, encipher_only={1}, decipher_only={2})>)rZ  r[  r   rW   )r9   rZ  r[  r1   r1   r2   rk     s   

zKeyUsage.__repr__rz   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"   rR  r|   rS  rT  rU  rV  rW  rX  rY  rc  rd  r}   r1   r1   r2   r~     s&   








zKeyUsage.__eq__c              
   C   s,   t | j| j| j| j| j| j| j| j| j	f	S r!   )
r   rS  rT  rU  rV  rW  rX  rY  rc  rd  r8   r1   r1   r2   r     s   zKeyUsage.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r#     r   zKeyUsage.public_bytes)rO   rP   rQ   r   	KEY_USAGErF   r   rI   r   rS  rT  rU  rV  rW  rX  rY  rZ  r[  rR   rk   r   r~   rA   r   r[   r#   r1   r1   r1   r2   rR  f  sZ    	

rR  c                   @   s   e Zd ZejZdejeje	  dejeje	  ddfddZ
dedefdd	Zd
eje	 ddfddZdefddZdefddZedejeje	  fddZedejeje	  fddZdefddZdS )NameConstraintspermitted_subtreesexcluded_subtreesr    Nc                 C   s   |d ur t |}|stdtdd |D std| | |d ur@t |}|s.tdtdd |D s;td| | |d u rL|d u rLtd|| _|| _d S )	Nz3permitted_subtrees must be a non-empty list or Nonec                 s   r   r!   r   r   r1   r1   r2   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   r1   r1   r2   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   rg   _validate_ip_name_permitted_subtrees_excluded_subtrees)r9   ri  rj  r1   r1   r2   rI     s8   


zNameConstraints.__init__rz   c                 C   r   r!   )r"   rh  r|   rj  ri  r}   r1   r1   r2   r~     r   zNameConstraints.__eq__treec                 C   s   t dd |D rtdd S )Nc                 s   s0    | ]}t |tot |jtjtjf V  qd S r!   )r"   r   rh   	ipaddressIPv4NetworkIPv6Network)r   namer1   r1   r2   r   "  s    

z4NameConstraints._validate_ip_name.<locals>.<genexpr>zGIPAddress name constraints must be an IPv4Network or IPv6Network object)anyrg   )r9   rn  r1   r1   r2   rk  !  s   z!NameConstraints._validate_ip_namec                 C   r   )Nze<NameConstraints(permitted_subtrees={0.permitted_subtrees}, excluded_subtrees={0.excluded_subtrees})>r   r8   r1   r1   r2   rk   .  r   zNameConstraints.__repr__c                 C   s@   | j d urt| j }nd }| jd urt| j}nd }t||fS r!   )ri  r   rj  r   )r9   psesr1   r1   r2   r   4  s   

zNameConstraints.__hash__c                 C   r   r!   )rl  r8   r1   r1   r2   ri  E  r   z"NameConstraints.permitted_subtreesc                 C   r   r!   )rm  r8   r1   r1   r2   rj  K  r   z!NameConstraints.excluded_subtreesc                 C   r   r!   r   r8   r1   r1   r2   r#   Q  r   zNameConstraints.public_bytes)rO   rP   rQ   r   NAME_CONSTRAINTSrF   rX   r   rm   r   rI   r   r   r~   rk  rR   rk   rA   r   r   r   ri  rj  r[   r#   r1   r1   r1   r2   rh    s,    
*	rh  c                   @   s   e Zd ZdedededdfddZedefdd	Zedefd
dZ	edefddZ
defddZdedefddZdefddZdS )	ExtensionrF   criticalrh   r    Nc                 C   s:   t |ts	tdt |tstd|| _|| _|| _d S )Nz2oid argument must be an ObjectIdentifier instance.z critical must be a boolean value)r"   r   rg   r   _oid	_critical_value)r9   rF   rx  rh   r1   r1   r2   rI   V  s   


zExtension.__init__c                 C   r   r!   ry  r8   r1   r1   r2   rF   e  r   zExtension.oidc                 C   r   r!   )rz  r8   r1   r1   r2   rx  i  r   zExtension.criticalc                 C   r   r!   r{  r8   r1   r1   r2   rh   m  r   zExtension.valuec                 C   r   )Nz@<Extension(oid={0.oid}, critical={0.critical}, value={0.value})>r   r8   r1   r1   r2   rk   q  r   zExtension.__repr__rz   c                 C   r   r!   )r"   rw  r|   rF   rx  rh   r}   r1   r1   r2   r~   w  s   


zExtension.__eq__c                 C   s   t | j| j| jfS r!   )r   rF   rx  rh   r8   r1   r1   r2   r     r1  zExtension.__hash__)rO   rP   rQ   r   r   r   rI   r   rF   rx  rh   rR   rk   r   r~   rA   r   r1   r1   r1   r2   rw  U  s&    

rw  c                
   @   s  e Zd Zdeje ddfddZed\ZZ	Z
ejdejeje eje eje f deje fdd	Zejdeje deje fd
d	Zejdeje deje fdd	Zejdeje deje fdd	Zejdeje deje fdd	Zdejeje eje eje eje eje eje eje f dejeje eje eje eje eje f fdd	ZdefddZdedefddZdefddZ dS )GeneralNamesgeneral_namesr    Nc                 C   r   )Nc                 s   r   r!   r   r   r1   r1   r2   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   rg   _general_namesr9   r  r1   r1   r2   rI     r  zGeneralNames.__init__r  typec                 C      d S r!   r1   r9   r  r1   r1   r2   get_values_for_type     	z GeneralNames.get_values_for_typec                 C   r  r!   r1   r  r1   r1   r2   r       c                 C   r  r!   r1   r  r1   r1   r2   r    r  c                 C   r  r!   r1   r  r1   r1   r2   r       c                 C   r  r!   r1   r  r1   r1   r2   r    r  c                    s0    fdd| D } t krdd |D S t|S )Nc                 3   s    | ]
}t | r|V  qd S r!   )r"   r   ir  r1   r2   r     s    z3GeneralNames.get_values_for_type.<locals>.<genexpr>c                 S   s   g | ]}|j qS r1   rK  r  r1   r1   r2   
<listcomp>  s    z4GeneralNames.get_values_for_type.<locals>.<listcomp>)r   r`   )r9   r  objsr1   r  r2   r    s   c                 C   rj   )Nz<GeneralNames({})>rW   r  r8   r1   r1   r2   rk     rl   zGeneralNames.__repr__rz   c                 C   r{   r!   )r"   r~  r|   r  r}   r1   r1   r2   r~     r   zGeneralNames.__eq__c                 C   r   r!   )r   r   r  r8   r1   r1   r2   r     r<   zGeneralNames.__hash__)!rO   rP   rQ   rX   rm   r   rI   rB   ro   rp   rq   overloadr'  rn   r   r   r   r   rR   r  r   r   r   r   r   r   r   rk   r   r   r~   rA   r   r1   r1   r1   r2   r~    s|    


r~  c                
   @     e Zd ZejZdeje ddfddZ	e
d\ZZZejdejeje eje eje f deje fdd	Zejdeje deje fd
d	Zejdeje deje fdd	Zejdeje deje fdd	Zejdeje deje fdd	Zdejeje eje eje eje eje eje eje f dejeje eje eje eje eje f fdd	ZdefddZdede fddZ!de"fddZ#de$fddZ%dS )SubjectAlternativeNamer  r    Nc                 C   r_   r!   r~  r  r  r1   r1   r2   rI     r<   zSubjectAlternativeName.__init__r  r  c                 C   r  r!   r1   r  r1   r1   r2   r    r  z*SubjectAlternativeName.get_values_for_typec                 C   r  r!   r1   r  r1   r1   r2   r    r  c                 C   r  r!   r1   r  r1   r1   r2   r    r  c                 C   r  r!   r1   r  r1   r1   r2   r    r  c                 C   r  r!   r1   r  r1   r1   r2   r    r  c                 C      | j |S r!   r  r  r  r1   r1   r2   r       c                 C   rj   )Nz<SubjectAlternativeName({})>r  r8   r1   r1   r2   rk     rl   zSubjectAlternativeName.__repr__rz   c                 C   r{   r!   )r"   r  r|   r  r}   r1   r1   r2   r~   "  r   zSubjectAlternativeName.__eq__c                 C   r   r!   r   r  r8   r1   r1   r2   r   (  r   zSubjectAlternativeName.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r#   +  r   z#SubjectAlternativeName.public_bytes)&rO   rP   rQ   r   SUBJECT_ALTERNATIVE_NAMErF   rX   rm   r   rI   rB   ro   rp   rq   r  r'  rn   r   r   r   r   rR   r  r   r   r   r   r   r   r   rk   r   r   r~   rA   r   r[   r#   r1   r1   r1   r2   r        

r  c                
   @   r  )IssuerAlternativeNamer  r    Nc                 C   r_   r!   r  r  r1   r1   r2   rI   2  r<   zIssuerAlternativeName.__init__r  r  c                 C   r  r!   r1   r  r1   r1   r2   r  7  r  z)IssuerAlternativeName.get_values_for_typec                 C   r  r!   r1   r  r1   r1   r2   r  B  r  c                 C   r  r!   r1   r  r1   r1   r2   r  I  r  c                 C   r  r!   r1   r  r1   r1   r2   r  P  r  c                 C   r  r!   r1   r  r1   r1   r2   r  V  r  c                 C   r  r!   r  r  r1   r1   r2   r  \  r  c                 C   rj   )Nz<IssuerAlternativeName({})>r  r8   r1   r1   r2   rk   p  rl   zIssuerAlternativeName.__repr__rz   c                 C   r{   r!   )r"   r  r|   r  r}   r1   r1   r2   r~   s  r   zIssuerAlternativeName.__eq__c                 C   r   r!   r  r8   r1   r1   r2   r   y  r   zIssuerAlternativeName.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r#   |  r   z"IssuerAlternativeName.public_bytes)&rO   rP   rQ   r   ISSUER_ALTERNATIVE_NAMErF   rX   rm   r   rI   rB   ro   rp   rq   r  r'  rn   r   r   r   r   rR   r  r   r   r   r   r   r   r   rk   r   r   r~   rA   r   r[   r#   r1   r1   r1   r2   r  /  r  r  c                
   @   r  )CertificateIssuerr  r    Nc                 C   r_   r!   r  r  r1   r1   r2   rI     r<   zCertificateIssuer.__init__r  r  c                 C   r  r!   r1   r  r1   r1   r2   r    r  z%CertificateIssuer.get_values_for_typec                 C   r  r!   r1   r  r1   r1   r2   r    r  c                 C   r  r!   r1   r  r1   r1   r2   r    r  c                 C   r  r!   r1   r  r1   r1   r2   r    r  c                 C   r  r!   r1   r  r1   r1   r2   r    r  c                 C   r  r!   r  r  r1   r1   r2   r    r  c                 C   rj   )Nz<CertificateIssuer({})>r  r8   r1   r1   r2   rk     rl   zCertificateIssuer.__repr__rz   c                 C   r{   r!   )r"   r  r|   r  r}   r1   r1   r2   r~     r   zCertificateIssuer.__eq__c                 C   r   r!   r  r8   r1   r1   r2   r     r   zCertificateIssuer.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r#     r   zCertificateIssuer.public_bytes)&rO   rP   rQ   r   CERTIFICATE_ISSUERrF   rX   rm   r   rI   rB   ro   rp   rq   r  r'  rn   r   r   r   r   rR   r  r   r   r   r   r   r   r   rk   r   r   r~   rA   r   r[   r#   r1   r1   r1   r2   r    r  r  c                   @   sr   e Zd ZejZdeddfddZdefddZ	de
defd	d
ZdefddZedefddZdefddZdS )	CRLReasonreasonr    Nc                 C   rt   )Nz*reason must be an element from ReasonFlags)r"   r   rg   _reason)r9   r  r1   r1   r2   rI     ry   zCRLReason.__init__c                 C   rj   )Nz<CRLReason(reason={})>)rW   r  r8   r1   r1   r2   rk     rl   zCRLReason.__repr__rz   c                 C   r{   r!   )r"   r  r|   r  r}   r1   r1   r2   r~     r   zCRLReason.__eq__c                 C   r   r!   )r   r  r8   r1   r1   r2   r     r   zCRLReason.__hash__c                 C   r   r!   )r  r8   r1   r1   r2   r    r   zCRLReason.reasonc                 C   r   r!   r   r8   r1   r1   r2   r#     r   zCRLReason.public_bytes)rO   rP   rQ   r   
CRL_REASONrF   r   rI   rR   rk   r   r   r~   rA   r   r   r  r[   r#   r1   r1   r1   r2   r    s    r  c                   @   sv   e Zd ZejZdejddfddZdefddZ	de
defd	d
ZdefddZedejfddZdefddZdS )InvalidityDateinvalidity_dater    Nc                 C   s   t |tjs
td|| _d S )Nz+invalidity_date must be a datetime.datetime)r"   datetimerg   _invalidity_date)r9   r  r1   r1   r2   rI     s   
zInvalidityDate.__init__c                 C   rj   )Nz$<InvalidityDate(invalidity_date={})>)rW   r  r8   r1   r1   r2   rk     s   zInvalidityDate.__repr__rz   c                 C   r{   r!   )r"   r  r|   r  r}   r1   r1   r2   r~     r   zInvalidityDate.__eq__c                 C   r   r!   )r   r  r8   r1   r1   r2   r     r   zInvalidityDate.__hash__c                 C   r   r!   )r  r8   r1   r1   r2   r    r   zInvalidityDate.invalidity_datec                 C   r   r!   r   r8   r1   r1   r2   r#   	  r   zInvalidityDate.public_bytes)rO   rP   rQ   r   INVALIDITY_DATErF   r  rI   rR   rk   r   r   r~   rA   r   r   r  r[   r#   r1   r1   r1   r2   r    s    r  c                   @   t   e Zd ZejZdeje ddfddZ	e
d\ZZZdefddZdefd	d
ZdedefddZdefddZdS ))PrecertificateSignedCertificateTimestampssigned_certificate_timestampsr    Nc                 C   r   )Nc                 s   r   r!   r"   r   r   sctr1   r1   r2   r     
    
zEPrecertificateSignedCertificateTimestamps.__init__.<locals>.<genexpr>YEvery item in the signed_certificate_timestamps list must be a SignedCertificateTimestampr`   r   rg   _signed_certificate_timestampsr9   r  r1   r1   r2   rI        
z2PrecertificateSignedCertificateTimestamps.__init__r  c                 C      d t| S )Nz/<PrecertificateSignedCertificateTimestamps({})>rW   r`   r8   r1   r1   r2   rk   %  s   z2PrecertificateSignedCertificateTimestamps.__repr__c                 C   r   r!   r   r   r  r8   r1   r1   r2   r   *  r<   z2PrecertificateSignedCertificateTimestamps.__hash__rz   c                 C   r{   r!   )r"   r  r|   r  r}   r1   r1   r2   r~   -     
z0PrecertificateSignedCertificateTimestamps.__eq__c                 C   r   r!   r   r8   r1   r1   r2   r#   6  r   z6PrecertificateSignedCertificateTimestamps.public_bytes)rO   rP   rQ   r   %PRECERT_SIGNED_CERTIFICATE_TIMESTAMPSrF   rX   rm   r   rI   rB   ro   rp   rq   rR   rk   rA   r   r   r   r~   r[   r#   r1   r1   r1   r2   r    s     

	r  c                   @   r  )SignedCertificateTimestampsr  r    Nc                 C   r   )Nc                 s   r   r!   r  r  r1   r1   r2   r   D  r  z7SignedCertificateTimestamps.__init__.<locals>.<genexpr>r  r  r  r1   r1   r2   rI   =  r  z$SignedCertificateTimestamps.__init__r  c                 C   r  )Nz!<SignedCertificateTimestamps({})>r  r8   r1   r1   r2   rk   R  r<   z$SignedCertificateTimestamps.__repr__c                 C   r   r!   r  r8   r1   r1   r2   r   U  r<   z$SignedCertificateTimestamps.__hash__rz   c                 C   r{   r!   )r"   r  r|   r  r}   r1   r1   r2   r~   X  r  z"SignedCertificateTimestamps.__eq__c                 C   r   r!   r   r8   r1   r1   r2   r#   a  r   z(SignedCertificateTimestamps.public_bytes)rO   rP   rQ   r   SIGNED_CERTIFICATE_TIMESTAMPSrF   rX   rm   r   rI   rB   ro   rp   rq   rR   rk   rA   r   r   r   r~   r[   r#   r1   r1   r1   r2   r  :  s     

	r  c                   @   sr   e Zd ZejZdeddfddZdede	fddZ
defd	d
ZdefddZedefddZdefddZdS )	OCSPNoncenoncer    Nc                 C   rt   )Nznonce must be bytes)r"   r[   rg   _nonce)r9   r  r1   r1   r2   rI   h  ry   zOCSPNonce.__init__rz   c                 C   r{   r!   )r"   r  r|   r  r}   r1   r1   r2   r~   n  r   zOCSPNonce.__eq__c                 C   r   r!   )r   r  r8   r1   r1   r2   r   t  r   zOCSPNonce.__hash__c                 C   r   )Nz<OCSPNonce(nonce={0.nonce!r})>r   r8   r1   r1   r2   rk   w  r   zOCSPNonce.__repr__c                 C   r   r!   )r  r8   r1   r1   r2   r  z  r   zOCSPNonce.noncec                 C   r   r!   r   r8   r1   r1   r2   r#   ~  r   zOCSPNonce.public_bytes)rO   rP   rQ   r   NONCErF   r[   rI   r   r   r~   rA   r   rR   rk   r   r  r#   r1   r1   r1   r2   r  e  r   r  c                   @   s2  e Zd ZejZdejeje	  deje
 dededejeje  dededd	fd
dZdefddZdedefddZdefddZedejeje	  fddZedeje
 fddZedefddZedefddZedejeje  fddZedefddZedefdd Zdefd!d"Zd	S )#IssuingDistributionPointr   r   only_contains_user_certsonly_contains_ca_certsonly_some_reasonsindirect_crlonly_contains_attribute_certsr    Nc           	      C   s   |d urt |}|rt|trtdd |D std|r,tj|v s(tj|v r,tdt|t	r@t|t	r@t|t	r@t|t	sDtd||||g}t
dd |D dkrYtd	t|||||||gshtd
|| _|| _|| _|| _|| _|| _|| _d S )Nc                 s   r   r!   r   r   r1   r1   r2   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 r1   r1   r   r1   r1   r2   r    rM  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   rg   r   r   r   r   r   r6   rs  _only_contains_user_certs_only_contains_ca_certs_indirect_crl_only_contains_attribute_certs_only_some_reasonsr   r   )	r9   r   r   r  r  r  r  r  crl_constraintsr1   r1   r2   rI     st   

z!IssuingDistributionPoint.__init__c                 C   r   )NaG  <IssuingDistributionPoint(full_name={0.full_name}, relative_name={0.relative_name}, only_contains_user_certs={0.only_contains_user_certs}, only_contains_ca_certs={0.only_contains_ca_certs}, only_some_reasons={0.only_some_reasons}, indirect_crl={0.indirect_crl}, only_contains_attribute_certs={0.only_contains_attribute_certs})>r   r8   r1   r1   r2   rk     s   z!IssuingDistributionPoint.__repr__rz   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}   r1   r1   r2   r~     s"   





zIssuingDistributionPoint.__eq__c                 C   s$   t | j| j| j| j| j| j| jfS r!   )r   r   r   r  r  r  r  r  r8   r1   r1   r2   r     s   z!IssuingDistributionPoint.__hash__c                 C   r   r!   r   r8   r1   r1   r2   r      r   z"IssuingDistributionPoint.full_namec                 C   r   r!   r   r8   r1   r1   r2   r     r   z&IssuingDistributionPoint.relative_namec                 C   r   r!   )r  r8   r1   r1   r2   r    r   z1IssuingDistributionPoint.only_contains_user_certsc                 C   r   r!   )r  r8   r1   r1   r2   r    r   z/IssuingDistributionPoint.only_contains_ca_certsc                 C   r   r!   )r  r8   r1   r1   r2   r    r   z*IssuingDistributionPoint.only_some_reasonsc                 C   r   r!   )r  r8   r1   r1   r2   r    r   z%IssuingDistributionPoint.indirect_crlc                 C   r   r!   )r  r8   r1   r1   r2   r    r   z6IssuingDistributionPoint.only_contains_attribute_certsc                 C   r   r!   r   r8   r1   r1   r2   r#     r   z%IssuingDistributionPoint.public_bytes) rO   rP   rQ   r   ISSUING_DISTRIBUTION_POINTrF   rX   r   rm   r   r   r   r   r   rI   rR   rk   r   r~   rA   r   r   r   r   r   r  r  r  r  r  r[   r#   r1   r1   r1   r2   r    sN    	
Sr  c                   @   s   e Zd ZdededdfddZedefddZedefd	d
Zde	fddZ
dedefddZdefddZdefddZdS )rf   rF   rh   r    Nc                 C   s"   t |ts	td|| _|| _d S )Nzoid must be an ObjectIdentifier)r"   r   rg   ry  r{  )r9   rF   rh   r1   r1   r2   rI   #  s   

zUnrecognizedExtension.__init__c                 C   r   r!   r|  r8   r1   r1   r2   rF   )  r   zUnrecognizedExtension.oidc                 C   r   r!   r}  r8   r1   r1   r2   rh   -  r   zUnrecognizedExtension.valuec                 C   r   )Nz7<UnrecognizedExtension(oid={0.oid}, value={0.value!r})>r   r8   r1   r1   r2   rk   1  r   zUnrecognizedExtension.__repr__rz   c                 C   r   r!   )r"   rf   r|   rF   rh   r}   r1   r1   r2   r~   7  r   zUnrecognizedExtension.__eq__c                 C   r   r!   )r   rF   rh   r8   r1   r1   r2   r   =  r   zUnrecognizedExtension.__hash__c                 C   r   r!   rK  r8   r1   r1   r2   r#   @  s   z"UnrecognizedExtension.public_bytes)rO   rP   rQ   r   r[   rI   r   rF   rh   rR   rk   r   r   r~   rA   r   r#   r1   r1   r1   r2   rf   "  s    rf   )gabcr  r,   ro  rX   cryptographyr   "cryptography.hazmat.bindings._rustr   r   r   cryptography.hazmat.primitivesr   r   ,cryptography.hazmat.primitives.asymmetric.ecr   -cryptography.hazmat.primitives.asymmetric.rsar   /cryptography.hazmat.primitives.asymmetric.typesr	   r
   *cryptography.x509.certificate_transparencyr   cryptography.x509.general_namer   r   r   r   r   r   r   r   r   cryptography.x509.namer   r   cryptography.x509.oidr   r   r   r   TypeVarr   r[   r3   rR   rB   	ExceptionrD   rU   ABCMetar   r]   rr   r   r   r   r   r   r   r   r   r   r   Enumr   r  r  r  r   r	  r
  r  r  _REASON_BIT_MAPPING_CRLREASONFLAGSr  r  r  r#  r)  r2  r7  rA  rC  rE  _TLS_FEATURE_TYPE_TO_ENUMrN  rR  rh  Genericrw  r~  r  r  r  r  r  r  r  r  r  rf   r1   r1   r1   r2   <module>   s   ,
'l$!!(.%%oA=+("  j0YQQQ-+ !