o
    ge                     @   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m	Z	m
Z
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 d d	lmZmZmZ d d
lmZ d dlmZmZm Z m!Z! dede"fddZ#dd Z$G dd de%Z&G dd de%Z'G dd de j(dZ)G dd de*Z+G dd de)Z,G dd de)Z-G dd  d e)Z.G d!d" d"e)Z/G d#d$ d$e)Z0G d%d& d&e*Z1G d'd( d(e)Z2G d)d* d*e)Z3G d+d, d,e)Z4G d-d. d.e)Z5G d/d0 d0e*Z6G d1d2 d2ej7Z8G d3d4 d4e)Z9G d5d6 d6e)Z:G d7d8 d8e*Z;G d9d: d:e*Z<G d;d< d<e*Z=G d=d> d>e)Z>G d?d@ d@e)Z?G dAdB dBe)Z@G dCdD dDe)ZAG dEdF dFej7ZBdGdH eBD ZCG dIdJ dJe)ZDG dKdL dLe)ZEG dMdN dNe)ZFG dOdP dPe*ZGG dQdR dRe*ZHG dSdT dTe)ZIG dUdV dVe)ZJG dWdX dXe)ZKG dYdZ dZe)ZLG d[d\ d\e)ZMG d]d^ d^e)ZNG d_d` d`e)ZOG dadb dbe)ZPG dcdd dde)ZQG dedf dfe)ZRdS )g    N)utils)
BIT_STRING	DERReaderOBJECT_IDENTIFIERSEQUENCE)_PUBLIC_KEY_TYPES)constant_timeserialization)EllipticCurvePublicKey)RSAPublicKey)SignedCertificateTimestamp)GeneralName	IPAddress	OtherName)RelativeDistinguishedName)CRLEntryExtensionOIDExtensionOIDOCSPExtensionOIDObjectIdentifier
public_keyreturnc                 C   s   t | tr| tjjtjj}nit | tr | tjj	tjj
}nY| tjjtjj}t|}|t}|t}|t}W d    n1 sHw   Y  | |t | s]|  W d    n1 sgw   Y  | dkrvtd|j}t| S )Nr   zInvalid public key encoding)
isinstancer   public_bytesr	   EncodingDERPublicFormatPKCS1r
   X962UncompressedPointSubjectPublicKeyInfor   read_single_elementr   read_elementr   r   is_emptyread_any_element	read_byte
ValueErrordatahashlibsha1digest)r   r&   
serializedreaderpublic_key_info	algorithmpublic_key_data r/   >/usr/lib/python3/dist-packages/cryptography/x509/extensions.py_key_identifier_from_public_key$   s:   



r1   c                    s.    fdd} fdd} fdd}|||fS )Nc                       t t|  S N)lengetattrself
field_namer/   r0   
len_methodM      z*_make_sequence_methods.<locals>.len_methodc                    r2   r3   )iterr5   r6   r8   r/   r0   iter_methodP   r;   z+_make_sequence_methods.<locals>.iter_methodc                    s   t |  | S r3   )r5   )r7   idxr8   r/   r0   getitem_methodS   r;   z._make_sequence_methods.<locals>.getitem_methodr/   )r9   r:   r=   r?   r/   r8   r0   _make_sequence_methodsL   s   
r@   c                       &   e Zd Zdedef fddZ  ZS )DuplicateExtensionmsgoidc                       t t| | || _d S r3   )superrB   __init__rD   r7   rC   rD   	__class__r/   r0   rG   Z      
zDuplicateExtension.__init____name__
__module____qualname__strr   rG   __classcell__r/   r/   rI   r0   rB   Y       rB   c                       rA   )ExtensionNotFoundrC   rD   c                    rE   r3   )rF   rS   rG   rD   rH   rI   r/   r0   rG   `   rK   zExtensionNotFound.__init__rL   r/   r/   rI   r0   rS   _   rR   rS   c                   @   s    e Zd ZejdefddZdS )ExtensionTyper   c                 C      dS )zK
        Returns the oid associated with the given extension type.
        Nr/   r6   r/   r/   r0   rD   f   s    zExtensionType.oidN)rM   rN   rO   abcabstractpropertyr   rD   r/   r/   r/   r0   rT   e   s    rT   )	metaclassc                   @   sR   e Zd Zdejd fddZdeddfddZdd	d
Ze	d\Z
ZZdd ZdS )
Extensions
extensions	Extensionc                 C   
   || _ d S r3   )_extensions)r7   rZ   r/   r/   r0   rG   n      
zExtensions.__init__rD   r   c                 C   s,   | D ]}|j |kr|  S qtd||)NNo {} extension was found)rD   rS   format)r7   rD   extr/   r/   r0   get_extension_for_oidq   s
   
z Extensions.get_extension_for_oidc                 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.r_   )UnrecognizedExtension	TypeErrorr   valuerS   r`   rD   )r7   extclassra   r/   r/   r0   get_extension_for_classx   s   z"Extensions.get_extension_for_classr]   c                 C      d | jS )Nz<Extensions({})>)r`   r]   r6   r/   r/   r0   __repr__      zExtensions.__repr__N)r   r[   )rM   rN   rO   typingListrG   r   rb   rg   r@   __len____iter____getitem__ri   r/   r/   r/   r0   rY   m   s    
rY   c                   @   J   e Zd ZejZdefddZdd Zdd Z	dd	 Z
d
d ZedZdS )	CRLNumber
crl_numberc                 C      t |ts	td|| _d S Nzcrl_number must be an integerr   intrd   _crl_numberr7   rr   r/   r/   r0   rG         

zCRLNumber.__init__c                 C      t |tstS | j|jkS r3   )r   rq   NotImplementedrr   r7   otherr/   r/   r0   __eq__      
zCRLNumber.__eq__c                 C   
   | |k S r3   r/   r|   r/   r/   r0   __ne__   r^   zCRLNumber.__ne__c                 C   
   t | jS r3   hashrr   r6   r/   r/   r0   __hash__   r^   zCRLNumber.__hash__c                 C   rh   )Nz<CRLNumber({})>)r`   rr   r6   r/   r/   r0   ri      rj   zCRLNumber.__repr__rw   N)rM   rN   rO   r   
CRL_NUMBERrD   rv   rG   r~   r   r   ri   r   read_only_propertyrr   r/   r/   r/   r0   rq          rq   c                   @   s   e Zd ZejZdeje dejej	e
  deje fddZededd fdd	Ze	
			 dddZdd Zdd Zdd Zdd ZedZedZedZdS )AuthorityKeyIdentifierkey_identifierauthority_cert_issuerauthority_cert_serial_numberc                 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 r3   r   r   .0xr/   r/   r0   	<genexpr>       

z2AuthorityKeyIdentifier.__init__.<locals>.<genexpr>z;authority_cert_issuer must be a list of GeneralName objectsz/authority_cert_serial_number must be an integer)	r%   listallrd   r   rv   _key_identifier_authority_cert_issuer_authority_cert_serial_number)r7   r   r   r   r/   r/   r0   rG      s*   

zAuthorityKeyIdentifier.__init__r   r   c                 C   s   t |}| |d d dS N)r   r   r   r1   )clsr   r)   r/   r/   r0   from_issuer_public_key   s   z-AuthorityKeyIdentifier.from_issuer_public_keyskiSubjectKeyIdentifierc                 C   s   | |j d d dS r   )r)   )r   r   r/   r/   r0   "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})>r`   r6   r/   r/   r0   ri      s   zAuthorityKeyIdentifier.__repr__c                 C   2   t |tstS | j|jko| j|jko| j|jkS r3   )r   r   r{   r   r   r   r|   r/   r/   r0   r~      s   

zAuthorityKeyIdentifier.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r      r^   zAuthorityKeyIdentifier.__ne__c                 C   s,   | j d u rd }nt| j }t| j|| jfS r3   )r   tupler   r   r   )r7   acir/   r/   r0   r      s   

zAuthorityKeyIdentifier.__hash__r   r   r   N)r   r   r   r   )rM   rN   rO   r   AUTHORITY_KEY_IDENTIFIERrD   rk   OptionalbytesIterabler   rv   rG   classmethodr   r   r   ri   r~   r   r   r   r   r   r   r   r/   r/   r/   r0   r      s<    
!
	
	
r   c                   @   s`   e Zd ZejZdefddZede	dd fddZ
edZd	d
 Zdd Zdd Zdd ZdS )r   r)   c                 C   r\   r3   )_digest)r7   r)   r/   r/   r0   rG     r^   zSubjectKeyIdentifier.__init__r   r   c                 C   s   | t |S r3   r   )r   r   r/   r/   r0   from_public_key  s   z$SubjectKeyIdentifier.from_public_keyr   c                 C   rh   )Nz$<SubjectKeyIdentifier(digest={0!r})>)r`   r)   r6   r/   r/   r0   ri     rj   zSubjectKeyIdentifier.__repr__c                 C   s   t |tstS t| j|jS r3   )r   r   r{   r   bytes_eqr)   r|   r/   r/   r0   r~     s   
zSubjectKeyIdentifier.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zSubjectKeyIdentifier.__ne__c                 C   r   r3   )r   r)   r6   r/   r/   r0   r   "  r^   zSubjectKeyIdentifier.__hash__N)rM   rN   rO   r   SUBJECT_KEY_IDENTIFIERrD   r   rG   r   r   r   r   r   r)   ri   r~   r   r   r/   r/   r/   r0   r     s    
r   c                   @   T   e Zd ZejZdejd fddZe	d\Z
ZZdd Zdd	 Zd
d Zdd ZdS )AuthorityInformationAccessdescriptionsAccessDescriptionc                 C   ,   t |}tdd |D std|| _d S )Nc                 s   r   r3   r   r   r   r/   r/   r0   r   +      z6AuthorityInformationAccess.__init__.<locals>.<genexpr>@Every item in the descriptions list must be an AccessDescriptionr   r   rd   _descriptionsr7   r   r/   r/   r0   rG   )     
z#AuthorityInformationAccess.__init__r   c                 C   rh   )Nz <AuthorityInformationAccess({})>r`   r   r6   r/   r/   r0   ri   5  rj   z#AuthorityInformationAccess.__repr__c                 C   rz   r3   )r   r   r{   r   r|   r/   r/   r0   r~   8  r   z!AuthorityInformationAccess.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r   >  r^   z!AuthorityInformationAccess.__ne__c                 C      t t| jS r3   r   r   r   r6   r/   r/   r0   r   A  r;   z#AuthorityInformationAccess.__hash__N)rM   rN   rO   r   AUTHORITY_INFORMATION_ACCESSrD   rk   r   rG   r@   rm   rn   ro   ri   r~   r   r   r/   r/   r/   r0   r   &      
r   c                   @   r   )SubjectInformationAccessr   r   c                 C   r   )Nc                 s   r   r3   r   r   r/   r/   r0   r   J  r   z4SubjectInformationAccess.__init__.<locals>.<genexpr>r   r   r   r/   r/   r0   rG   H  r   z!SubjectInformationAccess.__init__r   c                 C   rh   )Nz<SubjectInformationAccess({})>r   r6   r/   r/   r0   ri   T  rj   z!SubjectInformationAccess.__repr__c                 C   rz   r3   )r   r   r{   r   r|   r/   r/   r0   r~   W  r   zSubjectInformationAccess.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r   ]  r^   zSubjectInformationAccess.__ne__c                 C   r   r3   r   r6   r/   r/   r0   r   `  r;   z!SubjectInformationAccess.__hash__N)rM   rN   rO   r   SUBJECT_INFORMATION_ACCESSrD   rk   r   rG   r@   rm   rn   ro   ri   r~   r   r   r/   r/   r/   r0   r   E  r   r   c                   @   sR   e Zd ZdedefddZdd Zdd Zd	d
 Zdd Z	e
dZe
dZdS )r   access_methodaccess_locationc                 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   rd   r   _access_method_access_location)r7   r   r   r/   r/   r0   rG   e  s   


zAccessDescription.__init__c                 C   r   )NzY<AccessDescription(access_method={0.access_method}, access_location={0.access_location})>r   r6   r/   r/   r0   ri   q     zAccessDescription.__repr__c                 C   &   t |tstS | j|jko| j|jkS r3   )r   r   r{   r   r   r|   r/   r/   r0   r~   w  
   

zAccessDescription.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zAccessDescription.__ne__c                 C      t | j| jfS r3   )r   r   r   r6   r/   r/   r0   r        zAccessDescription.__hash__r   r   N)rM   rN   rO   r   r   rG   ri   r~   r   r   r   r   r   r   r/   r/   r/   r0   r   d  s    
	
r   c                   @   s^   e Zd ZejZdedeje	 fddZ
edZedZdd Zd	d
 Zdd Zdd ZdS )BasicConstraintscapath_lengthc                 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   boolrd   r%   rv   _ca_path_length)r7   r   r   r/   r/   r0   rG     s   

zBasicConstraints.__init__r   r   c                 C   r   )Nz:<BasicConstraints(ca={0.ca}, path_length={0.path_length})>r   r6   r/   r/   r0   ri     r   zBasicConstraints.__repr__c                 C   r   r3   )r   r   r{   r   r   r|   r/   r/   r0   r~        
zBasicConstraints.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zBasicConstraints.__ne__c                 C   r   r3   )r   r   r   r6   r/   r/   r0   r     r   zBasicConstraints.__hash__N)rM   rN   rO   r   BASIC_CONSTRAINTSrD   r   rk   r   rv   rG   r   r   r   r   ri   r~   r   r   r/   r/   r/   r0   r     s    

r   c                   @   sJ   e Zd ZejZdefddZe	dZ
dd Zdd Zd	d
 Zdd ZdS )DeltaCRLIndicatorrr   c                 C   rs   rt   ru   rx   r/   r/   r0   rG     ry   zDeltaCRLIndicator.__init__rw   c                 C   rz   r3   )r   r   r{   rr   r|   r/   r/   r0   r~     r   zDeltaCRLIndicator.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zDeltaCRLIndicator.__ne__c                 C   r   r3   r   r6   r/   r/   r0   r     r^   zDeltaCRLIndicator.__hash__c                 C   r   )Nz.<DeltaCRLIndicator(crl_number={0.crl_number})>r   r6   r/   r/   r0   ri     r^   zDeltaCRLIndicator.__repr__N)rM   rN   rO   r   DELTA_CRL_INDICATORrD   rv   rG   r   r   rr   r~   r   r   ri   r/   r/   r/   r0   r     s    
r   c                   @   r   )CRLDistributionPointsdistribution_pointsDistributionPointc                 C   r   )Nc                 s   r   r3   r   r   r   r/   r/   r0   r     r   z1CRLDistributionPoints.__init__.<locals>.<genexpr>?distribution_points must be a list of DistributionPoint objectsr   r   rd   _distribution_pointsr7   r   r/   r/   r0   rG        
zCRLDistributionPoints.__init__r   c                 C   rh   )Nz<CRLDistributionPoints({})>r`   r   r6   r/   r/   r0   ri     rj   zCRLDistributionPoints.__repr__c                 C   rz   r3   )r   r   r{   r   r|   r/   r/   r0   r~     r   zCRLDistributionPoints.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zCRLDistributionPoints.__ne__c                 C   r   r3   r   r   r   r6   r/   r/   r0   r     r;   zCRLDistributionPoints.__hash__N)rM   rN   rO   r   CRL_DISTRIBUTION_POINTSrD   rk   r   rG   r@   rm   rn   ro   ri   r~   r   r   r/   r/   r/   r0   r         

r   c                   @   r   )FreshestCRLr   r   c                 C   r   )Nc                 s   r   r3   r   r   r/   r/   r0   r     r   z'FreshestCRL.__init__.<locals>.<genexpr>r   r   r   r/   r/   r0   rG     r   zFreshestCRL.__init__r   c                 C   rh   )Nz<FreshestCRL({})>r   r6   r/   r/   r0   ri     rj   zFreshestCRL.__repr__c                 C   rz   r3   )r   r   r{   r   r|   r/   r/   r0   r~     r   zFreshestCRL.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zFreshestCRL.__ne__c                 C   r   r3   r   r6   r/   r/   r0   r     r;   zFreshestCRL.__hash__N)rM   rN   rO   r   FRESHEST_CRLrD   rk   r   rG   r@   rm   rn   ro   ri   r~   r   r   r/   r/   r/   r0   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  fddZ	dd	 Z
d
d Zdd Zdd ZedZedZedZedZdS )r   	full_namerelative_namereasonsReasonFlags
crl_issuerc                 C   s   |r|rt d|rt|}tdd |D std|r&t|ts&td|r9t|}tdd |D s9td|rMt|trItdd |D sMtd	|r]tj|v sYtj	|v r]t d
|ri|si|si|sit d|| _
|| _|| _|| _d S )NzOYou cannot provide both full_name and relative_name, at least one must be None.c                 s   r   r3   r   r   r/   r/   r0   r   (  r   z-DistributionPoint.__init__.<locals>.<genexpr>z/full_name must be a list of GeneralName objectsz1relative_name must be a RelativeDistinguishedNamec                 s   r   r3   r   r   r/   r/   r0   r   5  r   z2crl_issuer must be None or a list of general namesc                 s   r   r3   r   r   r   r/   r/   r0   r   <  r   z0reasons must be None or frozenset of ReasonFlagszLunspecified and remove_from_crl are not valid reasons in a DistributionPointzPYou must supply crl_issuer, full_name, or relative_name when reasons is not None)r%   r   r   rd   r   r   	frozensetr   unspecifiedremove_from_crl
_full_name_relative_name_reasons_crl_issuer)r7   r   r   r   r   r/   r/   r0   rG     sR   



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   r6   r/   r/   r0   ri   T     zDistributionPoint.__repr__c                 C   s>   t |tstS | j|jko| j|jko| j|jko| j|jkS r3   )r   r   r{   r   r   r   r   r|   r/   r/   r0   r~   [  s   



zDistributionPoint.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r   f  r^   zDistributionPoint.__ne__c                 C   sH   | j d urt| j }nd }| jd urt| j}nd }t|| j| j|fS r3   )r   r   r   r   r   r   )r7   fnr   r/   r/   r0   r   i  s   

zDistributionPoint.__hash__r   r   r   r   N)rM   rN   rO   rk   r   r   r   r   	FrozenSetrG   ri   r~   r   r   r   r   r   r   r   r   r/   r/   r/   r0   r     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)rM   rN   rO   r   key_compromiseca_compromiseaffiliation_changedr   cessation_of_operationcertificate_holdprivilege_withdrawnaa_compromiser   r/   r/   r/   r0   r   |  s    r   c                   @   sd   e Zd ZejZdeje deje fddZ	dd Z
dd Zd	d
 Zdd ZedZedZdS )PolicyConstraintsrequire_explicit_policyinhibit_policy_mappingc                 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   rv   rd   r%   _require_explicit_policy_inhibit_policy_mapping)r7   r  r  r/   r/   r0   rG     s$   


zPolicyConstraints.__init__c                 C   r   )Nz{<PolicyConstraints(require_explicit_policy={0.require_explicit_policy}, inhibit_policy_mapping={0.inhibit_policy_mapping})>r   r6   r/   r/   r0   ri     r   zPolicyConstraints.__repr__c                 C   r   r3   )r   r  r{   r  r  r|   r/   r/   r0   r~     r   zPolicyConstraints.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zPolicyConstraints.__ne__c                 C   r   r3   )r   r  r  r6   r/   r/   r0   r     s   
zPolicyConstraints.__hash__r  r  N)rM   rN   rO   r   POLICY_CONSTRAINTSrD   rk   r   rv   rG   ri   r~   r   r   r   r   r  r  r/   r/   r/   r0   r    s"    
	r  c                   @   r   )CertificatePoliciespoliciesPolicyInformationc                 C   r   )Nc                 s   r   r3   )r   r  r   r/   r/   r0   r     r   z/CertificatePolicies.__init__.<locals>.<genexpr>z;Every item in the policies list must be a PolicyInformation)r   r   rd   	_policies)r7   r
  r/   r/   r0   rG     r   zCertificatePolicies.__init__r  c                 C   rh   )Nz<CertificatePolicies({})>)r`   r  r6   r/   r/   r0   ri     rj   zCertificatePolicies.__repr__c                 C   rz   r3   )r   r	  r{   r  r|   r/   r/   r0   r~     r   zCertificatePolicies.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zCertificatePolicies.__ne__c                 C   r   r3   )r   r   r  r6   r/   r/   r0   r     r;   zCertificatePolicies.__hash__N)rM   rN   rO   r   CERTIFICATE_POLICIESrD   rk   r   rG   r@   rm   rn   ro   ri   r~   r   r   r/   r/   r/   r0   r	    r   r	  c                   @   sh   e Zd Zdedejejejedf   fddZ	dd Z
dd	 Zd
d Zdd ZedZedZdS )r  policy_identifierpolicy_qualifiers
UserNoticec                 C   sH   t |ts	td|| _|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 r3   )r   rP   r  r   r/   r/   r0   r     s    
z-PolicyInformation.__init__.<locals>.<genexpr>zMpolicy_qualifiers must be a list of strings and/or UserNotice objects or None)r   r   rd   _policy_identifierr   r   _policy_qualifiers)r7   r  r  r/   r/   r0   rG     s   

zPolicyInformation.__init__c                 C   r   )Nze<PolicyInformation(policy_identifier={0.policy_identifier}, policy_qualifiers={0.policy_qualifiers})>r   r6   r/   r/   r0   ri     r   zPolicyInformation.__repr__c                 C   r   r3   )r   r  r{   r  r  r|   r/   r/   r0   r~     r   zPolicyInformation.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zPolicyInformation.__ne__c                 C   s(   | j d urt| j }nd }t| j|fS r3   )r  r   r   r  )r7   pqr/   r/   r0   r     s   
zPolicyInformation.__hash__r  r  N)rM   rN   rO   r   rk   r   r   UnionrP   rG   ri   r~   r   r   r   r   r  r  r/   r/   r/   r0   r    s    
	
r  c                   @   s^   e Zd Zdejd deje fddZdd Zdd	 Zd
d Z	dd Z
edZedZdS )r  notice_referenceNoticeReferenceexplicit_textc                 C   s&   |rt |tstd|| _|| _d S )Nz2notice_reference must be None or a NoticeReference)r   r  rd   _notice_reference_explicit_text)r7   r  r  r/   r/   r0   rG      s   
zUserNotice.__init__c                 C   r   )NzV<UserNotice(notice_reference={0.notice_reference}, explicit_text={0.explicit_text!r})>r   r6   r/   r/   r0   ri   /  r   zUserNotice.__repr__c                 C   r   r3   )r   r  r{   r  r  r|   r/   r/   r0   r~   5  r   zUserNotice.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r   >  r^   zUserNotice.__ne__c                 C   r   r3   )r   r  r  r6   r/   r/   r0   r   A  r   zUserNotice.__hash__r  r  N)rM   rN   rO   rk   r   rP   rG   ri   r~   r   r   r   r   r  r  r/   r/   r/   r0   r    s    
	
r  c                   @   s^   e Zd Zdeje deje fddZdd Z	dd Z
d	d
 Zdd ZedZedZdS )r  organizationnotice_numbersc                 C   s2   || _ t|}tdd |D std|| _d S )Nc                 s   r   r3   )r   rv   r   r/   r/   r0   r   P  r   z+NoticeReference.__init__.<locals>.<genexpr>z)notice_numbers must be a list of integers)_organizationr   r   rd   _notice_numbers)r7   r  r  r/   r/   r0   rG   I  s
   
zNoticeReference.__init__c                 C   r   )NzU<NoticeReference(organization={0.organization!r}, notice_numbers={0.notice_numbers})>r   r6   r/   r/   r0   ri   U  r   zNoticeReference.__repr__c                 C   r   r3   )r   r  r{   r  r  r|   r/   r/   r0   r~   [  r   zNoticeReference.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r   d  r^   zNoticeReference.__ne__c                 C   s   t | jt| jfS r3   )r   r  r   r  r6   r/   r/   r0   r   g     zNoticeReference.__hash__r  r  N)rM   rN   rO   rk   r   rP   r   rv   rG   ri   r~   r   r   r   r   r  r  r/   r/   r/   r0   r  H  s    
	
r  c                   @   T   e Zd ZejZdeje fddZ	e
d\ZZZdd Zdd Zd	d
 Zdd ZdS )ExtendedKeyUsageusagesc                 C   r   )Nc                 s   r   r3   )r   r   r   r/   r/   r0   r   s  r   z,ExtendedKeyUsage.__init__.<locals>.<genexpr>z9Every item in the usages list must be an ObjectIdentifier)r   r   rd   _usages)r7   r!  r/   r/   r0   rG   q  s   
zExtendedKeyUsage.__init__r"  c                 C   rh   )Nz<ExtendedKeyUsage({})>)r`   r"  r6   r/   r/   r0   ri   |  rj   zExtendedKeyUsage.__repr__c                 C   rz   r3   )r   r   r{   r"  r|   r/   r/   r0   r~     r   zExtendedKeyUsage.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zExtendedKeyUsage.__ne__c                 C   r   r3   )r   r   r"  r6   r/   r/   r0   r     r;   zExtendedKeyUsage.__hash__N)rM   rN   rO   r   EXTENDED_KEY_USAGErD   rk   r   r   rG   r@   rm   rn   ro   ri   r~   r   r   r/   r/   r/   r0   r   n  s    	r   c                   @   2   e Zd ZejZdd Zdd Zdd Zdd Z	d	S )
OCSPNoCheckc                 C      t |tstS dS NT)r   r%  r{   r|   r/   r/   r0   r~        
zOCSPNoCheck.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zOCSPNoCheck.__ne__c                 C      t tS r3   )r   r%  r6   r/   r/   r0   r        zOCSPNoCheck.__hash__c                 C   rU   )Nz<OCSPNoCheck()>r/   r6   r/   r/   r0   ri        zOCSPNoCheck.__repr__N)
rM   rN   rO   r   OCSP_NO_CHECKrD   r~   r   r   ri   r/   r/   r/   r0   r%        r%  c                   @   r$  )
PrecertPoisonc                 C   r&  r'  )r   r.  r{   r|   r/   r/   r0   r~     r(  zPrecertPoison.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zPrecertPoison.__ne__c                 C   r)  r3   )r   r.  r6   r/   r/   r0   r     r*  zPrecertPoison.__hash__c                 C   rU   )Nz<PrecertPoison()>r/   r6   r/   r/   r0   ri     r+  zPrecertPoison.__repr__N)
rM   rN   rO   r   PRECERT_POISONrD   r~   r   r   ri   r/   r/   r/   r0   r.    r-  r.  c                   @   r   )
TLSFeaturefeaturesTLSFeatureTypec                 C   s8   t |}tdd |D rt|dkrtd|| _d S )Nc                 s   r   r3   )r   r2  r   r/   r/   r0   r     r   z&TLSFeature.__init__.<locals>.<genexpr>r   z@features must be a list of elements from the TLSFeatureType enum)r   r   r4   rd   	_features)r7   r1  r/   r/   r0   rG     s   
zTLSFeature.__init__r3  c                 C   r   )Nz$<TLSFeature(features={0._features})>r   r6   r/   r/   r0   ri     r^   zTLSFeature.__repr__c                 C   rz   r3   )r   r0  r{   r3  r|   r/   r/   r0   r~     r   zTLSFeature.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zTLSFeature.__ne__c                 C   r   r3   )r   r   r3  r6   r/   r/   r0   r     r;   zTLSFeature.__hash__N)rM   rN   rO   r   TLS_FEATURErD   rk   r   rG   r@   rm   rn   ro   ri   r~   r   r   r/   r/   r/   r0   r0    s    r0  c                   @   s   e Zd ZdZdZdS )r2        N)rM   rN   rO   status_requeststatus_request_v2r/   r/   r/   r0   r2    s    r2  c                 C   s   i | ]}|j |qS r/   re   r   r/   r/   r0   
<dictcomp>      r:  c                   @   rp   )InhibitAnyPolicy
skip_certsc                 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   rv   rd   r%   _skip_certs)r7   r=  r/   r/   r0   rG     s
   

zInhibitAnyPolicy.__init__c                 C   r   )Nz-<InhibitAnyPolicy(skip_certs={0.skip_certs})>r   r6   r/   r/   r0   ri     r^   zInhibitAnyPolicy.__repr__c                 C   rz   r3   )r   r<  r{   r=  r|   r/   r/   r0   r~     r   zInhibitAnyPolicy.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zInhibitAnyPolicy.__ne__c                 C   r   r3   )r   r=  r6   r/   r/   r0   r     r^   zInhibitAnyPolicy.__hash__r>  N)rM   rN   rO   r   INHIBIT_ANY_POLICYrD   rv   rG   ri   r~   r   r   r   r   r=  r/   r/   r/   r0   r<    s    	r<  c                   @   s   e Zd ZejZdedededededededed	efd
dZe	dZ
e	dZe	dZe	dZe	dZe	dZe	dZedd Zedd Zdd Zdd Zdd Zdd ZdS ) KeyUsagedigital_signaturecontent_commitmentkey_enciphermentdata_enciphermentkey_agreementkey_cert_signcrl_signencipher_onlydecipher_onlyc
           
      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)
r7   rA  rB  rC  rD  rE  rF  rG  rH  rI  r/   r/   r0   rG     s   
zKeyUsage.__init__rJ  rK  rL  rM  rN  rO  rP  c                 C      | j std| jS )Nz7encipher_only is undefined unless key_agreement is true)rE  r%   rQ  r6   r/   r/   r0   rH  '  
   zKeyUsage.encipher_onlyc                 C   rS  )Nz7decipher_only is undefined unless key_agreement is true)rE  r%   rR  r6   r/   r/   r0   rI  0  rT  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})>)rH  rI  r%   r`   )r7   rH  rI  r/   r/   r0   ri   9  s   

zKeyUsage.__repr__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 r3   )r   r@  r{   rA  rB  rC  rD  rE  rF  rG  rQ  rR  r|   r/   r/   r0   r~   N  s&   








zKeyUsage.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r   ^  r^   zKeyUsage.__ne__c              
   C   s,   t | j| j| j| j| j| j| j| j| j	f	S r3   )
r   rA  rB  rC  rD  rE  rF  rG  rQ  rR  r6   r/   r/   r0   r   a  s   zKeyUsage.__hash__N)rM   rN   rO   r   	KEY_USAGErD   r   rG   r   r   rA  rB  rC  rD  rE  rF  rG  propertyrH  rI  ri   r~   r   r   r/   r/   r/   r0   r@     sH    	










r@  c                   @   sx   e Zd ZejZdejeje	  dejeje	  fddZ
dd Zdd Zd	d
 Zdd Zdd ZedZedZdS )NameConstraintspermitted_subtreesexcluded_subtreesc                 C   s   |d urt |}tdd |D std| | |d ur4t |}tdd |D s/td| | |d u r@|d u r@td|| _|| _d S )Nc                 s   r   r3   r   r   r/   r/   r0   r   {  r   z+NameConstraints.__init__.<locals>.<genexpr>z@permitted_subtrees must be a list of GeneralName objects or Nonec                 s   r   r3   r   r   r/   r/   r0   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   rd   _validate_ip_namer%   _permitted_subtrees_excluded_subtrees)r7   rX  rY  r/   r/   r0   rG   t  s(   


zNameConstraints.__init__c                 C   r   r3   )r   rW  r{   rY  rX  r|   r/   r/   r0   r~     r   zNameConstraints.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zNameConstraints.__ne__c                 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 r3   )r   r   re   	ipaddressIPv4NetworkIPv6Network)r   namer/   r/   r0   r     s    

z4NameConstraints._validate_ip_name.<locals>.<genexpr>zGIPAddress name constraints must be an IPv4Network or IPv6Network object)anyrd   )r7   treer/   r/   r0   rZ    s   z!NameConstraints._validate_ip_namec                 C   r   )Nze<NameConstraints(permitted_subtrees={0.permitted_subtrees}, excluded_subtrees={0.excluded_subtrees})>r   r6   r/   r/   r0   ri     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 r3   )rX  r   rY  r   )r7   psesr/   r/   r0   r     s   

zNameConstraints.__hash__r[  r\  N)rM   rN   rO   r   NAME_CONSTRAINTSrD   rk   r   r   r   rG   r~   r   rZ  ri   r   r   r   rX  rY  r/   r/   r/   r0   rW  q  s    
"	
rW  c                   @   s`   e Zd ZdededefddZedZ	edZ
edZd	d
 Zdd Zdd Zdd ZdS )r[   rD   criticalre   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   rd   r   _oid	_critical_value)r7   rD   rf  re   r/   r/   r0   rG     s   


zExtension.__init__rg  rh  ri  c                 C   r   )Nz@<Extension(oid={0.oid}, critical={0.critical}, value={0.value})>r   r6   r/   r/   r0   ri     r   zExtension.__repr__c                 C   r   r3   )r   r[   r{   rD   rf  re   r|   r/   r/   r0   r~     s   


zExtension.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zExtension.__ne__c                 C   s   t | j| j| jfS r3   )r   rD   rf  re   r6   r/   r/   r0   r     r  zExtension.__hash__N)rM   rN   rO   r   r   rT   rG   r   r   rD   rf  re   ri   r~   r   r   r/   r/   r/   r0   r[     s    




r[   c                   @   sb   e Zd Zdeje fddZed\ZZ	Z
deje fddZdd	 Zd
d Zdd Zdd ZdS )GeneralNamesgeneral_namesc                 C   r   )Nc                 s   r   r3   r   r   r/   r/   r0   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   rd   _general_namesr7   rk  r/   r/   r0   rG     r   zGeneralNames.__init__rl  typec                    s0    fdd| D } t krdd |D }t|S )Nc                 3   s    | ]
}t | r|V  qd S r3   )r   r   irn  r/   r0   r     s    z3GeneralNames.get_values_for_type.<locals>.<genexpr>c                 s   s    | ]}|j V  qd S r3   r9  ro  r/   r/   r0   r     s    )r   r   )r7   rn  objsr/   rq  r0   get_values_for_type  s   z GeneralNames.get_values_for_typec                 C   rh   )Nz<GeneralNames({})>r`   rl  r6   r/   r/   r0   ri     rj   zGeneralNames.__repr__c                 C   rz   r3   )r   rj  r{   rl  r|   r/   r/   r0   r~   
  r   zGeneralNames.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zGeneralNames.__ne__c                 C   r   r3   )r   r   rl  r6   r/   r/   r0   r     r;   zGeneralNames.__hash__N)rM   rN   rO   rk   r   r   rG   r@   rm   rn   ro   Typers  ri   r~   r   r   r/   r/   r/   r0   rj    s    
	rj  c                   @   \   e Zd ZejZdeje fddZ	e
d\ZZZdd Zdd Zd	d
 Zdd Zdd ZdS )SubjectAlternativeNamerk  c                 C      t || _d S r3   rj  rl  rm  r/   r/   r0   rG     r;   zSubjectAlternativeName.__init__rl  c                 C      | j |S r3   rl  rs  r7   rn  r/   r/   r0   rs    rj   z*SubjectAlternativeName.get_values_for_typec                 C   rh   )Nz<SubjectAlternativeName({})>rt  r6   r/   r/   r0   ri   "  rj   zSubjectAlternativeName.__repr__c                 C   rz   r3   )r   rw  r{   rl  r|   r/   r/   r0   r~   %  r   zSubjectAlternativeName.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r   +  r^   zSubjectAlternativeName.__ne__c                 C   r   r3   r   rl  r6   r/   r/   r0   r   .  r^   zSubjectAlternativeName.__hash__N)rM   rN   rO   r   SUBJECT_ALTERNATIVE_NAMErD   rk   r   r   rG   r@   rm   rn   ro   rs  ri   r~   r   r   r/   r/   r/   r0   rw        rw  c                   @   rv  )IssuerAlternativeNamerk  c                 C   rx  r3   ry  rm  r/   r/   r0   rG   5  r;   zIssuerAlternativeName.__init__rl  c                 C   rz  r3   r{  r|  r/   r/   r0   rs  :  rj   z)IssuerAlternativeName.get_values_for_typec                 C   rh   )Nz<IssuerAlternativeName({})>rt  r6   r/   r/   r0   ri   =  rj   zIssuerAlternativeName.__repr__c                 C   rz   r3   )r   r  r{   rl  r|   r/   r/   r0   r~   @  r   zIssuerAlternativeName.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r   F  r^   zIssuerAlternativeName.__ne__c                 C   r   r3   r}  r6   r/   r/   r0   r   I  r^   zIssuerAlternativeName.__hash__N)rM   rN   rO   r   ISSUER_ALTERNATIVE_NAMErD   rk   r   r   rG   r@   rm   rn   ro   rs  ri   r~   r   r   r/   r/   r/   r0   r  2  r  r  c                   @   rv  )CertificateIssuerrk  c                 C   rx  r3   ry  rm  r/   r/   r0   rG   P  r;   zCertificateIssuer.__init__rl  c                 C   rz  r3   r{  r|  r/   r/   r0   rs  U  rj   z%CertificateIssuer.get_values_for_typec                 C   rh   )Nz<CertificateIssuer({})>rt  r6   r/   r/   r0   ri   X  rj   zCertificateIssuer.__repr__c                 C   rz   r3   )r   r  r{   rl  r|   r/   r/   r0   r~   [  r   zCertificateIssuer.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r   a  r^   zCertificateIssuer.__ne__c                 C   r   r3   r}  r6   r/   r/   r0   r   d  r^   zCertificateIssuer.__hash__N)rM   rN   rO   r   CERTIFICATE_ISSUERrD   rk   r   r   rG   r@   rm   rn   ro   rs  ri   r~   r   r   r/   r/   r/   r0   r  M  r  r  c                   @   rp   )	CRLReasonreasonc                 C   rs   )Nz*reason must be an element from ReasonFlags)r   r   rd   _reason)r7   r  r/   r/   r0   rG   k  ry   zCRLReason.__init__c                 C   rh   )Nz<CRLReason(reason={})>)r`   r  r6   r/   r/   r0   ri   q  rj   zCRLReason.__repr__c                 C   rz   r3   )r   r  r{   r  r|   r/   r/   r0   r~   t  r   zCRLReason.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r   z  r^   zCRLReason.__ne__c                 C   r   r3   )r   r  r6   r/   r/   r0   r   }  r^   zCRLReason.__hash__r  N)rM   rN   rO   r   
CRL_REASONrD   r   rG   ri   r~   r   r   r   r   r  r/   r/   r/   r0   r  h  s    r  c                   @   sL   e Zd ZejZdejfddZdd Zdd Z	dd	 Z
d
d ZedZdS )InvalidityDateinvalidity_datec                 C   s   t |tjs
td|| _d S )Nz+invalidity_date must be a datetime.datetime)r   datetimerd   _invalidity_date)r7   r  r/   r/   r0   rG     s   
zInvalidityDate.__init__c                 C   rh   )Nz$<InvalidityDate(invalidity_date={})>)r`   r  r6   r/   r/   r0   ri     s   zInvalidityDate.__repr__c                 C   rz   r3   )r   r  r{   r  r|   r/   r/   r0   r~     r   zInvalidityDate.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zInvalidityDate.__ne__c                 C   r   r3   )r   r  r6   r/   r/   r0   r     r^   zInvalidityDate.__hash__r  N)rM   rN   rO   r   INVALIDITY_DATErD   r  rG   ri   r~   r   r   r   r   r  r/   r/   r/   r0   r    s    r  c                   @   r  ))PrecertificateSignedCertificateTimestampssigned_certificate_timestampsc                 C   r   )Nc                 s   r   r3   r   r   r   sctr/   r/   r0   r     
    
zEPrecertificateSignedCertificateTimestamps.__init__.<locals>.<genexpr>YEvery item in the signed_certificate_timestamps list must be a SignedCertificateTimestampr   r   rd   _signed_certificate_timestampsr7   r  r/   r/   r0   rG        
z2PrecertificateSignedCertificateTimestamps.__init__r  c                 C      d t| S )Nz/<PrecertificateSignedCertificateTimestamps({})>r`   r   r6   r/   r/   r0   ri     s   z2PrecertificateSignedCertificateTimestamps.__repr__c                 C   r   r3   r   r   r  r6   r/   r/   r0   r     r;   z2PrecertificateSignedCertificateTimestamps.__hash__c                 C   rz   r3   )r   r  r{   r  r|   r/   r/   r0   r~        
z0PrecertificateSignedCertificateTimestamps.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   z0PrecertificateSignedCertificateTimestamps.__ne__N)rM   rN   rO   r   %PRECERT_SIGNED_CERTIFICATE_TIMESTAMPSrD   rk   r   r   rG   r@   rm   rn   ro   ri   r   r~   r   r/   r/   r/   r0   r    s    

	r  c                   @   r  )SignedCertificateTimestampsr  c                 C   r   )Nc                 s   r   r3   r  r  r/   r/   r0   r     r  z7SignedCertificateTimestamps.__init__.<locals>.<genexpr>r  r  r  r/   r/   r0   rG     r  z$SignedCertificateTimestamps.__init__r  c                 C   r  )Nz!<SignedCertificateTimestamps({})>r  r6   r/   r/   r0   ri     r;   z$SignedCertificateTimestamps.__repr__c                 C   r   r3   r  r6   r/   r/   r0   r     r;   z$SignedCertificateTimestamps.__hash__c                 C   rz   r3   )r   r  r{   r  r|   r/   r/   r0   r~     r  z"SignedCertificateTimestamps.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   z"SignedCertificateTimestamps.__ne__N)rM   rN   rO   r   SIGNED_CERTIFICATE_TIMESTAMPSrD   rk   r   r   rG   r@   rm   rn   ro   ri   r   r~   r   r/   r/   r/   r0   r    s    

	r  c                   @   rp   )	OCSPNoncenoncec                 C   rs   )Nznonce must be bytes)r   r   rd   _nonce)r7   r  r/   r/   r0   rG     ry   zOCSPNonce.__init__c                 C   rz   r3   )r   r  r{   r  r|   r/   r/   r0   r~     r   zOCSPNonce.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zOCSPNonce.__ne__c                 C   r   r3   )r   r  r6   r/   r/   r0   r   
  r^   zOCSPNonce.__hash__c                 C   r   )Nz<OCSPNonce(nonce={0.nonce!r})>r   r6   r/   r/   r0   ri     r^   zOCSPNonce.__repr__r  N)rM   rN   rO   r   NONCErD   r   rG   r~   r   r   ri   r   r   r  r/   r/   r/   r0   r    r   r  c                   @   s   e Zd ZejZdd Zdd Zdd Zdd Z	d	d
 Z
edZedZedZedZedZedZedZdS )IssuingDistributionPointc           	      C   s   |rt |trtdd |D std|r$tj|v s tj|v r$tdt |tr8t |tr8t |tr8t |ts<td||||g}t	dd |D dkrQtd	t
|||||||gs`td
|| _|| _|| _|| _|| _|| _|| _d S )Nc                 s   r   r3   r   r   r/   r/   r0   r   "  r   z4IssuingDistributionPoint.__init__.<locals>.<genexpr>z:only_some_reasons must be None or frozenset of ReasonFlagszTunspecified and remove_from_crl are not valid reasons in an IssuingDistributionPointzuonly_contains_user_certs, only_contains_ca_certs, indirect_crl and only_contains_attribute_certs must all be boolean.c                 S   s   g | ]}|r|qS r/   r/   r   r/   r/   r0   
<listcomp>D  r;  z5IssuingDistributionPoint.__init__.<locals>.<listcomp>   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   rd   r   r   r   r%   r   r4   ra  _only_contains_user_certs_only_contains_ca_certs_indirect_crl_only_contains_attribute_certs_only_some_reasonsr   r   )	r7   r   r   only_contains_user_certsonly_contains_ca_certsonly_some_reasonsindirect_crlonly_contains_attribute_certscrl_constraintsr/   r/   r0   rG     sl   



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   r6   r/   r/   r0   ri   f  s   z!IssuingDistributionPoint.__repr__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 r3   )
r   r  r{   r   r   r  r  r  r  r  r|   r/   r/   r0   r~   r  s"   





zIssuingDistributionPoint.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zIssuingDistributionPoint.__ne__c                 C   s$   t | j| j| j| j| j| j| jfS r3   )r   r   r   r  r  r  r  r  r6   r/   r/   r0   r     s   z!IssuingDistributionPoint.__hash__r   r   r  r  r  r  r  N)rM   rN   rO   r   ISSUING_DISTRIBUTION_POINTrD   rG   ri   r~   r   r   r   r   r   r   r  r  r  r  r  r/   r/   r/   r0   r    s(    P



r  c                   @   sR   e Zd ZdedefddZedZedZ	dd Z
d	d
 Zdd Zdd ZdS )rc   rD   re   c                 C   s"   t |ts	td|| _|| _d S )Nzoid must be an ObjectIdentifier)r   r   rd   rg  ri  )r7   rD   re   r/   r/   r0   rG     s   

zUnrecognizedExtension.__init__rg  ri  c                 C   r   )Nz7<UnrecognizedExtension(oid={0.oid}, value={0.value!r})>r   r6   r/   r/   r0   ri     r   zUnrecognizedExtension.__repr__c                 C   r   r3   )r   rc   r{   rD   re   r|   r/   r/   r0   r~     r   zUnrecognizedExtension.__eq__c                 C   r   r3   r/   r|   r/   r/   r0   r     r^   zUnrecognizedExtension.__ne__c                 C   r   r3   )r   rD   re   r6   r/   r/   r0   r     r   zUnrecognizedExtension.__hash__N)rM   rN   rO   r   r   rG   r   r   rD   re   ri   r~   r   r   r/   r/   r/   r0   rc     s    

rc   )SrV   r  r'   r]  rk   cryptographyr   cryptography.hazmat._derr   r   r   r   cryptography.hazmat._typesr   cryptography.hazmat.primitivesr   r	   ,cryptography.hazmat.primitives.asymmetric.ecr
   -cryptography.hazmat.primitives.asymmetric.rsar   *cryptography.x509.certificate_transparencyr   cryptography.x509.general_namer   r   r   cryptography.x509.namer   cryptography.x509.oidr   r   r   r   r   r1   r@   	ExceptionrB   rS   ABCMetarT   objectrY   rq   r   r   r   r   r   r   r   r   r   r   Enumr   r  r	  r  r  r  r   r%  r.  r0  r2  _TLS_FEATURE_TYPE_TO_ENUMr<  r@  rW  r[   rj  rw  r  r  r  r  r  r  r  r  rc   r/   r/   r/   r0   <module>   sx   (!_&)%%d@7)&"qU+&-+ 