
l]]c           @` s  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 d e f d	     YZ d
 e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ  d e f d     YZ! d e f d     YZ" d e f d     YZ# d e f d     YZ$ d e f d     YZ% d e f d     YZ& d e f d     YZ' d  e f d!     YZ( d S("   u   
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.
i    (   t   unicode_literalst   divisiont   absolute_importt   print_functionNi   (   t   SignedDigestAlgorithm(	   t   Booleant
   Enumeratedt   GeneralizedTimet   Integert   ObjectIdentifiert   OctetBitStringt   ParsableOctetStringt   Sequencet
   SequenceOf(   t   AuthorityInfoAccessSyntaxt   AuthorityKeyIdentifiert   CRLDistributionPointst   DistributionPointNamet   GeneralNamest   Namet   ReasonFlagst   Timet   Versionc           B` s#   e  Z i d  d 6d d 6d d 6Z RS(   u   v1i    u   v2i   u   v3i   (   t   __name__t
   __module__t   _map(    (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyR   +   s   t   IssuingDistributionPointc        
   B` s   e  Z d  e i d d 6e d 6f d e i d d 6e d 6f d e i d	 d 6e d 6f d
 e i d d 6e d 6f d e i d d 6e d 6f d e i d d 6e d 6f g Z RS(   u   distribution_pointi    u   explicitu   optionalu   only_contains_user_certsi   u   implicitu   defaultu   only_contains_ca_certsi   u   only_some_reasonsi   u   indirect_crli   u   only_contains_attribute_certsi   (   R   R   R   t   TrueR   t   FalseR   t   _fields(    (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyR   3   s   t   TBSCertListExtensionIdc           B` s?   e  Z i d  d 6d d 6d d 6d d 6d d	 6d
 d 6d d 6Z RS(   u   issuer_alt_nameu	   2.5.29.18u
   crl_numberu	   2.5.29.20u   delta_crl_indicatoru	   2.5.29.27u   issuing_distribution_pointu	   2.5.29.28u   authority_key_identifieru	   2.5.29.35u   freshest_crlu	   2.5.29.46u   authority_information_accessu   1.3.6.1.5.5.7.1.1(   R   R   R   (    (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyR   >   s   t   TBSCertListExtensionc           B` sp   e  Z d  e f d e i e d 6f d e f g Z d Z i e d 6e	 d 6e	 d 6e
 d 6e d 6e d	 6e d
 6Z RS(   u   extn_idu   criticalu   defaultu
   extn_valueu   issuer_alt_nameu
   crl_numberu   delta_crl_indicatoru   issuing_distribution_pointu   authority_key_identifieru   freshest_crlu   authority_information_access(   u   extn_idu
   extn_value(   R   R   R   R   R   R   R   t	   _oid_pairR   R   R   R   R   R   t
   _oid_specs(    (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyR   J   s   	t   TBSCertListExtensionsc           B` s   e  Z e Z RS(    (   R   R   R   t   _child_spec(    (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyR"   ]   s   t	   CRLReasonc           B` sc   e  Z i
 d  d 6d d 6d d 6d d 6d d	 6d
 d 6d d 6d d 6d d 6d d 6Z e d    Z RS(   u   unspecifiedi    u   key_compromisei   u   ca_compromisei   u   affiliation_changedi   u
   supersededi   u   cessation_of_operationi   u   certificate_holdi   u   remove_from_crli   u   privilege_withdrawni	   u   aa_compromisei
   c         C` sQ   i
 d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6|  j  S(   u  
        :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".
        u   an unspecified reasonu   unspecifiedu   a compromised keyu   key_compromiseu   the CA being compromisedu   ca_compromiseu   an affiliation changeu   affiliation_changedu   certificate supersessionu
   supersededu   a cessation of operationu   cessation_of_operationu   a certificate holdu   certificate_holdu   removal from the CRLu   remove_from_crlu   privilege withdrawlu   privilege_withdrawnu   the AA being compromisedu   aa_compromise(   t   native(   t   self(    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   human_friendlyo   s    
(   R   R   R   t   propertyR'   (    (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyR$   a   s   
t   CRLEntryExtensionIdc           B` s*   e  Z i d  d 6d d 6d d 6d d 6Z RS(   u
   crl_reasonu	   2.5.29.21u   hold_instruction_codeu	   2.5.29.23u   invalidity_dateu	   2.5.29.24u   certificate_issueru	   2.5.29.29(   R   R   R   (    (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyR)      s
   t   CRLEntryExtensionc           B` s[   e  Z d  e f d e i e d 6f d e f g Z d Z i e d 6e	 d 6e
 d 6e d 6Z RS(	   u   extn_idu   criticalu   defaultu
   extn_valueu
   crl_reasonu   hold_instruction_codeu   invalidity_dateu   certificate_issuer(   u   extn_idu
   extn_value(   R   R   R)   R   R   R   R   R    R$   R	   R   R   R!   (    (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyR*      s   	t   CRLEntryExtensionsc           B` s   e  Z e Z RS(    (   R   R   R*   R#   (    (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyR+      s   t   RevokedCertificatec           B` s   e  Z d  e f d e f d e i e d 6f g Z e Z d
 Z
 d
 Z d
 Z d
 Z e Z d   Z e d    Z e d    Z e d    Z e d    Z e d	    Z RS(   u   user_certificateu   revocation_dateu   crl_entry_extensionsu   optionalc         C` s   t    |  _ xr |  d D]f } | d j } d | } t |  |  r] t |  | | d j  n  | d j r |  j j |  q q Wt |  _ d S(   uv   
        Sets common named extensions to private attributes and creates a list
        of critical extensions
        u   crl_entry_extensionsu   extn_idu	   _%s_valueu
   extn_valueu   criticalN(	   t   sett   _critical_extensionsR%   t   hasattrt   setattrt   parsedt   addR   t   _processed_extensions(   R&   t	   extensiont   namet   attribute_name(    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   _set_extensions   s    
c         C` s   |  j  s |  j   n  |  j S(   u   
        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
        (   R3   R7   R.   (   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   critical_extensions   s    
	c         C` s#   |  j  t k r |  j   n  |  j S(   u   
        This extension indicates the reason that a certificate was revoked.

        :return:
            None or a CRLReason object
        (   R3   R   R7   t   _crl_reason_value(   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   crl_reason_value   s    	c         C` s#   |  j  t k r |  j   n  |  j S(   u=  
        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
        (   R3   R   R7   t   _invalidity_date_value(   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   invalidity_date_value   s    c         C` s#   |  j  t k r |  j   n  |  j S(   u  
        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
        (   R3   R   R7   t   _certificate_issuer_value(   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   certificate_issuer_value   s    c         C` sa   |  j  t k rZ d |  _  |  j rZ x3 |  j D]% } | j d k r+ | j |  _  Pq+ q+ WqZ n  |  j  S(   ui   
        :return:
            None, or an asn1crypto.x509.Name object for the issuer of the cert
        u   directory_nameN(   t   _issuer_nameR   t   NoneR>   R5   t   chosen(   R&   t   general_name(    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   issuer_name   s    		N(   R   R   R   R   R+   R   R   R   R3   R@   R.   R9   R;   R=   R?   R7   R(   R8   R:   R<   R>   RC   (    (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyR,      s   			t   RevokedCertificatesc           B` s   e  Z e Z RS(    (   R   R   R,   R#   (    (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyRD     s   t   TbsCertListc           B` s|   e  Z d  e i e d 6f d e f d e f d e f d e i e d 6f d e i e d 6f d e i d d	 6e d 6f g Z	 RS(
   u   versionu   optionalu	   signatureu   issueru   this_updateu   next_updateu   revoked_certificatesu   crl_extensionsi    u   explicit(
   R   R   R   R   R   R   R   RD   R"   R   (    (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyRE     s   			t   CertificateListc           B` sa  e  Z d  e f d e f d e f g Z 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 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% RS(   u   tbs_cert_listu   signature_algorithmu	   signaturec         C` s   t    |  _ xv |  d d D]f } | d j } d | } t |  |  ra t |  | | d j  n  | d j r |  j j |  q q Wt |  _ d S(   uv   
        Sets common named extensions to private attributes and creates a list
        of critical extensions
        u   tbs_cert_listu   crl_extensionsu   extn_idu	   _%s_valueu
   extn_valueu   criticalN(	   R-   R.   R%   R/   R0   R1   R2   R   R3   (   R&   R4   R5   R6   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyR7   4  s    
c         C` s   |  j  s |  j   n  |  j S(   u   
        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
        (   R3   R7   R.   (   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyR8   F  s    
	c         C` s#   |  j  t k r |  j   n  |  j S(   u   
        This extension allows associating one or more alternative names with
        the issuer of the CRL.

        :return:
            None or an x509.GeneralNames object
        (   R3   R   R7   t   _issuer_alt_name_value(   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   issuer_alt_name_valueT  s    
c         C` s#   |  j  t k r |  j   n  |  j S(   u   
        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
        (   R3   R   R7   t   _crl_number_value(   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   crl_number_valueb  s    
c         C` s#   |  j  t k r |  j   n  |  j S(   u   
        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
        (   R3   R   R7   t   _delta_crl_indicator_value(   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   delta_crl_indicator_valuep  s    
c         C` s#   |  j  t k r |  j   n  |  j S(   u   
        This extension includes information about what types of revocations
        and certificates are part of the CRL.

        :return:
            None or an IssuingDistributionPoint object
        (   R3   R   R7   t!   _issuing_distribution_point_value(   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt    issuing_distribution_point_value~  s    
c         C` s#   |  j  t k r |  j   n  |  j S(   u   
        This extension helps in identifying the public key with which to
        validate the authenticity of the CRL.

        :return:
            None or an AuthorityKeyIdentifier object
        (   R3   R   R7   t   _authority_key_identifier_value(   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   authority_key_identifier_value  s    
c         C` s#   |  j  t k r |  j   n  |  j S(   u   
        This extension is used in complete CRLs to indicate where a delta CRL
        may be located.

        :return:
            None or a CRLDistributionPoints object
        (   R3   R   R7   t   _freshest_crl_value(   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   freshest_crl_value  s    
c         C` s#   |  j  t k r |  j   n  |  j S(   u   
        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
        (   R3   R   R7   t#   _authority_information_access_value(   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt"   authority_information_access_value  s    
c         C` s   |  d d S(   u_   
        :return:
            An asn1crypto.x509.Name object for the issuer of the CRL
        u   tbs_cert_listu   issuer(    (   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   issuer  s    c         C` s   |  j  s d S|  j  d j S(   u   
        :return:
            None or a byte string of the key_identifier from the authority key
            identifier extension
        u   key_identifierN(   RP   R@   R%   (   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   authority_key_identifier  s    	c         C` s   |  j  d k r g  |  _  |  j r x~ |  j D]p } | d j d k r+ | d } | j d k rc q+ n  | j } | j   d d !d k r |  j  j |  q q+ q+ Wq n  |  j  S(	   u   
        :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
        u   access_methodu
   ca_issuersu   access_locationu   uniform_resource_identifieri    i   u   http://N(   t   _issuer_cert_urlsR@   RT   R%   R5   t   lowert   append(   R&   t   entryt   locationt   url(    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   issuer_cert_urls  s    			
	 c         C` s   |  j  d k r g  |  _  |  j d k	 r xi |  j D][ } | d } | j d k rV q1 n  x3 | j D]( } | j d k r` |  j  j |  q` q` Wq1 Wq n  |  j  S(   u   
        Returns delta CRL URLs - only applies to complete CRLs

        :return:
            A list of zero or more DistributionPoint objects
        u   distribution_pointu   name_relative_to_crl_issueru   uniform_resource_identifierN(   t   _delta_crl_distribution_pointsR@   RR   R5   RA   RY   (   R&   t   distribution_pointt   distribution_point_nameRB   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   delta_crl_distribution_points  s    		
!c         C` s   |  d j  S(   uE   
        :return:
            A byte string of the signature
        u	   signature(   R%   (   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt	   signature  s    c         C` s7   |  j  d k r0 t j |  j    j   |  _  n  |  j  S(   uf   
        :return:
            The SHA1 hash of the DER-encoded bytes of this certificate list
        N(   t   _sha1R@   t   hashlibt   sha1t   dumpt   digest(   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyRe     s    !c         C` s7   |  j  d k r0 t j |  j    j   |  _  n  |  j  S(   ui   
        :return:
            The SHA-256 hash of the DER-encoded bytes of this certificate list
        N(   t   _sha256R@   Rd   t   sha256Rf   Rg   (   R&   (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyRi     s    !N(&   R   R   RE   R   R
   R   R   R3   R@   R.   RG   RI   RK   RM   RO   RQ   RS   RW   R^   Rc   Rh   R7   R(   R8   RH   RJ   RL   RN   RP   RR   RT   RU   RV   R]   Ra   Rb   Re   Ri   (    (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyRF     s@   					()   t   __doc__t
   __future__R    R   R   R   Rd   t   algosR   t   coreR   R   R   R   R	   R
   R   R   R   t   x509R   R   R   R   R   R   R   R   R   R   R   R   R"   R$   R)   R*   R+   R,   RD   RE   RF   (    (    (    s-   lib/python2.7/site-packages/asn1crypto/crl.pyt   <module>
   s$   "@:&	k