3
ãdeìÿ  ã               @   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*ee+dœdd„Z,e-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 d+d,„ d,e3ƒZ;G d-d.„ d.e3ƒZ<G d/d0„ d0e3ƒZ=G d1d2„ d2e3ƒZ>G d3d4„ d4ƒZ?G d5d6„ d6ej@ƒZAeAjBeAjCeAjDeAjEeAjFeAjGeAjHeAjId7œZJeAjBd8eAjCd9eAjDd:eAjEd;eAjFd<eAjGd=eAjHd>eAjId?iZKG d@dA„ dAe3ƒZLG dBdC„ dCe3ƒZMG dDdE„ dEƒZNG dFdG„ dGƒZOG dHdI„ dIƒZPG dJdK„ dKe3ƒZQG dLdM„ dMe3ƒZRG dNdO„ dOe3ƒZSG dPdQ„ dQe3ƒZTG dRdS„ dSej@ƒZUdTdU„ eUD ƒZVG dVdW„ dWe3ƒZWG dXdY„ dYe3ƒZXG dZd[„ d[e3ƒZYG d\d]„ d]ejZe* ƒZ[G d^d_„ d_ƒZ\G d`da„ dae3ƒZ]G dbdc„ dce3ƒZ^G ddde„ dee3ƒZ_G dfdg„ dge3ƒZ`G dhdi„ die3ƒZaG djdk„ dke3ƒZbG dldm„ dme3ƒZcG dndo„ doe3ƒZdG dpdq„ dqe3ƒZeG drds„ dse3ƒZfdS )té    N)Ú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_keyÚreturnc             C   sl   t | tƒr | jtjjtjjƒ}n>t | tƒr@| jtjj	tjj
ƒ}n| jtjjtjjƒ}tj|ƒ}tj|ƒjƒ S )N)Ú
isinstancer   Úpublic_bytesr   ÚEncodingZDERZPublicFormatZPKCS1r   ZX962ZUncompressedPointZSubjectPublicKeyInfor   Zparse_spki_for_dataÚhashlibÚsha1Údigest)r   ÚdataZ
serialized© r(   úS/var/www/agendate/envp3/lib/python3.6/site-packages/cryptography/x509/extensions.pyÚ_key_identifier_from_public_key1   s    



r*   )Ú
field_namec                s4   t dœ‡ fdd„}‡ fdd„}‡ fdd„}|||fS )N)r    c                s   t t| ˆ ƒƒS )N)ÚlenÚgetattr)Úself)r+   r(   r)   Ú
len_methodJ   s    z*_make_sequence_methods.<locals>.len_methodc                s   t t| ˆ ƒƒS )N)Úiterr-   )r.   )r+   r(   r)   Úiter_methodM   s    z+_make_sequence_methods.<locals>.iter_methodc                s   t | ˆ ƒ| S )N)r-   )r.   Úidx)r+   r(   r)   Úgetitem_methodP   s    z._make_sequence_methods.<locals>.getitem_method)Úint)r+   r/   r1   r3   r(   )r+   r)   Ú_make_sequence_methodsI   s    r5   c                   s&   e Zd Zeeddœ‡ fdd„Z‡  ZS )ÚDuplicateExtensionN)ÚmsgÚoidr    c                s   t ƒ j|ƒ || _d S )N)ÚsuperÚ__init__r8   )r.   r7   r8   )Ú	__class__r(   r)   r:   W   s    zDuplicateExtension.__init__)Ú__name__Ú
__module__Ú__qualname__Ústrr   r:   Ú__classcell__r(   r(   )r;   r)   r6   V   s   r6   c                   s&   e Zd Zeeddœ‡ fdd„Z‡  ZS )ÚExtensionNotFoundN)r7   r8   r    c                s   t ƒ j|ƒ || _d S )N)r9   r:   r8   )r.   r7   r8   )r;   r(   r)   r:   ]   s    zExtensionNotFound.__init__)r<   r=   r>   r?   r   r:   r@   r(   r(   )r;   r)   rA   \   s   rA   c               @   s&   e Zd ZU eje edœdd„ZdS )r   )r    c             C   s   t dj| ƒƒ‚dS )z7
        Serializes the extension type to DER.
        z7public_bytes is not implemented for extension type {!r}N)ÚNotImplementedErrorÚformat)r.   r(   r(   r)   r"   e   s    zExtensionType.public_bytesN)	r<   r=   r>   ÚtypingÚClassVarr   r8   Úbytesr"   r(   r(   r(   r)   r   b   s   

)Ú	metaclassc               @   sd   e Zd Zejd ddœdd„Zeddœdd„Zeje	 d	d
œdd„Z
edƒ\ZZZedœdd„ZdS )Ú
ExtensionszExtension[ExtensionType]N)Ú
extensionsr    c             C   s   t |ƒ| _d S )N)ÚlistÚ_extensions)r.   rI   r(   r(   r)   r:   q   s    zExtensions.__init__)r8   r    c             C   s2   x| D ]}|j |kr|S qW td|› d�|ƒ‚d S )NzNo z extension was found)r8   rA   )r.   r8   Úextr(   r(   r)   Úget_extension_for_oidv   s    

z Extensions.get_extension_for_oidzExtension[ExtensionTypeVar])Úextclassr    c             C   sF   |t krtdƒ‚x| D ]}t|j|ƒr|S qW td|› d�|jƒ‚d S )Nz|UnrecognizedExtension can't be used with get_extension_for_class because more than one instance of the class may be present.zNo z extension was found)ÚUnrecognizedExtensionÚ	TypeErrorr!   ÚvaluerA   r8   )r.   rN   rL   r(   r(   r)   Úget_extension_for_class   s    
z"Extensions.get_extension_for_classrK   )r    c             C   s   d| j › d�S )Nz<Extensions(z)>)rK   )r.   r(   r(   r)   Ú__repr__“   s    zExtensions.__repr__)r<   r=   r>   rD   ÚIterabler:   r   rM   ÚTyper   rR   r5   Ú__len__Ú__iter__Ú__getitem__r?   rS   r(   r(   r(   r)   rH   p   s   rH   c               @   sn   e Zd ZejZeddœdd„Zee	dœdd„Z
edœd	d
„Zedœdd„Zeedœdd„ƒZedœdd„ZdS )Ú	CRLNumberN)Ú
crl_numberr    c             C   s   t |tƒstdƒ‚|| _d S )Nzcrl_number must be an integer)r!   r4   rP   Ú_crl_number)r.   rZ   r(   r(   r)   r:   š   s    
zCRLNumber.__init__)Úotherr    c             C   s   t |tƒstS | j|jkS )N)r!   rY   ÚNotImplementedrZ   )r.   r\   r(   r(   r)   Ú__eq__    s    
zCRLNumber.__eq__)r    c             C   s
   t | jƒS )N)ÚhashrZ   )r.   r(   r(   r)   Ú__hash__¦   s    zCRLNumber.__hash__c             C   s   d| j › d�S )Nz<CRLNumber(z)>)rZ   )r.   r(   r(   r)   rS   ©   s    zCRLNumber.__repr__c             C   s   | j S )N)r[   )r.   r(   r(   r)   rZ   ¬   s    zCRLNumber.crl_numberc             C   s
   t j| ƒS )N)Ú	rust_x509Úencode_extension_value)r.   r(   r(   r)   r"   °   s    zCRLNumber.public_bytes)r<   r=   r>   r   Z
CRL_NUMBERr8   r4   r:   ÚobjectÚboolr^   r`   r?   rS   ÚpropertyrZ   rF   r"   r(   r(   r(   r)   rY   —   s   rY   c               @   sî   e Zd ZejZeje ejej	e
  eje ddœdd„Zeed dœdd„ƒZedd d	œd
d„ƒZedœdd„Zeedœdd„Zedœdd„Zeeje dœdd„ƒZeejeje
  dœdd„ƒZeeje dœdd„ƒZedœdd„ZdS )ÚAuthorityKeyIdentifierN)Úkey_identifierÚauthority_cert_issuerÚauthority_cert_serial_numberr    c             C   st   |d k|d kkrt dƒ‚|d k	rBt|ƒ}tdd„ |D ƒƒsBtdƒ‚|d k	r^t|tƒ r^tdƒ‚|| _|| _|| _d S )NzXauthority_cert_issuer and authority_cert_serial_number must both be present or both Nonec             s   s   | ]}t |tƒV  qd S )N)r!   r   )Ú.0Úxr(   r(   r)   ú	<genexpr>È   s    z2AuthorityKeyIdentifier.__init__.<locals>.<genexpr>z;authority_cert_issuer must be a list of GeneralName objectsz/authority_cert_serial_number must be an integer)	Ú
ValueErrorrJ   ÚallrP   r!   r4   Ú_key_identifierÚ_authority_cert_issuerÚ_authority_cert_serial_number)r.   rg   rh   ri   r(   r(   r)   r:   ·   s     


zAuthorityKeyIdentifier.__init__)r   r    c             C   s   t |ƒ}| |d d d�S )N)rg   rh   ri   )r*   )Úclsr   r&   r(   r(   r)   Úfrom_issuer_public_keyÝ   s
    z-AuthorityKeyIdentifier.from_issuer_public_keyÚSubjectKeyIdentifier)Úskir    c             C   s   | |j d d d�S )N)rg   rh   ri   )r&   )rr   ru   r(   r(   r)   Ú"from_issuer_subject_key_identifierè   s    z9AuthorityKeyIdentifier.from_issuer_subject_key_identifier)r    c             C   s
   dj | ƒ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})>)rC   )r.   r(   r(   r)   rS   ò   s    zAuthorityKeyIdentifier.__repr__)r\   r    c             C   s2   t |tƒstS | j|jko0| j|jko0| j|jkS )N)r!   rf   r]   rg   rh   ri   )r.   r\   r(   r(   r)   r^   ú   s    
zAuthorityKeyIdentifier.__eq__c             C   s,   | j d krd }n
t| j ƒ}t| j|| jfƒS )N)rh   Útupler_   rg   ri   )r.   Zacir(   r(   r)   r`     s
    

zAuthorityKeyIdentifier.__hash__c             C   s   | j S )N)ro   )r.   r(   r(   r)   rg     s    z%AuthorityKeyIdentifier.key_identifierc             C   s   | j S )N)rp   )r.   r(   r(   r)   rh     s    z,AuthorityKeyIdentifier.authority_cert_issuerc             C   s   | j S )N)rq   )r.   r(   r(   r)   ri     s    z3AuthorityKeyIdentifier.authority_cert_serial_numberc             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"     s    z#AuthorityKeyIdentifier.public_bytes)r<   r=   r>   r   ZAUTHORITY_KEY_IDENTIFIERr8   rD   ÚOptionalrF   rT   r   r4   r:   Úclassmethodr	   rs   rv   r?   rS   rc   rd   r^   r`   re   rg   ÚListrh   ri   r"   r(   r(   r(   r)   rf   ´   s*   !	rf   c               @   s”   e Zd ZejZeddœdd„Zee	d dœdd„ƒZ
eedœd	d
„ƒZeedœdd„ƒZedœdd„Zeedœdd„Zedœdd„Zedœdd„ZdS )rt   N)r&   r    c             C   s
   || _ d S )N)Ú_digest)r.   r&   r(   r(   r)   r:   #  s    zSubjectKeyIdentifier.__init__)r   r    c             C   s   | t |ƒƒS )N)r*   )rr   r   r(   r(   r)   Úfrom_public_key&  s    z$SubjectKeyIdentifier.from_public_key)r    c             C   s   | j S )N)r{   )r.   r(   r(   r)   r&   ,  s    zSubjectKeyIdentifier.digestc             C   s   | j S )N)r{   )r.   r(   r(   r)   rg   0  s    z#SubjectKeyIdentifier.key_identifierc             C   s   d| j ›d�S )Nz<SubjectKeyIdentifier(digest=z)>)r&   )r.   r(   r(   r)   rS   4  s    zSubjectKeyIdentifier.__repr__)r\   r    c             C   s   t |tƒstS tj| j|jƒS )N)r!   rt   r]   r   Zbytes_eqr&   )r.   r\   r(   r(   r)   r^   7  s    
zSubjectKeyIdentifier.__eq__c             C   s
   t | jƒS )N)r_   r&   )r.   r(   r(   r)   r`   =  s    zSubjectKeyIdentifier.__hash__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   @  s    z!SubjectKeyIdentifier.public_bytes)r<   r=   r>   r   ZSUBJECT_KEY_IDENTIFIERr8   rF   r:   ry   r
   r|   re   r&   rg   r?   rS   rc   rd   r^   r4   r`   r"   r(   r(   r(   r)   rt      s   rt   c               @   sp   e Zd ZejZejd ddœdd„Ze	dƒ\Z
ZZedœdd	„Zeed
œdd„Zedœdd„Zedœdd„ZdS )ÚAuthorityInformationAccessÚAccessDescriptionN)Údescriptionsr    c             C   s,   t |ƒ}tdd„ |D ƒƒs"tdƒ‚|| _d S )Nc             s   s   | ]}t |tƒV  qd S )N)r!   r~   )rj   rk   r(   r(   r)   rl   K  s    z6AuthorityInformationAccess.__init__.<locals>.<genexpr>z@Every item in the descriptions list must be an AccessDescription)rJ   rn   rP   Ú_descriptions)r.   r   r(   r(   r)   r:   G  s
    z#AuthorityInformationAccess.__init__r€   )r    c             C   s   d| j › d�S )Nz<AuthorityInformationAccess(z)>)r€   )r.   r(   r(   r)   rS   U  s    z#AuthorityInformationAccess.__repr__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   r}   r]   r€   )r.   r\   r(   r(   r)   r^   X  s    
z!AuthorityInformationAccess.__eq__c             C   s   t t| jƒƒS )N)r_   rw   r€   )r.   r(   r(   r)   r`   ^  s    z#AuthorityInformationAccess.__hash__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   a  s    z'AuthorityInformationAccess.public_bytes)r<   r=   r>   r   ZAUTHORITY_INFORMATION_ACCESSr8   rD   rT   r:   r5   rV   rW   rX   r?   rS   rc   rd   r^   r4   r`   rF   r"   r(   r(   r(   r)   r}   D  s   
r}   c               @   sp   e Zd ZejZejd ddœdd„Ze	dƒ\Z
ZZedœdd	„Zeed
œdd„Zedœdd„Zedœdd„ZdS )ÚSubjectInformationAccessr~   N)r   r    c             C   s,   t |ƒ}tdd„ |D ƒƒs"tdƒ‚|| _d S )Nc             s   s   | ]}t |tƒV  qd S )N)r!   r~   )rj   rk   r(   r(   r)   rl   l  s    z4SubjectInformationAccess.__init__.<locals>.<genexpr>z@Every item in the descriptions list must be an AccessDescription)rJ   rn   rP   r€   )r.   r   r(   r(   r)   r:   h  s
    z!SubjectInformationAccess.__init__r€   )r    c             C   s   d| j › d�S )Nz<SubjectInformationAccess(z)>)r€   )r.   r(   r(   r)   rS   v  s    z!SubjectInformationAccess.__repr__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   r�   r]   r€   )r.   r\   r(   r(   r)   r^   y  s    
zSubjectInformationAccess.__eq__c             C   s   t t| jƒƒS )N)r_   rw   r€   )r.   r(   r(   r)   r`     s    z!SubjectInformationAccess.__hash__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   ‚  s    z%SubjectInformationAccess.public_bytes)r<   r=   r>   r   ZSUBJECT_INFORMATION_ACCESSr8   rD   rT   r:   r5   rV   rW   rX   r?   rS   rc   rd   r^   r4   r`   rF   r"   r(   r(   r(   r)   r�   e  s   
r�   c               @   sn   e Zd Zeeddœdd„Zedœdd„Zee	dœd	d
„Z
edœdd„Zeedœdd„ƒZeedœdd„ƒZdS )r~   N)Úaccess_methodÚaccess_locationr    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   rP   r   Ú_access_methodÚ_access_location)r.   r‚   rƒ   r(   r(   r)   r:   ‡  s    

zAccessDescription.__init__)r    c             C   s
   dj | ƒS )NzY<AccessDescription(access_method={0.access_method}, access_location={0.access_location})>)rC   )r.   r(   r(   r)   rS   “  s    zAccessDescription.__repr__)r\   r    c             C   s&   t |tƒstS | j|jko$| j|jkS )N)r!   r~   r]   r‚   rƒ   )r.   r\   r(   r(   r)   r^   ™  s    
zAccessDescription.__eq__c             C   s   t | j| jfƒS )N)r_   r‚   rƒ   )r.   r(   r(   r)   r`   ¢  s    zAccessDescription.__hash__c             C   s   | j S )N)r„   )r.   r(   r(   r)   r‚   ¥  s    zAccessDescription.access_methodc             C   s   | j S )N)r…   )r.   r(   r(   r)   rƒ   ©  s    z!AccessDescription.access_location)r<   r=   r>   r   r   r:   r?   rS   rc   rd   r^   r4   r`   re   r‚   rƒ   r(   r(   r(   r)   r~   †  s   
	r~   c               @   sŽ   e Zd ZejZeeje	 ddœdd„Z
eedœdd„ƒZeeje	 dœdd	„ƒZedœd
d„Zeedœdd„Ze	dœdd„Zedœdd„ZdS )ÚBasicConstraintsN)ÚcaÚpath_lengthr    c             C   s\   t |tƒstdƒ‚|d k	r(| r(tdƒ‚|d k	rLt |tƒ sD|dk rLt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!   rd   rP   rm   r4   Ú_caÚ_path_length)r.   r‡   rˆ   r(   r(   r)   r:   ±  s    
zBasicConstraints.__init__)r    c             C   s   | j S )N)r‰   )r.   r(   r(   r)   r‡   Â  s    zBasicConstraints.cac             C   s   | j S )N)rŠ   )r.   r(   r(   r)   rˆ   Æ  s    zBasicConstraints.path_lengthc             C   s
   dj | ƒS )Nz:<BasicConstraints(ca={0.ca}, path_length={0.path_length})>)rC   )r.   r(   r(   r)   rS   Ê  s    zBasicConstraints.__repr__)r\   r    c             C   s&   t |tƒstS | j|jko$| j|jkS )N)r!   r†   r]   r‡   rˆ   )r.   r\   r(   r(   r)   r^   Ï  s    
zBasicConstraints.__eq__c             C   s   t | j| jfƒS )N)r_   r‡   rˆ   )r.   r(   r(   r)   r`   Õ  s    zBasicConstraints.__hash__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   Ø  s    zBasicConstraints.public_bytes)r<   r=   r>   r   ZBASIC_CONSTRAINTSr8   rd   rD   rx   r4   r:   re   r‡   rˆ   r?   rS   rc   r^   r`   rF   r"   r(   r(   r(   r)   r†   ®  s   r†   c               @   sn   e Zd ZejZeddœdd„Zeedœdd„ƒZ	e
edœd	d
„Zedœdd„Zedœdd„Zedœdd„ZdS )ÚDeltaCRLIndicatorN)rZ   r    c             C   s   t |tƒstdƒ‚|| _d S )Nzcrl_number must be an integer)r!   r4   rP   r[   )r.   rZ   r(   r(   r)   r:   ß  s    
zDeltaCRLIndicator.__init__)r    c             C   s   | j S )N)r[   )r.   r(   r(   r)   rZ   å  s    zDeltaCRLIndicator.crl_number)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   r‹   r]   rZ   )r.   r\   r(   r(   r)   r^   é  s    
zDeltaCRLIndicator.__eq__c             C   s
   t | jƒS )N)r_   rZ   )r.   r(   r(   r)   r`   ï  s    zDeltaCRLIndicator.__hash__c             C   s   d| j › d�S )Nz<DeltaCRLIndicator(crl_number=z)>)rZ   )r.   r(   r(   r)   rS   ò  s    zDeltaCRLIndicator.__repr__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   õ  s    zDeltaCRLIndicator.public_bytes)r<   r=   r>   r   ZDELTA_CRL_INDICATORr8   r4   r:   re   rZ   rc   rd   r^   r`   r?   rS   rF   r"   r(   r(   r(   r)   r‹   Ü  s   r‹   c               @   sp   e Zd ZejZejd ddœdd„Ze	dƒ\Z
ZZedœdd	„Zeed
œdd„Zedœdd„Zedœdd„ZdS )ÚCRLDistributionPointsÚDistributionPointN)Údistribution_pointsr    c             C   s,   t |ƒ}tdd„ |D ƒƒs"tdƒ‚|| _d S )Nc             s   s   | ]}t |tƒV  qd S )N)r!   r�   )rj   rk   r(   r(   r)   rl     s    z1CRLDistributionPoints.__init__.<locals>.<genexpr>z?distribution_points must be a list of DistributionPoint objects)rJ   rn   rP   Ú_distribution_points)r.   rŽ   r(   r(   r)   r:   ü  s    zCRLDistributionPoints.__init__r�   )r    c             C   s   d| j › d�S )Nz<CRLDistributionPoints(z)>)r�   )r.   r(   r(   r)   rS     s    zCRLDistributionPoints.__repr__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   rŒ   r]   r�   )r.   r\   r(   r(   r)   r^     s    
zCRLDistributionPoints.__eq__c             C   s   t t| jƒƒS )N)r_   rw   r�   )r.   r(   r(   r)   r`     s    zCRLDistributionPoints.__hash__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"     s    z"CRLDistributionPoints.public_bytes)r<   r=   r>   r   ZCRL_DISTRIBUTION_POINTSr8   rD   rT   r:   r5   rV   rW   rX   r?   rS   rc   rd   r^   r4   r`   rF   r"   r(   r(   r(   r)   rŒ   ù  s   rŒ   c               @   sp   e Zd ZejZejd ddœdd„Ze	dƒ\Z
ZZedœdd	„Zeed
œdd„Zedœdd„Zedœdd„ZdS )ÚFreshestCRLr�   N)rŽ   r    c             C   s,   t |ƒ}tdd„ |D ƒƒs"tdƒ‚|| _d S )Nc             s   s   | ]}t |tƒV  qd S )N)r!   r�   )rj   rk   r(   r(   r)   rl   &  s    z'FreshestCRL.__init__.<locals>.<genexpr>z?distribution_points must be a list of DistributionPoint objects)rJ   rn   rP   r�   )r.   rŽ   r(   r(   r)   r:   !  s    zFreshestCRL.__init__r�   )r    c             C   s   d| j › d�S )Nz<FreshestCRL(z)>)r�   )r.   r(   r(   r)   rS   3  s    zFreshestCRL.__repr__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   r�   r]   r�   )r.   r\   r(   r(   r)   r^   6  s    
zFreshestCRL.__eq__c             C   s   t t| jƒƒS )N)r_   rw   r�   )r.   r(   r(   r)   r`   <  s    zFreshestCRL.__hash__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   ?  s    zFreshestCRL.public_bytes)r<   r=   r>   r   ZFRESHEST_CRLr8   rD   rT   r:   r5   rV   rW   rX   r?   rS   rc   rd   r^   r4   r`   rF   r"   r(   r(   r(   r)   r�     s   r�   c               @   sê   e Zd Zejeje  eje ejejd  ejeje  ddœdd„Z	e
dœdd„Zeed	œd
d„Zedœdd„Zeejeje  dœdd„ƒZeeje dœdd„ƒZeejejd  dœdd„ƒZeejeje  dœdd„ƒZdS )r�   ÚReasonFlagsN)Ú	full_nameÚrelative_nameÚreasonsÚ
crl_issuerr    c             C   sü   |r|rt dƒ‚| r*| r*| r*t dƒ‚|d k	rTt|ƒ}tdd„ |D ƒƒsTtdƒ‚|rjt|tƒsjtdƒ‚|d k	r”t|ƒ}tdd„ |D ƒƒs”tdƒ‚|rÀt|tƒ s¸td	d„ |D ƒƒ rÀtd
ƒ‚|ràtj|ksØtj	|kràt 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   s   | ]}t |tƒV  qd S )N)r!   r   )rj   rk   r(   r(   r)   rl   X  s    z-DistributionPoint.__init__.<locals>.<genexpr>z/full_name must be a list of GeneralName objectsz1relative_name must be a RelativeDistinguishedNamec             s   s   | ]}t |tƒV  qd S )N)r!   r   )rj   rk   r(   r(   r)   rl   e  s    z2crl_issuer must be None or a list of general namesc             s   s   | ]}t |tƒV  qd S )N)r!   r‘   )rj   rk   r(   r(   r)   rl   l  s    z0reasons must be None or frozenset of ReasonFlagszLunspecified and remove_from_crl are not valid reasons in a DistributionPoint)rm   rJ   rn   rP   r!   r   Ú	frozensetr‘   ÚunspecifiedÚremove_from_crlÚ
_full_nameÚ_relative_nameÚ_reasonsÚ_crl_issuer)r.   r’   r“   r”   r•   r(   r(   r)   r:   D  sB    


zDistributionPoint.__init__)r    c             C   s
   dj | ƒS )Nz}<DistributionPoint(full_name={0.full_name}, relative_name={0.relative_name}, reasons={0.reasons}, crl_issuer={0.crl_issuer})>)rC   )r.   r(   r(   r)   rS   ~  s    zDistributionPoint.__repr__)r\   r    c             C   s>   t |tƒstS | j|jko<| j|jko<| j|jko<| j|jkS )N)r!   r�   r]   r’   r“   r”   r•   )r.   r\   r(   r(   r)   r^   …  s    
zDistributionPoint.__eq__c             C   sH   | j d k	rt| j ƒ}nd }| jd k	r0t| jƒ}nd }t|| j| j|fƒS )N)r’   rw   r•   r_   r“   r”   )r.   Úfnr•   r(   r(   r)   r`   �  s    


zDistributionPoint.__hash__c             C   s   | j S )N)r™   )r.   r(   r(   r)   r’   ¡  s    zDistributionPoint.full_namec             C   s   | j S )N)rš   )r.   r(   r(   r)   r“   ¥  s    zDistributionPoint.relative_namec             C   s   | j S )N)r›   )r.   r(   r(   r)   r”   ©  s    zDistributionPoint.reasonsc             C   s   | j S )N)rœ   )r.   r(   r(   r)   r•   ­  s    zDistributionPoint.crl_issuer)r<   r=   r>   rD   rx   rT   r   r   Ú	FrozenSetr:   r?   rS   rc   rd   r^   r4   r`   re   rz   r’   r“   r”   r•   r(   r(   r(   r)   r�   C  s    4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)r<   r=   r>   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eje eje ddœdd„Z	e
dœdd„Zeedœd	d
„Zedœdd„Zeeje dœdd„ƒZeeje dœdd„ƒZedœdd„ZdS )ÚPolicyConstraintsN)Úrequire_explicit_policyÚinhibit_policy_mappingr    c             C   s`   |d k	rt |tƒ rtdƒ‚|d k	r8t |tƒ r8tdƒ‚|d krP|d krPt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!   r4   rP   rm   Ú_require_explicit_policyÚ_inhibit_policy_mapping)r.   r°   r±   r(   r(   r)   r:   å  s    



zPolicyConstraints.__init__)r    c             C   s
   dj | ƒS )Nz{<PolicyConstraints(require_explicit_policy={0.require_explicit_policy}, inhibit_policy_mapping={0.inhibit_policy_mapping})>)rC   )r.   r(   r(   r)   rS     s    zPolicyConstraints.__repr__)r\   r    c             C   s&   t |tƒstS | j|jko$| j|jkS )N)r!   r¯   r]   r°   r±   )r.   r\   r(   r(   r)   r^   	  s    
zPolicyConstraints.__eq__c             C   s   t | j| jfƒS )N)r_   r°   r±   )r.   r(   r(   r)   r`     s    zPolicyConstraints.__hash__c             C   s   | j S )N)r²   )r.   r(   r(   r)   r°     s    z)PolicyConstraints.require_explicit_policyc             C   s   | j S )N)r³   )r.   r(   r(   r)   r±     s    z(PolicyConstraints.inhibit_policy_mappingc             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"     s    zPolicyConstraints.public_bytes)r<   r=   r>   r   ZPOLICY_CONSTRAINTSr8   rD   rx   r4   r:   r?   rS   rc   rd   r^   r`   re   r°   r±   rF   r"   r(   r(   r(   r)   r¯   â  s   	r¯   c               @   sp   e Zd ZejZejd ddœdd„Ze	dƒ\Z
ZZedœdd	„Zeed
œdd„Zedœdd„Zedœdd„ZdS )ÚCertificatePoliciesÚPolicyInformationN)Úpoliciesr    c             C   s,   t |ƒ}tdd„ |D ƒƒs"tdƒ‚|| _d S )Nc             s   s   | ]}t |tƒV  qd S )N)r!   rµ   )rj   rk   r(   r(   r)   rl   (  s    z/CertificatePolicies.__init__.<locals>.<genexpr>z;Every item in the policies list must be a PolicyInformation)rJ   rn   rP   Ú	_policies)r.   r¶   r(   r(   r)   r:   &  s
    zCertificatePolicies.__init__r·   )r    c             C   s   d| j › d�S )Nz<CertificatePolicies(z)>)r·   )r.   r(   r(   r)   rS   2  s    zCertificatePolicies.__repr__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   r´   r]   r·   )r.   r\   r(   r(   r)   r^   5  s    
zCertificatePolicies.__eq__c             C   s   t t| jƒƒS )N)r_   rw   r·   )r.   r(   r(   r)   r`   ;  s    zCertificatePolicies.__hash__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   >  s    z CertificatePolicies.public_bytes)r<   r=   r>   r   ZCERTIFICATE_POLICIESr8   rD   rT   r:   r5   rV   rW   rX   r?   rS   rc   rd   r^   r4   r`   rF   r"   r(   r(   r(   r)   r´   #  s   
r´   c               @   sš   e Zd Zeejejejedf   ddœdd„Z	edœdd„Z
eed	œd
d„Zedœdd„Zeedœdd„ƒZeejejejedf   dœdd„ƒZdS )rµ   Ú
UserNoticeN)Úpolicy_identifierÚpolicy_qualifiersr    c             C   sL   t |tƒstdƒ‚|| _|d k	rBt|ƒ}tdd„ |D ƒƒsBtdƒ‚|| _d S )Nz-policy_identifier must be an ObjectIdentifierc             s   s   | ]}t |ttfƒV  qd S )N)r!   r?   r¸   )rj   rk   r(   r(   r)   rl   R  s    z-PolicyInformation.__init__.<locals>.<genexpr>zMpolicy_qualifiers must be a list of strings and/or UserNotice objects or None)r!   r   rP   Ú_policy_identifierrJ   rn   Ú_policy_qualifiers)r.   r¹   rº   r(   r(   r)   r:   C  s    
zPolicyInformation.__init__)r    c             C   s
   dj | ƒS )Nze<PolicyInformation(policy_identifier={0.policy_identifier}, policy_qualifiers={0.policy_qualifiers})>)rC   )r.   r(   r(   r)   rS   [  s    zPolicyInformation.__repr__)r\   r    c             C   s&   t |tƒstS | j|jko$| j|jkS )N)r!   rµ   r]   r¹   rº   )r.   r\   r(   r(   r)   r^   a  s    
zPolicyInformation.__eq__c             C   s(   | j d k	rt| j ƒ}nd }t| j|fƒS )N)rº   rw   r_   r¹   )r.   Zpqr(   r(   r)   r`   j  s    
zPolicyInformation.__hash__c             C   s   | j S )N)r»   )r.   r(   r(   r)   r¹   t  s    z#PolicyInformation.policy_identifierc             C   s   | j S )N)r¼   )r.   r(   r(   r)   rº   x  s    z#PolicyInformation.policy_qualifiers)r<   r=   r>   r   rD   rx   rT   ÚUnionr?   r:   rS   rc   rd   r^   r4   r`   re   r¹   rz   rº   r(   r(   r(   r)   rµ   B  s   	
rµ   c               @   s†   e Zd Zejd eje ddœdd„Zedœdd„Zee	d	œd
d„Z
edœdd„Zeejd dœdd„ƒZeeje dœdd„ƒZdS )r¸   ÚNoticeReferenceN)Únotice_referenceÚexplicit_textr    c             C   s(   |rt |tƒ rtdƒ‚|| _|| _d S )Nz2notice_reference must be None or a NoticeReference)r!   r¾   rP   Ú_notice_referenceÚ_explicit_text)r.   r¿   rÀ   r(   r(   r)   r:   €  s    
zUserNotice.__init__)r    c             C   s
   dj | ƒS )NzV<UserNotice(notice_reference={0.notice_reference}, explicit_text={0.explicit_text!r})>)rC   )r.   r(   r(   r)   rS   �  s    zUserNotice.__repr__)r\   r    c             C   s&   t |tƒstS | j|jko$| j|jkS )N)r!   r¸   r]   r¿   rÀ   )r.   r\   r(   r(   r)   r^   •  s    
zUserNotice.__eq__c             C   s   t | j| jfƒS )N)r_   r¿   rÀ   )r.   r(   r(   r)   r`   ž  s    zUserNotice.__hash__c             C   s   | j S )N)rÁ   )r.   r(   r(   r)   r¿   ¡  s    zUserNotice.notice_referencec             C   s   | j S )N)rÂ   )r.   r(   r(   r)   rÀ   ¥  s    zUserNotice.explicit_text)r<   r=   r>   rD   rx   r?   r:   rS   rc   rd   r^   r4   r`   re   r¿   rÀ   r(   r(   r(   r)   r¸     s   	r¸   c               @   s†   e Zd Zeje eje ddœdd„Zedœdd„Z	e
edœd	d
„Zedœdd„Zeeje dœdd„ƒZeeje dœdd„ƒZdS )r¾   N)ÚorganizationÚnotice_numbersr    c             C   s2   || _ t|ƒ}tdd„ |D ƒƒs(tdƒ‚|| _d S )Nc             s   s   | ]}t |tƒV  qd S )N)r!   r4   )rj   rk   r(   r(   r)   rl   ²  s    z+NoticeReference.__init__.<locals>.<genexpr>z)notice_numbers must be a list of integers)Ú_organizationrJ   rn   rP   Ú_notice_numbers)r.   rÃ   rÄ   r(   r(   r)   r:   «  s
    zNoticeReference.__init__)r    c             C   s
   dj | ƒS )NzU<NoticeReference(organization={0.organization!r}, notice_numbers={0.notice_numbers})>)rC   )r.   r(   r(   r)   rS   ·  s    zNoticeReference.__repr__)r\   r    c             C   s&   t |tƒstS | j|jko$| j|jkS )N)r!   r¾   r]   rÃ   rÄ   )r.   r\   r(   r(   r)   r^   ½  s    
zNoticeReference.__eq__c             C   s   t | jt| jƒfƒS )N)r_   rÃ   rw   rÄ   )r.   r(   r(   r)   r`   Æ  s    zNoticeReference.__hash__c             C   s   | j S )N)rÅ   )r.   r(   r(   r)   rÃ   É  s    zNoticeReference.organizationc             C   s   | j S )N)rÆ   )r.   r(   r(   r)   rÄ   Í  s    zNoticeReference.notice_numbers)r<   r=   r>   rD   rx   r?   rT   r4   r:   rS   rc   rd   r^   r`   re   rÃ   rz   rÄ   r(   r(   r(   r)   r¾   ª  s   	r¾   c               @   sp   e Zd ZejZeje ddœdd„Z	e
dƒ\ZZZedœdd„Zeed	œd
d„Zedœdd„Zedœdd„ZdS )ÚExtendedKeyUsageN)Úusagesr    c             C   s,   t |ƒ}tdd„ |D ƒƒs"tdƒ‚|| _d S )Nc             s   s   | ]}t |tƒV  qd S )N)r!   r   )rj   rk   r(   r(   r)   rl   ×  s    z,ExtendedKeyUsage.__init__.<locals>.<genexpr>z9Every item in the usages list must be an ObjectIdentifier)rJ   rn   rP   Ú_usages)r.   rÈ   r(   r(   r)   r:   Õ  s
    zExtendedKeyUsage.__init__rÉ   )r    c             C   s   d| j › d�S )Nz<ExtendedKeyUsage(z)>)rÉ   )r.   r(   r(   r)   rS   à  s    zExtendedKeyUsage.__repr__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   rÇ   r]   rÉ   )r.   r\   r(   r(   r)   r^   ã  s    
zExtendedKeyUsage.__eq__c             C   s   t t| jƒƒS )N)r_   rw   rÉ   )r.   r(   r(   r)   r`   é  s    zExtendedKeyUsage.__hash__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   ì  s    zExtendedKeyUsage.public_bytes)r<   r=   r>   r   ZEXTENDED_KEY_USAGEr8   rD   rT   r   r:   r5   rV   rW   rX   r?   rS   rc   rd   r^   r4   r`   rF   r"   r(   r(   r(   r)   rÇ   Ò  s   	rÇ   c               @   sL   e Zd ZejZeedœdd„Ze	dœdd„Z
edœdd„Zedœd	d
„ZdS )ÚOCSPNoCheck)r\   r    c             C   s   t |tƒstS dS )NT)r!   rÊ   r]   )r.   r\   r(   r(   r)   r^   ó  s    
zOCSPNoCheck.__eq__)r    c             C   s   t tƒS )N)r_   rÊ   )r.   r(   r(   r)   r`   ù  s    zOCSPNoCheck.__hash__c             C   s   dS )Nz<OCSPNoCheck()>r(   )r.   r(   r(   r)   rS   ü  s    zOCSPNoCheck.__repr__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   ÿ  s    zOCSPNoCheck.public_bytesN)r<   r=   r>   r   ZOCSP_NO_CHECKr8   rc   rd   r^   r4   r`   r?   rS   rF   r"   r(   r(   r(   r)   rÊ   ð  s
   rÊ   c               @   sL   e Zd ZejZeedœdd„Ze	dœdd„Z
edœdd„Zedœd	d
„ZdS )ÚPrecertPoison)r\   r    c             C   s   t |tƒstS dS )NT)r!   rË   r]   )r.   r\   r(   r(   r)   r^     s    
zPrecertPoison.__eq__)r    c             C   s   t tƒS )N)r_   rË   )r.   r(   r(   r)   r`     s    zPrecertPoison.__hash__c             C   s   dS )Nz<PrecertPoison()>r(   )r.   r(   r(   r)   rS     s    zPrecertPoison.__repr__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"     s    zPrecertPoison.public_bytesN)r<   r=   r>   r   ZPRECERT_POISONr8   rc   rd   r^   r4   r`   r?   rS   rF   r"   r(   r(   r(   r)   rË     s
   rË   c               @   sp   e Zd ZejZejd ddœdd„Ze	dƒ\Z
ZZedœdd	„Zeed
œdd„Zedœdd„Zedœdd„ZdS )Ú
TLSFeatureÚTLSFeatureTypeN)Úfeaturesr    c             C   s:   t |ƒ}tdd„ |D ƒƒ s(t|ƒdkr0tdƒ‚|| _d S )Nc             s   s   | ]}t |tƒV  qd S )N)r!   rÍ   )rj   rk   r(   r(   r)   rl     s    z&TLSFeature.__init__.<locals>.<genexpr>r   z@features must be a list of elements from the TLSFeatureType enum)rJ   rn   r,   rP   Ú	_features)r.   rÎ   r(   r(   r)   r:     s    zTLSFeature.__init__rÏ   )r    c             C   s   d| j › d�S )Nz<TLSFeature(features=z)>)rÏ   )r.   r(   r(   r)   rS   (  s    zTLSFeature.__repr__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   rÌ   r]   rÏ   )r.   r\   r(   r(   r)   r^   +  s    
zTLSFeature.__eq__c             C   s   t t| jƒƒS )N)r_   rw   rÏ   )r.   r(   r(   r)   r`   1  s    zTLSFeature.__hash__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   4  s    zTLSFeature.public_bytes)r<   r=   r>   r   ZTLS_FEATUREr8   rD   rT   r:   r5   rV   rW   rX   r?   rS   rc   rd   r^   r4   r`   rF   r"   r(   r(   r(   r)   rÌ     s   rÌ   c               @   s   e Zd ZdZdZdS )rÍ   r«   é   N)r<   r=   r>   Zstatus_requestZstatus_request_v2r(   r(   r(   r)   rÍ   8  s   rÍ   c             C   s   i | ]}||j “qS r(   )rQ   )rj   rk   r(   r(   r)   ú
<dictcomp>C  s    rÑ   c               @   sn   e Zd ZejZeddœdd„Zedœdd„Z	e
edœd	d
„Zedœdd„Zeedœdd„ƒZedœdd„ZdS )ÚInhibitAnyPolicyN)Ú
skip_certsr    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!   r4   rP   rm   Ú_skip_certs)r.   rÓ   r(   r(   r)   r:   I  s
    
zInhibitAnyPolicy.__init__)r    c             C   s   d| j › d�S )Nz<InhibitAnyPolicy(skip_certs=z)>)rÓ   )r.   r(   r(   r)   rS   R  s    zInhibitAnyPolicy.__repr__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   rÒ   r]   rÓ   )r.   r\   r(   r(   r)   r^   U  s    
zInhibitAnyPolicy.__eq__c             C   s
   t | jƒS )N)r_   rÓ   )r.   r(   r(   r)   r`   [  s    zInhibitAnyPolicy.__hash__c             C   s   | j S )N)rÔ   )r.   r(   r(   r)   rÓ   ^  s    zInhibitAnyPolicy.skip_certsc             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   b  s    zInhibitAnyPolicy.public_bytes)r<   r=   r>   r   ZINHIBIT_ANY_POLICYr8   r4   r:   r?   rS   rc   rd   r^   r`   re   rÓ   rF   r"   r(   r(   r(   r)   rÒ   F  s   	rÒ   c               @   s  e Zd ZejZeeeeeeeeeddœ
dd„Zeedœdd„ƒZ	eedœdd	„ƒZ
eedœd
d„ƒZeedœdd„ƒZeedœdd„ƒZeedœdd„ƒZeedœdd„ƒZeedœdd„ƒZeedœdd„ƒZedœdd„Zeedœdd„Zedœdd„Zedœdd „ZdS )!ÚKeyUsageN)
Údigital_signatureÚcontent_commitmentÚkey_enciphermentÚdata_enciphermentÚkey_agreementÚkey_cert_signÚcrl_signÚencipher_onlyÚdecipher_onlyr    c
       
      C   sP   | r|s|	rt dƒ‚|| _|| _|| _|| _|| _|| _|| _|| _|	| _	d S )NzKencipher_only and decipher_only can only be true when key_agreement is true)
rm   Ú_digital_signatureÚ_content_commitmentÚ_key_enciphermentÚ_data_enciphermentÚ_key_agreementÚ_key_cert_signÚ	_crl_signÚ_encipher_onlyÚ_decipher_only)
r.   rÖ   r×   rØ   rÙ   rÚ   rÛ   rÜ   rÝ   rÞ   r(   r(   r)   r:   i  s    zKeyUsage.__init__)r    c             C   s   | j S )N)rß   )r.   r(   r(   r)   rÖ   …  s    zKeyUsage.digital_signaturec             C   s   | j S )N)rà   )r.   r(   r(   r)   r×   ‰  s    zKeyUsage.content_commitmentc             C   s   | j S )N)rá   )r.   r(   r(   r)   rØ   �  s    zKeyUsage.key_enciphermentc             C   s   | j S )N)râ   )r.   r(   r(   r)   rÙ   ‘  s    zKeyUsage.data_enciphermentc             C   s   | j S )N)rã   )r.   r(   r(   r)   rÚ   •  s    zKeyUsage.key_agreementc             C   s   | j S )N)rä   )r.   r(   r(   r)   rÛ   ™  s    zKeyUsage.key_cert_signc             C   s   | j S )N)rå   )r.   r(   r(   r)   rÜ   �  s    zKeyUsage.crl_signc             C   s   | j stdƒ‚n| jS d S )Nz7encipher_only is undefined unless key_agreement is true)rÚ   rm   ræ   )r.   r(   r(   r)   rÝ   ¡  s    zKeyUsage.encipher_onlyc             C   s   | j stdƒ‚n| jS d S )Nz7decipher_only is undefined unless key_agreement is true)rÚ   rm   rç   )r.   r(   r(   r)   rÞ   ª  s    zKeyUsage.decipher_onlyc             C   s<   y| j }| j}W n tk
r,   d}d}Y nX dj| ||ƒ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})>)rÝ   rÞ   rm   rC   )r.   rÝ   rÞ   r(   r(   r)   rS   ³  s    

zKeyUsage.__repr__)r\   r    c             C   sz   t |tƒstS | j|jkox| j|jkox| j|jkox| j|jkox| j|jkox| j|jkox| j	|j	kox| j
|j
kox| j|jkS )N)r!   rÕ   r]   rÖ   r×   rØ   rÙ   rÚ   rÛ   rÜ   ræ   rç   )r.   r\   r(   r(   r)   r^   È  s    
zKeyUsage.__eq__c          
   C   s,   t | j| j| j| j| j| j| j| j| j	f	ƒS )N)
r_   rÖ   r×   rØ   rÙ   rÚ   rÛ   rÜ   ræ   rç   )r.   r(   r(   r)   r`   Ø  s    zKeyUsage.__hash__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   ç  s    zKeyUsage.public_bytes)r<   r=   r>   r   Z	KEY_USAGEr8   rd   r:   re   rÖ   r×   rØ   rÙ   rÚ   rÛ   rÜ   rÝ   rÞ   r?   rS   rc   r^   r4   r`   rF   r"   r(   r(   r(   r)   rÕ   f  sB   rÕ   c               @   sô   e Zd ZejZejeje	  ejeje	  ddœdd„Z
eedœdd„Zeje	 ddœd	d
„Zeje	 ddœdd„Zeje	 ddœdd„Zedœdd„Zedœdd„Zeejeje	  dœdd„ƒZeejeje	  dœdd„ƒZedœdd„ZdS )ÚNameConstraintsN)Úpermitted_subtreesÚexcluded_subtreesr    c             C   s¨   |d k	r@t |ƒ}|stdƒ‚tdd„ |D ƒƒs6tdƒ‚| j|ƒ |d k	r€t |ƒ}|s\tdƒ‚tdd„ |D ƒƒsvtdƒ‚| j|ƒ |d kr˜|d kr˜tdƒ‚|| _|| _d S )	Nz3permitted_subtrees must be a non-empty list or Nonec             s   s   | ]}t |tƒV  qd S )N)r!   r   )rj   rk   r(   r(   r)   rl   ù  s    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   s   | ]}t |tƒV  qd S )N)r!   r   )rj   rk   r(   r(   r)   rl     s    z?excluded_subtrees must be a list of GeneralName objects or NonezIAt least one of permitted_subtrees and excluded_subtrees must not be None)rJ   rm   rn   rP   Ú_validate_treeÚ_permitted_subtreesÚ_excluded_subtrees)r.   ré   rê   r(   r(   r)   r:   î  s.    

zNameConstraints.__init__)r\   r    c             C   s&   t |tƒstS | j|jko$| j|jkS )N)r!   rè   r]   rê   ré   )r.   r\   r(   r(   r)   r^     s    
zNameConstraints.__eq__)Útreer    c             C   s   | j |ƒ | j|ƒ d S )N)Ú_validate_ip_nameÚ_validate_dns_name)r.   rî   r(   r(   r)   rë   !  s    
zNameConstraints._validate_treec             C   s   t dd„ |D ƒƒrtdƒ‚d S )Nc             s   s.   | ]&}t |tƒo$t |jtjtjfƒ V  qd S )N)r!   r   rQ   Ú	ipaddressÚIPv4NetworkÚIPv6Network)rj   Únamer(   r(   r)   rl   '  s   z4NameConstraints._validate_ip_name.<locals>.<genexpr>zGIPAddress name constraints must be an IPv4Network or IPv6Network object)ÚanyrP   )r.   rî   r(   r(   r)   rï   %  s
    
z!NameConstraints._validate_ip_namec             C   s   t dd„ |D ƒƒrtdƒ‚d S )Nc             s   s"   | ]}t |tƒod |jkV  qdS )Ú*N)r!   r   rQ   )rj   rô   r(   r(   r)   rl   4  s    z5NameConstraints._validate_dns_name.<locals>.<genexpr>zDDNSName name constraints must not contain the '*' wildcard character)rõ   rm   )r.   rî   r(   r(   r)   rð   2  s    z"NameConstraints._validate_dns_name)r    c             C   s
   dj | ƒS )Nze<NameConstraints(permitted_subtrees={0.permitted_subtrees}, excluded_subtrees={0.excluded_subtrees})>)rC   )r.   r(   r(   r)   rS   ;  s    zNameConstraints.__repr__c             C   s@   | j d k	rt| j ƒ}nd }| jd k	r0t| jƒ}nd }t||fƒS )N)ré   rw   rê   r_   )r.   ZpsÚesr(   r(   r)   r`   A  s    



zNameConstraints.__hash__c             C   s   | j S )N)rì   )r.   r(   r(   r)   ré   R  s    z"NameConstraints.permitted_subtreesc             C   s   | j S )N)rí   )r.   r(   r(   r)   rê   X  s    z!NameConstraints.excluded_subtreesc             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   ^  s    zNameConstraints.public_bytes)r<   r=   r>   r   ZNAME_CONSTRAINTSr8   rD   rx   rT   r   r:   rc   rd   r^   rë   rï   rð   r?   rS   r4   r`   re   rz   ré   rê   rF   r"   r(   r(   r(   r)   rè   ë  s   &		rè   c               @   s‚   e Zd Zeeeddœdd„Zeedœdd„ƒZeedœdd	„ƒZ	eedœd
d„ƒZ
edœdd„Zeedœdd„Zedœdd„ZdS )Ú	ExtensionN)r8   ÚcriticalrQ   r    c             C   s:   t |tƒstdƒ‚t |tƒs$tdƒ‚|| _|| _|| _d S )Nz2oid argument must be an ObjectIdentifier instance.z critical must be a boolean value)r!   r   rP   rd   Ú_oidÚ	_criticalÚ_value)r.   r8   rù   rQ   r(   r(   r)   r:   c  s    

zExtension.__init__)r    c             C   s   | j S )N)rú   )r.   r(   r(   r)   r8   r  s    zExtension.oidc             C   s   | j S )N)rû   )r.   r(   r(   r)   rù   v  s    zExtension.criticalc             C   s   | j S )N)rü   )r.   r(   r(   r)   rQ   z  s    zExtension.valuec             C   s
   dj | ƒS )Nz@<Extension(oid={0.oid}, critical={0.critical}, value={0.value})>)rC   )r.   r(   r(   r)   rS   ~  s    zExtension.__repr__)r\   r    c             C   s2   t |tƒstS | j|jko0| j|jko0| j|jkS )N)r!   rø   r]   r8   rù   rQ   )r.   r\   r(   r(   r)   r^   „  s
    
zExtension.__eq__c             C   s   t | j| j| jfƒS )N)r_   r8   rù   rQ   )r.   r(   r(   r)   r`   Ž  s    zExtension.__hash__)r<   r=   r>   r   rd   r   r:   re   r8   rù   rQ   r?   rS   rc   r^   r4   r`   r(   r(   r(   r)   rø   b  s   
rø   c            	   @   sš  e Zd Zeje ddœdd„Zedƒ\ZZ	Z
ejejeje eje eje f eje dœdd„ƒZejeje eje dœd	d„ƒZejeje eje dœd
d„ƒZejeje eje dœdd„ƒZejeje eje dœdd„ƒZejeje eje eje eje eje eje eje f ejeje eje eje eje eje f dœdd„Zedœdd„Zeedœdd„Zedœdd„Z dS )ÚGeneralNamesN)Úgeneral_namesr    c             C   s,   t |ƒ}tdd„ |D ƒƒs"tdƒ‚|| _d S )Nc             s   s   | ]}t |tƒV  qd S )N)r!   r   )rj   rk   r(   r(   r)   rl   •  s    z(GeneralNames.__init__.<locals>.<genexpr>z^Every item in the general_names list must be an object conforming to the GeneralName interface)rJ   rn   rP   Ú_general_names)r.   rþ   r(   r(   r)   r:   “  s
    zGeneralNames.__init__rÿ   )Útyper    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   Úget_values_for_typeŸ  s    	z GeneralNames.get_values_for_typec             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  ª  s    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  ±  s    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  ¸  s    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  ¾  s    c                s0   ‡ fdd„| D ƒ}ˆ t kr(dd„ |D ƒS t|ƒS )Nc             3   s   | ]}t |ˆ ƒr|V  qd S )N)r!   )rj   Úi)r   r(   r)   rl   Ù  s    z3GeneralNames.get_values_for_type.<locals>.<genexpr>c             S   s   g | ]
}|j ‘qS r(   )rQ   )rj   r  r(   r(   r)   ú
<listcomp>Û  s    z4GeneralNames.get_values_for_type.<locals>.<listcomp>)r   rJ   )r.   r   Úobjsr(   )r   r)   r  Ä  s    )r    c             C   s   d| j › d�S )Nz<GeneralNames(z)>)rÿ   )r.   r(   r(   r)   rS   Þ  s    zGeneralNames.__repr__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   rý   r]   rÿ   )r.   r\   r(   r(   r)   r^   á  s    
zGeneralNames.__eq__c             C   s   t t| jƒƒS )N)r_   rw   rÿ   )r.   r(   r(   r)   r`   ç  s    zGeneralNames.__hash__)!r<   r=   r>   rD   rT   r   r:   r5   rV   rW   rX   Úoverloadr½   rU   r   r   r   rz   r?   r  r   r   r   r   r   r   r   rS   rc   rd   r^   r4   r`   r(   r(   r(   r)   rý   ’  sJ   

rý   c            	   @   s®  e Zd ZejZeje ddœdd„Z	e
dƒ\ZZZejejeje eje eje f eje dœdd„ƒZejeje eje dœd	d„ƒZejeje eje dœd
d„ƒZejeje eje dœdd„ƒZejeje eje dœdd„ƒZejeje eje eje eje eje eje eje f ejeje eje eje eje eje f dœdd„Zedœdd„Zee dœdd„Z!e"dœdd„Z#e$dœdd„Z%dS )ÚSubjectAlternativeNameN)rþ   r    c             C   s   t |ƒ| _d S )N)rý   rÿ   )r.   rþ   r(   r(   r)   r:   î  s    zSubjectAlternativeName.__init__rÿ   )r   r    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  ó  s    	z*SubjectAlternativeName.get_values_for_typec             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  þ  s    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r    s    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r    s    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r    s    c             C   s   | j j|ƒS )N)rÿ   r  )r.   r   r(   r(   r)   r    s    )r    c             C   s   d| j › d�S )Nz<SubjectAlternativeName(z)>)rÿ   )r.   r(   r(   r)   rS   ,  s    zSubjectAlternativeName.__repr__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   r  r]   rÿ   )r.   r\   r(   r(   r)   r^   /  s    
zSubjectAlternativeName.__eq__c             C   s
   t | jƒS )N)r_   rÿ   )r.   r(   r(   r)   r`   5  s    zSubjectAlternativeName.__hash__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   8  s    z#SubjectAlternativeName.public_bytes)&r<   r=   r>   r   ZSUBJECT_ALTERNATIVE_NAMEr8   rD   rT   r   r:   r5   rV   rW   rX   r  r½   rU   r   r   r   rz   r?   r  r   r   r   r   r   r   r   rS   rc   rd   r^   r4   r`   rF   r"   r(   r(   r(   r)   r  ë  sN   r  c            	   @   s®  e Zd ZejZeje ddœdd„Z	e
dƒ\ZZZejejeje eje eje f eje dœdd„ƒZejeje eje dœd	d„ƒZejeje eje dœd
d„ƒZejeje eje dœdd„ƒZejeje eje dœdd„ƒZejeje eje eje eje eje eje eje f ejeje eje eje eje eje f dœdd„Zedœdd„Zee dœdd„Z!e"dœdd„Z#e$dœdd„Z%dS )ÚIssuerAlternativeNameN)rþ   r    c             C   s   t |ƒ| _d S )N)rý   rÿ   )r.   rþ   r(   r(   r)   r:   ?  s    zIssuerAlternativeName.__init__rÿ   )r   r    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  D  s    	z)IssuerAlternativeName.get_values_for_typec             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  O  s    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  V  s    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  ]  s    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  c  s    c             C   s   | j j|ƒS )N)rÿ   r  )r.   r   r(   r(   r)   r  i  s    )r    c             C   s   d| j › d�S )Nz<IssuerAlternativeName(z)>)rÿ   )r.   r(   r(   r)   rS   }  s    zIssuerAlternativeName.__repr__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   r  r]   rÿ   )r.   r\   r(   r(   r)   r^   €  s    
zIssuerAlternativeName.__eq__c             C   s
   t | jƒS )N)r_   rÿ   )r.   r(   r(   r)   r`   †  s    zIssuerAlternativeName.__hash__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   ‰  s    z"IssuerAlternativeName.public_bytes)&r<   r=   r>   r   ZISSUER_ALTERNATIVE_NAMEr8   rD   rT   r   r:   r5   rV   rW   rX   r  r½   rU   r   r   r   rz   r?   r  r   r   r   r   r   r   r   rS   rc   rd   r^   r4   r`   rF   r"   r(   r(   r(   r)   r  <  sN   r  c            	   @   s®  e Zd ZejZeje ddœdd„Z	e
dƒ\ZZZejejeje eje eje f eje dœdd„ƒZejeje eje dœd	d„ƒZejeje eje dœd
d„ƒZejeje eje dœdd„ƒZejeje eje dœdd„ƒZejeje eje eje eje eje eje eje f ejeje eje eje eje eje f dœdd„Zedœdd„Zee dœdd„Z!e"dœdd„Z#e$dœdd„Z%dS )ÚCertificateIssuerN)rþ   r    c             C   s   t |ƒ| _d S )N)rý   rÿ   )r.   rþ   r(   r(   r)   r:   �  s    zCertificateIssuer.__init__rÿ   )r   r    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  •  s    	z%CertificateIssuer.get_values_for_typec             C   s   d S )Nr(   )r.   r   r(   r(   r)   r     s    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  §  s    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  ®  s    c             C   s   d S )Nr(   )r.   r   r(   r(   r)   r  ´  s    c             C   s   | j j|ƒS )N)rÿ   r  )r.   r   r(   r(   r)   r  º  s    )r    c             C   s   d| j › d�S )Nz<CertificateIssuer(z)>)rÿ   )r.   r(   r(   r)   rS   Î  s    zCertificateIssuer.__repr__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   r  r]   rÿ   )r.   r\   r(   r(   r)   r^   Ñ  s    
zCertificateIssuer.__eq__c             C   s
   t | jƒS )N)r_   rÿ   )r.   r(   r(   r)   r`   ×  s    zCertificateIssuer.__hash__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   Ú  s    zCertificateIssuer.public_bytes)&r<   r=   r>   r   ZCERTIFICATE_ISSUERr8   rD   rT   r   r:   r5   rV   rW   rX   r  r½   rU   r   r   r   rz   r?   r  r   r   r   r   r   r   r   rS   rc   rd   r^   r4   r`   rF   r"   r(   r(   r(   r)   r  �  sN   r  c               @   sn   e Zd ZejZeddœdd„Zedœdd„Z	e
edœd	d
„Zedœdd„Zeedœdd„ƒZedœdd„ZdS )Ú	CRLReasonN)Úreasonr    c             C   s   t |tƒstdƒ‚|| _d S )Nz*reason must be an element from ReasonFlags)r!   r‘   rP   Ú_reason)r.   r
  r(   r(   r)   r:   á  s    
zCRLReason.__init__)r    c             C   s   d| j › d�S )Nz<CRLReason(reason=z)>)r  )r.   r(   r(   r)   rS   ç  s    zCRLReason.__repr__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   r	  r]   r
  )r.   r\   r(   r(   r)   r^   ê  s    
zCRLReason.__eq__c             C   s
   t | jƒS )N)r_   r
  )r.   r(   r(   r)   r`   ð  s    zCRLReason.__hash__c             C   s   | j S )N)r  )r.   r(   r(   r)   r
  ó  s    zCRLReason.reasonc             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   ÷  s    zCRLReason.public_bytes)r<   r=   r>   r   Z
CRL_REASONr8   r‘   r:   r?   rS   rc   rd   r^   r4   r`   re   r
  rF   r"   r(   r(   r(   r)   r	  Þ  s   r	  c               @   sr   e Zd ZejZejddœdd„Zedœdd„Z	e
edœd	d
„Zedœdd„Zeejdœdd„ƒZedœdd„ZdS )ÚInvalidityDateN)Úinvalidity_dater    c             C   s   t |tjƒstdƒ‚|| _d S )Nz+invalidity_date must be a datetime.datetime)r!   ÚdatetimerP   Ú_invalidity_date)r.   r  r(   r(   r)   r:   þ  s    zInvalidityDate.__init__)r    c             C   s   dj | jƒS )Nz$<InvalidityDate(invalidity_date={})>)rC   r  )r.   r(   r(   r)   rS     s    zInvalidityDate.__repr__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   r  r]   r  )r.   r\   r(   r(   r)   r^   	  s    
zInvalidityDate.__eq__c             C   s
   t | jƒS )N)r_   r  )r.   r(   r(   r)   r`     s    zInvalidityDate.__hash__c             C   s   | j S )N)r  )r.   r(   r(   r)   r    s    zInvalidityDate.invalidity_datec             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"     s    zInvalidityDate.public_bytes)r<   r=   r>   r   ZINVALIDITY_DATEr8   r  r:   r?   rS   rc   rd   r^   r4   r`   re   r  rF   r"   r(   r(   r(   r)   r  û  s   r  c               @   sp   e Zd ZejZeje ddœdd„Z	e
dƒ\ZZZedœdd„Zedœd	d
„Zeedœdd„Zedœdd„ZdS )Ú)PrecertificateSignedCertificateTimestampsN)Úsigned_certificate_timestampsr    c             C   s,   t |ƒ}tdd„ |D ƒƒs"tdƒ‚|| _d S )Nc             s   s   | ]}t |tƒV  qd S )N)r!   r   )rj   Úsctr(   r(   r)   rl   %  s   zEPrecertificateSignedCertificateTimestamps.__init__.<locals>.<genexpr>zYEvery item in the signed_certificate_timestamps list must be a SignedCertificateTimestamp)rJ   rn   rP   Ú_signed_certificate_timestamps)r.   r  r(   r(   r)   r:     s    
z2PrecertificateSignedCertificateTimestamps.__init__r  )r    c             C   s   dj t| ƒƒS )Nz/<PrecertificateSignedCertificateTimestamps({})>)rC   rJ   )r.   r(   r(   r)   rS   2  s    z2PrecertificateSignedCertificateTimestamps.__repr__c             C   s   t t| jƒƒS )N)r_   rw   r  )r.   r(   r(   r)   r`   7  s    z2PrecertificateSignedCertificateTimestamps.__hash__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   r  r]   r  )r.   r\   r(   r(   r)   r^   :  s    
z0PrecertificateSignedCertificateTimestamps.__eq__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   C  s    z6PrecertificateSignedCertificateTimestamps.public_bytes)r<   r=   r>   r   Z%PRECERT_SIGNED_CERTIFICATE_TIMESTAMPSr8   rD   rT   r   r:   r5   rV   rW   rX   r?   rS   r4   r`   rc   rd   r^   rF   r"   r(   r(   r(   r)   r    s   	r  c               @   sp   e Zd ZejZeje ddœdd„Z	e
dƒ\ZZZedœdd„Zedœd	d
„Zeedœdd„Zedœdd„ZdS )ÚSignedCertificateTimestampsN)r  r    c             C   s,   t |ƒ}tdd„ |D ƒƒs"tdƒ‚|| _d S )Nc             s   s   | ]}t |tƒV  qd S )N)r!   r   )rj   r  r(   r(   r)   rl   R  s   z7SignedCertificateTimestamps.__init__.<locals>.<genexpr>zYEvery item in the signed_certificate_timestamps list must be a SignedCertificateTimestamp)rJ   rn   rP   r  )r.   r  r(   r(   r)   r:   J  s    
z$SignedCertificateTimestamps.__init__r  )r    c             C   s   dt | ƒ› d�S )Nz<SignedCertificateTimestamps(z)>)rJ   )r.   r(   r(   r)   rS   _  s    z$SignedCertificateTimestamps.__repr__c             C   s   t t| jƒƒS )N)r_   rw   r  )r.   r(   r(   r)   r`   b  s    z$SignedCertificateTimestamps.__hash__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   r  r]   r  )r.   r\   r(   r(   r)   r^   e  s    
z"SignedCertificateTimestamps.__eq__c             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   n  s    z(SignedCertificateTimestamps.public_bytes)r<   r=   r>   r   ZSIGNED_CERTIFICATE_TIMESTAMPSr8   rD   rT   r   r:   r5   rV   rW   rX   r?   rS   r4   r`   rc   rd   r^   rF   r"   r(   r(   r(   r)   r  G  s   	r  c               @   sn   e Zd ZejZeddœdd„Zee	dœdd„Z
edœd	d
„Zedœdd„Zeedœdd„ƒZedœdd„ZdS )Ú	OCSPNonceN)Únoncer    c             C   s   t |tƒstdƒ‚|| _d S )Nznonce must be bytes)r!   rF   rP   Ú_nonce)r.   r  r(   r(   r)   r:   u  s    
zOCSPNonce.__init__)r\   r    c             C   s   t |tƒstS | j|jkS )N)r!   r  r]   r  )r.   r\   r(   r(   r)   r^   {  s    
zOCSPNonce.__eq__)r    c             C   s
   t | jƒS )N)r_   r  )r.   r(   r(   r)   r`   �  s    zOCSPNonce.__hash__c             C   s   d| j ›d�S )Nz<OCSPNonce(nonce=z)>)r  )r.   r(   r(   r)   rS   „  s    zOCSPNonce.__repr__c             C   s   | j S )N)r  )r.   r(   r(   r)   r  ‡  s    zOCSPNonce.noncec             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   ‹  s    zOCSPNonce.public_bytes)r<   r=   r>   r   ZNONCEr8   rF   r:   rc   rd   r^   r4   r`   r?   rS   re   r  r"   r(   r(   r(   r)   r  r  s   r  c            	   @   s"  e Zd ZejZejeje	  eje
 eeejeje  eeddœdd„Zedœdd„Zeedœd	d
„Zedœdd„Zeejeje	  dœdd„ƒZeeje
 dœdd„ƒZeedœdd„ƒZeedœdd„ƒZeejeje  dœdd„ƒZeedœdd„ƒZeedœdd„ƒZedœdd„ZdS )ÚIssuingDistributionPointN)r’   r“   Úonly_contains_user_certsÚonly_contains_ca_certsÚonly_some_reasonsÚindirect_crlÚonly_contains_attribute_certsr    c       	      C   s  |d k	rt |ƒ}|r<t|tƒ s4tdd„ |D ƒƒ r<tdƒ‚|r\tj|ksTtj|kr\tdƒ‚t|t	ƒo‚t|t	ƒo‚t|t	ƒo‚t|t	ƒsŒtdƒ‚||||g}t
dd„ |D ƒƒdkr¶td	ƒ‚t|||||||gƒsÔtd
ƒ‚|| _|| _|| _|| _|| _|| _|| _d S )Nc             s   s   | ]}t |tƒV  qd S )N)r!   r‘   )rj   rk   r(   r(   r)   rl   ¡  s    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(   )rj   rk   r(   r(   r)   r  Ã  s    z5IssuingDistributionPoint.__init__.<locals>.<listcomp>r§   z‹Only one of the following can be set to True: only_contains_user_certs, only_contains_ca_certs, indirect_crl, only_contains_attribute_certszàCannot 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.)rJ   r!   r–   rn   rP   r‘   r—   r˜   rm   rd   r,   rõ   Ú_only_contains_user_certsÚ_only_contains_ca_certsÚ_indirect_crlÚ_only_contains_attribute_certsÚ_only_some_reasonsr™   rš   )	r.   r’   r“   r  r  r  r  r  Zcrl_constraintsr(   r(   r)   r:   ’  sT    






z!IssuingDistributionPoint.__init__)r    c             C   s
   dj | ƒS )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})>)rC   )r.   r(   r(   r)   rS   å  s    z!IssuingDistributionPoint.__repr__)r\   r    c             C   sb   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S )N)
r!   r  r]   r’   r“   r  r  r  r  r  )r.   r\   r(   r(   r)   r^   ñ  s    
zIssuingDistributionPoint.__eq__c             C   s$   t | j| j| j| j| j| j| jfƒS )N)r_   r’   r“   r  r  r  r  r  )r.   r(   r(   r)   r`      s    z!IssuingDistributionPoint.__hash__c             C   s   | j S )N)r™   )r.   r(   r(   r)   r’     s    z"IssuingDistributionPoint.full_namec             C   s   | j S )N)rš   )r.   r(   r(   r)   r“     s    z&IssuingDistributionPoint.relative_namec             C   s   | j S )N)r  )r.   r(   r(   r)   r    s    z1IssuingDistributionPoint.only_contains_user_certsc             C   s   | j S )N)r  )r.   r(   r(   r)   r    s    z/IssuingDistributionPoint.only_contains_ca_certsc             C   s   | j S )N)r"  )r.   r(   r(   r)   r    s    z*IssuingDistributionPoint.only_some_reasonsc             C   s   | j S )N)r   )r.   r(   r(   r)   r  #  s    z%IssuingDistributionPoint.indirect_crlc             C   s   | j S )N)r!  )r.   r(   r(   r)   r  '  s    z6IssuingDistributionPoint.only_contains_attribute_certsc             C   s
   t j| ƒS )N)ra   rb   )r.   r(   r(   r)   r"   +  s    z%IssuingDistributionPoint.public_bytes) r<   r=   r>   r   ZISSUING_DISTRIBUTION_POINTr8   rD   rx   rT   r   r   rd   rž   r‘   r:   r?   rS   rc   r^   r4   r`   re   rz   r’   r“   r  r  r  r  r  rF   r"   r(   r(   r(   r)   r  �  s6   Jr  c               @   s|   e Zd Zeeddœdd„Zeedœdd„ƒZeedœdd	„ƒZe	dœd
d„Z
eedœdd„Zedœdd„Zedœdd„ZdS )rO   N)r8   rQ   r    c             C   s"   t |tƒstdƒ‚|| _|| _d S )Nzoid must be an ObjectIdentifier)r!   r   rP   rú   rü   )r.   r8   rQ   r(   r(   r)   r:   0  s    
zUnrecognizedExtension.__init__)r    c             C   s   | j S )N)rú   )r.   r(   r(   r)   r8   6  s    zUnrecognizedExtension.oidc             C   s   | j S )N)rü   )r.   r(   r(   r)   rQ   :  s    zUnrecognizedExtension.valuec             C   s
   dj | ƒS )Nz7<UnrecognizedExtension(oid={0.oid}, value={0.value!r})>)rC   )r.   r(   r(   r)   rS   >  s    zUnrecognizedExtension.__repr__)r\   r    c             C   s&   t |tƒstS | j|jko$| j|jkS )N)r!   rO   r]   r8   rQ   )r.   r\   r(   r(   r)   r^   D  s    
zUnrecognizedExtension.__eq__c             C   s   t | j| jfƒS )N)r_   r8   rQ   )r.   r(   r(   r)   r`   J  s    zUnrecognizedExtension.__hash__c             C   s   | j S )N)rQ   )r.   r(   r(   r)   r"   M  s    z"UnrecognizedExtension.public_bytes)r<   r=   r>   r   rF   r:   re   r8   rQ   r?   rS   rc   rd   r^   r4   r`   r"   r(   r(   r(   r)   rO   /  s   rO   )gÚabcr  r$   rñ   rD   Zcryptographyr   Z"cryptography.hazmat.bindings._rustr   r   ra   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   rF   r*   r?   r5   Ú	Exceptionr6   rA   ÚABCMetar   rH   rY   rf   rt   r}   r�   r~   r†   r‹   rŒ   r�   r�   ÚEnumr‘   r    r¡   r¢   rŸ   r£   r¤   r¥   r¦   Z_REASON_BIT_MAPPINGZ_CRLREASONFLAGSr¯   r´   rµ   r¸   r¾   rÇ   rÊ   rË   rÌ   rÍ   Z_TLS_FEATURE_TYPE_TO_ENUMrÒ   rÕ   rè   ÚGenericrø   rý   r  r  r  r	  r  r  r  r  r  rO   r(   r(   r(   r)   Ú<module>   s    ,'l$!!(.%%o

A=+("  w0YQQQ-+ !