
     h>                        d Z ddlmZmZmZmZ ddl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mZmZmZmZmZmZ  G d d	e          Z G d
 de          Z G d de          Z G d de          Z G d de          Z  G d de          Z! G d de          Z" G d de          Z# G d de          Z$ G d de          Z% G d de          Z& G d de          Z' G d  d!e          Z(dS )"z
ASN.1 type classes for certificate revocation lists (CRL). Exports the
following items:

 - CertificateList()

Other type classes are defined that help compose the types listed above.
    )unicode_literalsdivisionabsolute_importprint_functionN   )SignedDigestAlgorithm)	Boolean
EnumeratedGeneralizedTimeIntegerObjectIdentifierOctetBitStringParsableOctetStringSequence
SequenceOf)AuthorityInfoAccessSyntaxAuthorityKeyIdentifierCRLDistributionPointsDistributionPointNameGeneralNamesNameReasonFlagsTimec                       e Zd ZddddZdS )Versionv1v2v3)r   r      N__name__
__module____qualname___map     J/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/asn1crypto/crl.pyr   r   +   s#         DDDr&   r   c            
       f    e Zd Zdedddfdedddfd	ed
ddfdedddfdedddfdedddfgZdS )IssuingDistributionPointdistribution_pointr   Texplicitoptionalonly_contains_user_certsr   F)implicitdefaultonly_contains_ca_certsr   only_some_reasons   )r/   r-   indirect_crl   only_contains_attribute_certs   N)r!   r"   r#   r   r	   r   _fieldsr%   r&   r'   r)   r)   3   s        	41RV6W6WX	#W1.O.OP	!7u,M,MN	kt+L+LM	qU"C"CD	('e3T3TUGGGr&   r)   c                   "    e Zd ZddddddddZd	S )
TBSCertListExtensionIdissuer_alt_name
crl_numberdelta_crl_indicatorissuing_distribution_pointauthority_key_identifierfreshest_crlauthority_information_access)z	2.5.29.18z	2.5.29.20z	2.5.29.27z	2.5.29.28z	2.5.29.35z	2.5.29.46z1.3.6.1.5.5.7.1.1Nr    r%   r&   r'   r:   r:   >   s/        &!*1/#; DDDr&   r:   c                   B    e Zd ZdefdeddifdefgZdZee	e	e
eeedZdS )	TBSCertListExtensionextn_idcriticalr0   F
extn_valuerD   rF   )r;   r<   r=   r>   r?   r@   rA   N)r!   r"   r#   r:   r	   r   r8   	_oid_pairr   r   r)   r   r   r   
_oid_specsr%   r&   r'   rC   rC   J   s^        	*+	Wy%01	*+G *I'&&>$:-(A JJJr&   rC   c                       e Zd ZeZdS )TBSCertListExtensionsN)r!   r"   r#   rC   _child_specr%   r&   r'   rK   rK   ]   s        &KKKr&   rK   c                   >    e Zd Zddddddddd	d
d
Zed             ZdS )	CRLReasonunspecifiedkey_compromiseca_compromiseaffiliation_changed
supersededcessation_of_operationcertificate_holdremove_from_crlprivilege_withdrawnaa_compromise)
r   r   r   r3   r5   r7         	   
   c                 2    ddddddddd	d
d
| j                  S )a  
        :return:
            A unicode string with revocation description that is suitable to
            show to end-users. Starts with a lower case letter and phrased in
            such a way that it makes sense after the phrase "because of" or
            "due to".
        zan unspecified reasonza compromised keyzthe CA being compromisedzan affiliation changezcertificate supersessionza cessation of operationza certificate holdzremoval from the CRLzprivilege withdrawlzthe AA being compromised)
rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   nativeselfs    r'   human_friendlyzCRLReason.human_friendlyo   s=     317#:4&@ 45#87
 
 + 	r&   N)r!   r"   r#   r$   propertyrb   r%   r&   r'   rN   rN   a   sY         #  D   X  r&   rN   c                       e Zd ZdddddZdS )CRLEntryExtensionId
crl_reasonhold_instruction_codeinvalidity_datecertificate_issuer)z	2.5.29.21z	2.5.29.23z	2.5.29.24z	2.5.29.29Nr    r%   r&   r'   re   re      s&        !,&)	 DDDr&   re   c                   <    e Zd ZdefdeddifdefgZdZee	e
edZdS )	CRLEntryExtensionrD   rE   r0   FrF   rG   )rf   rg   rh   ri   N)r!   r"   r#   re   r	   r   r8   rH   rN   r   r   r   rI   r%   r&   r'   rk   rk      sU        	'(	Wy%01	*+G *I!1**	 JJJr&   rk   c                       e Zd ZeZdS )CRLEntryExtensionsN)r!   r"   r#   rk   rL   r%   r&   r'   rm   rm      s        #KKKr&   rm   c                       e Zd ZdefdefdeddifgZdZdZdZ	dZ
dZdZd Zed	             Zed
             Zed             Zed             Zed             ZdS )RevokedCertificateuser_certificaterevocation_datecrl_entry_extensionsr-   TFNc                    t                      | _        | d         D ]g}|d         j        }d|z  }t          | |          rt	          | ||d         j                   |d         j        r| j                            |           hd| _        dS )v
        Sets common named extensions to private attributes and creates a list
        of critical extensions
        rr   rD   	_%s_valuerF   rE   TNset_critical_extensionsr_   hasattrsetattrparsedadd_processed_extensionsra   	extensionnameattribute_names       r'   _set_extensionsz"RevokedCertificate._set_extensions   s     %(EE!45 	4 	4IY'.D(4/Nt^,, Nni.E.LMMM$+ 4)--d333%)"""r&   c                 F    | j         s|                                  | j        S z
        Returns a set of the names (or OID if not a known extension) of the
        extensions marked as critical

        :return:
            A set of unicode strings
        r}   r   rx   r`   s    r'   critical_extensionsz&RevokedCertificate.critical_extensions   *     ) 	#  """((r&   c                 J    | j         du r|                                  | j        S )z
        This extension indicates the reason that a certificate was revoked.

        :return:
            None or a CRLReason object
        F)r}   r   _crl_reason_valuer`   s    r'   crl_reason_valuez#RevokedCertificate.crl_reason_value   s-     %..  """%%r&   c                 J    | j         du r|                                  | j        S )a=  
        This extension indicates the suspected date/time the private key was
        compromised or the certificate became invalid. This would usually be
        before the revocation date, which is when the CA processed the
        revocation.

        :return:
            None or a GeneralizedTime object
        F)r}   r   _invalidity_date_valuer`   s    r'   invalidity_date_valuez(RevokedCertificate.invalidity_date_value   s-     %..  """**r&   c                 J    | j         du r|                                  | j        S )a  
        This extension indicates the issuer of the certificate in question,
        and is used in indirect CRLs. CRL entries without this extension are
        for certificates issued from the last seen issuer.

        :return:
            None or an x509.GeneralNames object
        F)r}   r   _certificate_issuer_valuer`   s    r'   certificate_issuer_valuez+RevokedCertificate.certificate_issuer_value   s-     %..  """--r&   c                     | j         du r1d| _         | j        r#| j        D ]}|j        dk    r|j        | _          n| j         S )zi
        :return:
            None, or an asn1crypto.x509.Name object for the issuer of the cert
        FNdirectory_name)_issuer_namer   r   chosen)ra   general_names     r'   issuer_namezRevokedCertificate.issuer_name   sf     %% $D, $($A  L#(,<<<,8,?) =   r&   )r!   r"   r#   r   r   rm   r8   r}   rx   r   r   r   r   r   rc   r   r   r   r   r   r%   r&   r'   ro   ro      s        	W%	D!	!3j$5GHG "! $L* * *$ ) ) X) 
& 
& X
& + + X+ . . X. ! ! X! ! !r&   ro   c                       e Zd ZeZdS )RevokedCertificatesN)r!   r"   r#   ro   rL   r%   r&   r'   r   r     s        $KKKr&   r   c                   V    e Zd Zdeddifdefdefdefdeddifdeddifd	ed
ddfgZ	dS )TbsCertListversionr-   T	signatureissuerthis_updatenext_updaterevoked_certificatescrl_extensionsr   r+   N)
r!   r"   r#   r   r   r   r   r   rK   r8   r%   r&   r'   r   r     so        	Gj$/0	+,	4		z401	!4z46HI	0qd2S2STGGGr&   r   c                      e Zd ZdefdefdefgZdZdZdZ	dZ
dZdZdZdZdZdZdZdZdZ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             Zed             Zed             Zed             Z ed             Z!ed             Z"ed             Z#ed             Z$dS )CertificateListtbs_cert_listsignature_algorithmr   FNc                 &   t                      | _        | d         d         D ]g}|d         j        }d|z  }t          | |          rt	          | ||d         j                   |d         j        r| j                            |           hd| _        dS )	rt   r   r   rD   ru   rF   rE   TNrv   r~   s       r'   r   zCertificateList._set_extensions4  s     %(EE!o./?@ 	4 	4IY'.D(4/Nt^,, Nni.E.LMMM$+ 4)--d333%)"""r&   c                 F    | j         s|                                  | j        S r   r   r`   s    r'   r   z#CertificateList.critical_extensionsF  r   r&   c                 J    | j         du r|                                  | j        S )z
        This extension allows associating one or more alternative names with
        the issuer of the CRL.

        :return:
            None or an x509.GeneralNames object
        F)r}   r   _issuer_alt_name_valuer`   s    r'   issuer_alt_name_valuez%CertificateList.issuer_alt_name_valueT  s-     %..  """**r&   c                 J    | j         du r|                                  | j        S )z
        This extension adds a monotonically increasing number to the CRL and is
        used to distinguish different versions of the CRL.

        :return:
            None or an Integer object
        F)r}   r   _crl_number_valuer`   s    r'   crl_number_valuez CertificateList.crl_number_valueb  s-     %..  """%%r&   c                 J    | j         du r|                                  | j        S )z
        This extension indicates a CRL is a delta CRL, and contains the CRL
        number of the base CRL that it is a delta from.

        :return:
            None or an Integer object
        F)r}   r   _delta_crl_indicator_valuer`   s    r'   delta_crl_indicator_valuez)CertificateList.delta_crl_indicator_valuep  s-     %..  """..r&   c                 J    | j         du r|                                  | j        S )z
        This extension includes information about what types of revocations
        and certificates are part of the CRL.

        :return:
            None or an IssuingDistributionPoint object
        F)r}   r   !_issuing_distribution_point_valuer`   s    r'    issuing_distribution_point_valuez0CertificateList.issuing_distribution_point_value~  s-     %..  """55r&   c                 J    | j         du r|                                  | j        S )z
        This extension helps in identifying the public key with which to
        validate the authenticity of the CRL.

        :return:
            None or an AuthorityKeyIdentifier object
        F)r}   r   _authority_key_identifier_valuer`   s    r'   authority_key_identifier_valuez.CertificateList.authority_key_identifier_value  s-     %..  """33r&   c                 J    | j         du r|                                  | j        S )z
        This extension is used in complete CRLs to indicate where a delta CRL
        may be located.

        :return:
            None or a CRLDistributionPoints object
        F)r}   r   _freshest_crl_valuer`   s    r'   freshest_crl_valuez"CertificateList.freshest_crl_value  s-     %..  """''r&   c                 J    | j         du r|                                  | j        S )z
        This extension is used to provide a URL with which to download the
        certificate used to sign this CRL.

        :return:
            None or an AuthorityInfoAccessSyntax object
        F)r}   r   #_authority_information_access_valuer`   s    r'   "authority_information_access_valuez2CertificateList.authority_information_access_value  s-     %..  """77r&   c                     | d         d         S )z_
        :return:
            An asn1crypto.x509.Name object for the issuer of the CRL
        r   r   r%   r`   s    r'   r   zCertificateList.issuer  s     O$X..r&   c                 8    | j         sdS | j         d         j        S )z
        :return:
            None or a byte string of the key_identifier from the authority key
            identifier extension
        Nkey_identifier)r   r_   r`   s    r'   r?   z(CertificateList.authority_key_identifier  s&     2 	423CDKKr&   c                    | j         ~g | _         | j        rp| j        D ]h}|d         j        dk    rU|d         }|j        dk    r'|j        }|                                dd         dk    r| j                             |           i| j         S )	z
        :return:
            A list of unicode strings that are URLs that should contain either
            an individual DER-encoded X.509 certificate, or a DER-encoded CMS
            message containing multiple certificates
        Naccess_method
ca_issuersaccess_locationuniform_resource_identifierr      zhttp://)_issuer_cert_urlsr   r_   r   lowerappend)ra   entrylocationurls       r'   issuer_cert_urlsz CertificateList.issuer_cert_urls  s     !)%'D"6 ?!D ? ?E_-4DD#():#;#=,III$&o99;;qs+y88 299#>>>%%r&   c                     | j         [g | _         | j        M| j        D ]E}|d         }|j        dk    r|j        D ]'}|j        dk    r| j                             |           (F| j         S )z
        Returns delta CRL URLs - only applies to complete CRLs

        :return:
            A list of zero or more DistributionPoint objects
        Nr*   name_relative_to_crl_issuerr   )_delta_crl_distribution_pointsr   r   r   r   )ra   r*   distribution_point_namer   s       r'   delta_crl_distribution_pointsz-CertificateList.delta_crl_distribution_points  s     .624D/&2*.*A [ [&.@AU.V+.37TTT (?(F [ [',0MMM ?FFGYZZZ[ 22r&   c                     | d         j         S )zE
        :return:
            A byte string of the signature
        r   r^   r`   s    r'   r   zCertificateList.signature  s     K ''r&   c                     | j         =t          j        |                                                                           | _         | j         S )zf
        :return:
            The SHA1 hash of the DER-encoded bytes of this certificate list
        )_sha1hashlibsha1dumpdigestr`   s    r'   r   zCertificateList.sha1  s9     : diikk2299;;DJzr&   c                     | j         =t          j        |                                                                           | _         | j         S )zi
        :return:
            The SHA-256 hash of the DER-encoded bytes of this certificate list
        )_sha256r   sha256r   r   r`   s    r'   r   zCertificateList.sha256  s9     <">$))++66==??DL|r&   )%r!   r"   r#   r   r   r   r8   r}   rx   r   r   r   r   r   r   r   r   r   r   r   r   rc   r   r   r   r   r   r   r   r   r   r?   r   r   r   r   r   r%   r&   r'   r   r     s)       	+&	 56	n%G "!!%(,%&*#*.'%)"EG* * *$ ) ) X) + + X+ & & X& / / X/ 6 6 X6 4 4 X4 ( ( X( 8 8 X8 / / X/ 
L 
L X
L & & X&* 3 3 X30 ( ( X(   X   X  r&   r   ))__doc__
__future__r   r   r   r   r   algosr   corer	   r
   r   r   r   r   r   r   r   x509r   r   r   r   r   r   r   r   r   r)   r:   rC   rK   rN   re   rk   rm   ro   r   r   r   r%   r&   r'   <module>r      se    S R R R R R R R R R R R  ( ( ( ( ( (
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	    g       x   	 	 	 	 	- 	 	 	    8   &' ' ' ' 'J ' ' '# # # # #
 # # #L    *           $ $ $ $ $ $ $ $h! h! h! h! h! h! h! h!V% % % % %* % % %	 	 	 	 	( 	 	 	y y y y yh y y y y yr&   