ó
l]›]c           @` sñ  d  Z  d d l m Z m Z m Z m Z d d l Z d d l Z d d l m	 Z	 m
 Z
 d d l m Z m Z d d l 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 m Z m Z m Z m  Z  m! Z! m" Z" m# Z# d d	 l$ 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 f  d „  ƒ  YZ- d e e- f d „  ƒ  YZ. d e e- f d „  ƒ  YZ/ d e f d „  ƒ  YZ0 d e f d „  ƒ  YZ1 d  e f d! „  ƒ  YZ2 d" e! f d# „  ƒ  YZ3 d$ e! f d% „  ƒ  YZ4 d& e! f d' „  ƒ  YZ5 d( e! f d) „  ƒ  YZ6 d* e! f d+ „  ƒ  YZ7 d, e f d- „  ƒ  YZ8 d. e f d/ „  ƒ  YZ9 d0 e f d1 „  ƒ  YZ: d2 e! f d3 „  ƒ  YZ; d4 e! f d5 „  ƒ  YZ< d6 e! f d7 „  ƒ  YZ= d8 e# f d9 „  ƒ  YZ> d: e f d; „  ƒ  YZ? d< e e! f d= „  ƒ  YZ@ d> e! f d? „  ƒ  YZA d@ e! f dA „  ƒ  YZB dB e! f dC „  ƒ  YZC dD e! f dE „  ƒ  YZD dF e f dG „  ƒ  YZE dH e e! f dI „  ƒ  YZF dJ e! f dK „  ƒ  YZG d S(L   u'  
ASN.1 type classes for public and private keys. Exports the following items:

 - DSAPrivateKey()
 - ECPrivateKey()
 - EncryptedPrivateKeyInfo()
 - PrivateKeyInfo()
 - PublicKeyInfo()
 - RSAPrivateKey()
 - RSAPublicKey()

Other type classes are defined that help compose the types listed above.
i    (   t   unicode_literalst   divisiont   absolute_importt   print_functionNi   (   t   unwrapt   APIException(   t	   type_namet   byte_cls(   t   _ForceNullParameterst   DigestAlgorithmt   EncryptionAlgorithmt   RSAESOAEPParamst   RSASSAPSSParams(   t   Anyt	   Asn1Valuet	   BitStringt   Choicet   Integert   IntegerOctetStringt   Nullt   ObjectIdentifiert   OctetBitStringt   OctetStringt   ParsableOctetStringt   ParsableOctetBitStringt   Sequencet
   SequenceOft   SetOf(   t   int_from_bytest   int_to_bytest   OtherPrimeInfoc           B` s/   e  Z d  Z d e f d e f d e f g Z RS(   u=   
    Source: https://tools.ietf.org/html/rfc3447#page-46
    u   primeu   exponentu   coefficient(   t   __name__t
   __module__t   __doc__R   t   _fields(    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR   -   s   		t   OtherPrimeInfosc           B` s   e  Z d  Z e Z RS(   u=   
    Source: https://tools.ietf.org/html/rfc3447#page-46
    (   R   R    R!   R   t   _child_spec(    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR#   9   s   t   RSAPrivateKeyVersionc           B` s"   e  Z d  Z i d d 6d d 6Z RS(   uX   
    Original Name: Version
    Source: https://tools.ietf.org/html/rfc3447#page-45
    u	   two-primei    u   multii   (   R   R    R!   t   _map(    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR%   A   s   t   RSAPrivateKeyc           B` sx   e  Z d  Z d e f d e f d e f d e f d e f d e f d e f d e f d	 e f d
 e i e d 6f g
 Z RS(   u=   
    Source: https://tools.ietf.org/html/rfc3447#page-45
    u   versionu   modulusu   public_exponentu   private_exponentu   prime1u   prime2u	   exponent1u	   exponent2u   coefficientu   other_prime_infosu   optional(   R   R    R!   R%   R   R#   t   TrueR"   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR'   M   s   									t   RSAPublicKeyc           B` s&   e  Z d  Z d e f d e f g Z RS(   u=   
    Source: https://tools.ietf.org/html/rfc3447#page-44
    u   modulusu   public_exponent(   R   R    R!   R   R"   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR)   `   s   	t   DSAPrivateKeyc           B` sJ   e  Z d  Z d e f d e f d e f d e f d e f d e f g Z RS(   u&  
    The ASN.1 structure that OpenSSL uses to store a DSA private key that is
    not part of a PKCS#8 structure. Reversed engineered from english-language
    description on linked OpenSSL documentation page.

    Original Name: None
    Source: https://www.openssl.org/docs/apps/dsa.html
    u   versionu   pu   qu   gu
   public_keyu   private_key(   R   R    R!   R   R"   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR*   k   s   					t   _ECPointc           B` s&   e  Z d  Z e d „  ƒ Z d „  Z RS(   u
  
    In both PublicKeyInfo and PrivateKeyInfo, the EC public key is a byte
    string that is encoded as a bit string. This class adds convenience
    methods for converting to and from the byte string to a pair of integers
    that are the X and Y coordinates.
    c         C` s•   t  t j t j | d ƒ d ƒ ƒ } t  t j t j | d ƒ d ƒ ƒ } t | | ƒ } d } | t | d | ƒ7} | t | d | ƒ7} |  | ƒ S(   u  
        Creates an ECPoint object from the X and Y integer coordinates of the
        point

        :param x:
            The X coordinate, as an integer

        :param y:
            The Y coordinate, as an integer

        :return:
            An ECPoint object
        i   g       @s   t   width(   t   intt   matht   ceilt   logt   maxR   (   t   clst   xt   yt   x_bytest   y_bytest	   num_bytest   byte_string(    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyt   from_coords‡   s    %%c         C` s¬   |  j  } | d d !} | d k ri | d } t | ƒ d } t | d | !ƒ } t | | ƒ } | | f S| t d d g ƒ k r– t t d ƒ ƒ ‚ n  t t d ƒ ƒ ‚ d	 S(
   u±   
        Returns the X and Y coordinates for this EC point, as native Python
        integers

        :return:
            A 2-element tuple containing integers (X, Y)
        i    i   s   i   s   s   uQ   
                Invalid EC public key - first byte is incorrect
                u|   
            Compressed representations of EC public keys are not supported due
            to patent US6252960
            N(   t   nativet   lenR   t   sett
   ValueErrorR   (   t   selft   datat
   first_bytet	   remainingt	   field_lenR3   R4   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyt	   to_coords¢   s    		

(   R   R    R!   t   classmethodR9   RC   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR+      s   t   ECPointc           B` s   e  Z RS(    (   R   R    (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRE   Å   s   t   ECPointBitStringc           B` s   e  Z RS(    (   R   R    (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRF   Ê   s   t   SpecifiedECDomainVersionc           B` s)   e  Z d  Z i d d 6d d 6d d 6Z RS(   u:   
    Source: http://www.secg.org/sec1-v2.pdf page 104
    u   ecdpVer1i   u   ecdpVer2i   u   ecdpVer3i   (   R   R    R!   R&   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRG   Ï   s
   t	   FieldTypec           B` s"   e  Z d  Z i d d 6d d 6Z RS(   uR   
    Original Name: None
    Source: http://www.secg.org/sec1-v2.pdf page 101
    u   prime_fieldu   1.2.840.10045.1.1u   characteristic_two_fieldu   1.2.840.10045.1.2(   R   R    R!   R&   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRH   Ú   s   t   CharacteristicTwoBasisc           B` s)   e  Z d  Z i d d 6d d 6d d 6Z RS(   uR   
    Original Name: None
    Source: http://www.secg.org/sec1-v2.pdf page 102
    u   gn_basisu   1.2.840.10045.1.2.1.1u   tp_basisu   1.2.840.10045.1.2.1.2u   pp_basisu   1.2.840.10045.1.2.1.3(   R   R    R!   R&   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRI   æ   s
   t   Pentanomialc           B` s/   e  Z d  Z d e f d e f d e f g Z RS(   u:   
    Source: http://www.secg.org/sec1-v2.pdf page 102
    u   k1u   k2u   k3(   R   R    R!   R   R"   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRJ   ó   s   		t   CharacteristicTwoc           B` sP   e  Z d  Z d e f d e f d e f g Z d Z i e d 6e d 6e	 d 6Z
 RS(   u`   
    Original Name: Characteristic-two
    Source: http://www.secg.org/sec1-v2.pdf page 101
    u   mu   basisu
   parametersu   gn_basisu   tp_basisu   pp_basis(   u   basisu
   parameters(   R   R    R!   R   RI   R   R"   t	   _oid_pairR   RJ   t
   _oid_specs(    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRK   ÿ   s   		t   FieldIDc           B` s@   e  Z d  Z d e f d e f g Z d Z i e d 6e d 6Z	 RS(   u:   
    Source: http://www.secg.org/sec1-v2.pdf page 100
    u
   field_typeu
   parametersu   prime_fieldu   characteristic_two_field(   u
   field_typeu
   parameters(
   R   R    R!   RH   R   R"   RL   R   RK   RM   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRN     s   	t   Curvec           B` s9   e  Z d  Z d e f d e f d e i e d 6f g Z RS(   u:   
    Source: http://www.secg.org/sec1-v2.pdf page 104
    u   au   bu   seedu   optional(   R   R    R!   R   R   R(   R"   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRO   $  s   		t   SpecifiedECDomainc           B` sg   e  Z d  Z d e f d e f d e f d e f d e f d e i e d 6f d e	 i e d 6f g Z
 RS(	   u:   
    Source: http://www.secg.org/sec1-v2.pdf page 103
    u   versionu   field_idu   curveu   baseu   orderu   cofactoru   optionalu   hash(   R   R    R!   RG   RN   RO   RE   R   R(   R	   R"   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRP   0  s   					t
   NamedCurvec           B` sg  e  Z d  Z i) d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6d! d" 6d# d$ 6d% d& 6d' d( 6d) d* 6d+ d, 6d- d. 6d/ d0 6d1 d2 6d3 d4 6d5 d6 6d7 d8 6d9 d: 6d; d< 6d= d> 6d? d@ 6dA dB 6dC dD 6dE dF 6dG dH 6dI dJ 6dK dL 6dM dN 6dO dP 6dQ dR 6Z i) dS d 6dS d 6dS d 6dS d 6dT d
 6dT d 6dT d 6dT d 6dT d 6dU d 6dV d 6dV d 6dV d 6dV d 6dV d 6dW d  6dX d" 6dY d$ 6dY d& 6dZ d( 6dT d* 6dT d, 6dV d. 6dV d0 6dV d2 6dS d4 6d[ d6 6dS d8 6dT d: 6d\ d< 6d] d> 6d[ d@ 6d] dB 6d^ dD 6d^ dF 6d_ dH 6d` dJ 6d` dL 6da dN 6db dP 6db dR 6Z e dc „  ƒ Z RS(d   u§   
    Various named curves

    Original Name: None
    Source: https://tools.ietf.org/html/rfc3279#page-23,
            https://tools.ietf.org/html/rfc5480#page-5
    u
   c2pnb163v1u   1.2.840.10045.3.0.1u
   c2pnb163v2u   1.2.840.10045.3.0.2u
   c2pnb163v3u   1.2.840.10045.3.0.3u
   c2pnb176w1u   1.2.840.10045.3.0.4u
   c2tnb191v1u   1.2.840.10045.3.0.5u
   c2tnb191v2u   1.2.840.10045.3.0.6u
   c2tnb191v3u   1.2.840.10045.3.0.7u
   c2onb191v4u   1.2.840.10045.3.0.8u
   c2onb191v5u   1.2.840.10045.3.0.9u
   c2pnb208w1u   1.2.840.10045.3.0.10u
   c2tnb239v1u   1.2.840.10045.3.0.11u
   c2tnb239v2u   1.2.840.10045.3.0.12u
   c2tnb239v3u   1.2.840.10045.3.0.13u
   c2onb239v4u   1.2.840.10045.3.0.14u
   c2onb239v5u   1.2.840.10045.3.0.15u
   c2pnb272w1u   1.2.840.10045.3.0.16u
   c2pnb304w1u   1.2.840.10045.3.0.17u
   c2tnb359v1u   1.2.840.10045.3.0.18u
   c2pnb368w1u   1.2.840.10045.3.0.19u
   c2tnb431r1u   1.2.840.10045.3.0.20u
   prime192v2u   1.2.840.10045.3.1.2u
   prime192v3u   1.2.840.10045.3.1.3u
   prime239v1u   1.2.840.10045.3.1.4u
   prime239v2u   1.2.840.10045.3.1.5u
   prime239v3u   1.2.840.10045.3.1.6u	   sect163k1u   1.3.132.0.1u	   secp256k1u   1.3.132.0.10u	   sect163r2u   1.3.132.0.15u	   secp192r1u   1.2.840.10045.3.1.1u	   secp224r1u   1.3.132.0.33u	   sect233k1u   1.3.132.0.26u	   secp256r1u   1.2.840.10045.3.1.7u	   sect233r1u   1.3.132.0.27u	   sect283k1u   1.3.132.0.16u	   sect283r1u   1.3.132.0.17u	   secp384r1u   1.3.132.0.34u	   sect409k1u   1.3.132.0.36u	   sect409r1u   1.3.132.0.37u	   secp521r1u   1.3.132.0.35u	   sect571k1u   1.3.132.0.38u	   sect571r1u   1.3.132.0.39i   i   i   i   i!   i%   i-   i5   i    i   i   i$   i0   i3   iB   iH   c         C` s=   | |  j  | <|  j d k	 r, | |  j | <n  | |  j | <d S(   u€  
        Registers a new named elliptic curve that is not included in the
        default list of named curves

        :param name:
            A unicode string of the curve name

        :param oid:
            A unicode string of the dotted format OID

        :param key_size:
            An integer of the number of bytes the private key should be
            encoded to
        N(   R&   t   _reverse_mapt   Nonet
   _key_sizes(   R2   t   namet   oidt   key_size(    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyt   register¨  s    (   R   R    R!   R&   RT   RD   RX   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRQ   @  s¬   

t   ECDomainParametersc           B` s>   e  Z d  Z d e f d e f d e f g Z e d „  ƒ Z RS(   u:   
    Source: http://www.secg.org/sec1-v2.pdf page 102
    u	   specifiedu   namedu   implicit_cac         C` s¤   |  j  d k r$ t t d ƒ ƒ ‚ n  |  j  d k r` |  j d j } t j t j | d ƒ d ƒ S|  j j } | t	 j
 k r™ t t d t | ƒ ƒ ƒ ‚ n  t	 j
 | S(   Nu   implicit_cau   
                Unable to calculate key_size from ECDomainParameters
                that are implicitly defined by the CA key
                u	   specifiedu   orderg       @g       @u¬   
                The asn1crypto.keys.NamedCurve %s does not have a registered key length,
                please call asn1crypto.keys.NamedCurve.register()
                (   RU   R=   R   t   chosenR:   R.   R/   R0   t   dottedRQ   RT   t   repr(   R>   t   orderRV   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRW   Ê  s    (	   R   R    R!   RP   RQ   R   t   _alternativest   propertyRW   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRY   ¿  s
   		t   ECPrivateKeyVersionc           B` s   e  Z d  Z i d d 6Z RS(   uR   
    Original Name: None
    Source: http://www.secg.org/sec1-v2.pdf page 108
    u   ecPrivkeyVer1i   (   R   R    R!   R&   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR`   ä  s   t   ECPrivateKeyc           B` s{   e  Z d  Z d e f d e f d e i d d 6e d 6f d e i d d 6e d 6f g Z d Z
 d	 „  Z d
 „  Z d „  Z RS(   u:   
    Source: http://www.secg.org/sec1-v2.pdf page 108
    u   versionu   private_keyu
   parametersi    u   explicitu   optionalu
   public_keyi   c         C` sð   t  t |  ƒ j | | ƒ } | d k r£ |  j d  k r„ |  d j } t | t ƒ r  t | ƒ d k r  |  j	 t |  d j ƒ ƒ q  qì |  j d  k	 rì |  j
 ƒ  qì nI | d k rì t |  d t ƒ rì |  d j d k rì |  j	 |  d j ƒ n  | S(   Nu   private_keyi   u
   parametersu   implicit_ca(   t   superRa   t   __setitem__t	   _key_sizeRS   t   contentst
   isinstanceR   R;   t   set_key_sizet   _update_key_sizeRY   RU   RW   (   R>   t   keyt   valuet   rest   pkey_contents(    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRc   ÿ  s    ! c         C` s   | |  _  |  j ƒ  d S(   u·   
        Sets the key_size to ensure the private key is encoded to the proper length

        :param key_size:
            An integer byte length to encode the private_key to
        N(   Rd   Rh   (   R>   RW   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRg     s    	c         C` s=   |  j  d k	 r9 t |  d t ƒ r9 |  d j |  j  ƒ n  d S(   uG   
        Ensure the private_key explicit encoding width is set
        u   private_keyN(   Rd   RS   Rf   R   t   set_encoded_width(   R>   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRh     s    "N(   R   R    R!   R`   R   RY   R(   RF   R"   RS   Rd   Rc   Rg   Rh   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRa   ï  s   		 		t	   DSAParamsc           B` s/   e  Z d  Z d e f d e f d e f g Z RS(   u‰   
    Parameters for a DSA public or private key

    Original Name: Dss-Parms
    Source: https://tools.ietf.org/html/rfc3279#page-9
    u   pu   qu   g(   R   R    R!   R   R"   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRn   &  s   		t	   Attributec           B` s0   e  Z d  Z d e f d e i e d 6f g Z RS(   uq   
    Source: https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-X.501-198811-S!!PDF-E&type=items page 8
    u   typeu   valuesu   spec(   R   R    R!   R   R   R   R"   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRo   5  s   	t
   Attributesc           B` s   e  Z d  Z e Z RS(   u<   
    Source: https://tools.ietf.org/html/rfc5208#page-3
    (   R   R    R!   Ro   R$   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRp   @  s   t   PrivateKeyAlgorithmIdc           B` s0   e  Z d  Z i d d 6d d 6d d 6d d 6Z RS(	   u»   
    These OIDs for various public keys are reused when storing private keys
    inside of a PKCS#8 structure

    Original Name: None
    Source: https://tools.ietf.org/html/rfc3279
    u   rsau   1.2.840.113549.1.1.1u
   rsassa_pssu   1.2.840.113549.1.1.10u   dsau   1.2.840.10040.4.1u   ecu   1.2.840.10045.2.1(   R   R    R!   R&   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRq   H  s   t   PrivateKeyAlgorithmc           B` sQ   e  Z d  Z d e f d e i e d 6f g Z d Z i e d 6e	 d 6e
 d 6Z RS(   um   
    Original Name: PrivateKeyAlgorithmIdentifier
    Source: https://tools.ietf.org/html/rfc5208#page-3
    u	   algorithmu
   parametersu   optionalu   dsau   ecu
   rsassa_pss(   u	   algorithmu
   parameters(   R   R    R!   Rq   R   R(   R"   RL   Rn   RY   R   RM   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRr   ]  s   	t   PrivateKeyInfoc           B` s  e  Z d  Z d e f d e f d e f d e i d d 6e d 6f g Z d „  Z	 i e	 d 6Z
 d Z d Z d Z d Z e 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 RS(   u<   
    Source: https://tools.ietf.org/html/rfc5208#page-3
    u   versionu   private_key_algorithmu   private_keyu
   attributesi    u   implicitu   optionalc         C` s5   |  d d j  } i t d 6t d 6t d 6t d 6| S(   Nu   private_key_algorithmu	   algorithmu   rsau
   rsassa_pssu   dsau   ec(   R:   R'   R   Ra   (   R>   t	   algorithm(    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyt   _private_key_spec|  s    c         C` sË  t  | t ƒ r> t  | t ƒ r> t t d t | ƒ ƒ ƒ ‚ n  | d k rw t  | t ƒ sk t j | ƒ } n  t ƒ  } nß | d k rî t  | t	 ƒ s¤ t	 j | ƒ } n  t
 ƒ  } | d | d <| d | d <| d | d <| d } | d } nh | d	 k r;t  | t ƒ st j | ƒ } n | j ƒ  } | d
 } | d
 =n t t d t | ƒ ƒ ƒ ‚ t ƒ  } t | ƒ | d <| | d
 <|  ƒ  } | | _ t d ƒ | d <| | d <| | d <| d k rÇ| | _ n  | S(   u'  
        Wraps a private key in a PrivateKeyInfo structure

        :param private_key:
            A byte string or Asn1Value object of the private key

        :param algorithm:
            A unicode string of "rsa", "dsa" or "ec"

        :return:
            A PrivateKeyInfo object
        uX   
                private_key must be a byte string or Asn1Value, not %s
                u   rsau   dsau   pu   qu   gu
   public_keyu   private_keyu   ecu
   parametersuU   
                algorithm must be one of "rsa", "dsa", "ec", not %s
                u	   algorithmi    u   versionu   private_key_algorithm(   Rf   R   R   t	   TypeErrorR   R   R'   t   loadR   R*   Rn   Ra   t   copyR=   R\   Rr   Rq   t
   _algorithmR   t   _public_key(   R2   t   private_keyRt   t   paramst
   public_keyt   private_key_algot	   container(    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyt   wrapŽ  sJ     	


	
		

c         C` sÁ   t  t |  ƒ j | | ƒ } |  d } | d k s= | d k r½ | d j d k r½ t | d t ƒ r½ | d j d k r½ t |  d t ƒ r½ t |  d j t	 ƒ r½ |  d j j
 | d j ƒ n  | S(   Nu   private_key_algorithmu   private_keyu	   algorithmu   ecu
   parametersu   implicit_ca(   Rb   Rs   Rc   R:   Rf   RY   RU   R   t   parsedRa   Rg   RW   (   R>   Ri   Rj   Rk   Rt   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRc   Ô  s    
c         C` s   t  d ƒ ‚ d S(   uÂ   
        Unwraps the private key into an RSAPrivateKey, DSAPrivateKey or
        ECPrivateKey object

        :return:
            An RSAPrivateKey, DSAPrivateKey or ECPrivateKey object
        ux   asn1crypto.keys.PrivateKeyInfo().unwrap() has been removed, please use oscrypto.asymmetric.PrivateKey().unwrap() insteadN(   R   (   R>   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR   å  s    	c         C` su   |  j  d k r0 t t d |  j  j ƒ  ƒ ƒ ‚ n  |  d d } | j } | j d k r_ d } n	 | j } | j | f S(   u#  
        Returns information about the curve used for an EC key

        :raises:
            ValueError - when the key is not an EC key

        :return:
            A two-element tuple, with the first element being a unicode string
            of "implicit_ca", "specified" or "named". If the first element is
            "implicit_ca", the second is None. If "specified", the second is
            an OrderedDict that is the native version of SpecifiedECDomain. If
            "named", the second is a unicode string of the curve name.
        u   ecuK   
                Only EC keys have a curve, this key is %s
                u   private_key_algorithmu
   parametersu   implicit_caN(   Rt   R=   R   t   upperRZ   RU   RS   R:   (   R>   R|   RZ   Rj   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyt   curveò  s    			c         C` si   |  j  d k r0 t t d |  j  j ƒ  ƒ ƒ ‚ n  t j |  d d d j d ƒ d } | d k re d	 Sd
 S(   uò   
        Returns the name of the family of hash algorithms used to generate a
        DSA key

        :raises:
            ValueError - when the key is not a DSA key

        :return:
            A unicode string of "sha1" or "sha2"
        u   dsaut   
                Only DSA keys are generated using a hash algorithm, this key is
                %s
                u   private_key_algorithmu
   parametersu   qi   i   i   u   sha1u   sha2(   Rt   R=   R   R‚   R.   R0   R:   (   R>   t   byte_len(    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyt	   hash_algo  s    %c         C` s-   |  j  d k r& |  d d j |  _  n  |  j  S(   uO   
        :return:
            A unicode string of "rsa", "dsa" or "ec"
        u   private_key_algorithmu	   algorithmN(   Ry   RS   R:   (   R>   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRt   .  s    c         C` sß   |  j  d k rØ |  j d k r5 |  d j d j } nM |  j d k r\ |  d d d j } n& |  j d k r‚ |  d j d j } n  t t j t j | d	 ƒ ƒ ƒ |  _  |  j  d
 } | d k rØ |  j  d
 | 7_  qØ n  |  j  S(   uU   
        :return:
            The bit size of the private key, as an integer
        u   rsau   private_keyu   modulusu   dsau   private_key_algorithmu
   parametersu   pu   eci   i   i    N(	   t	   _bit_sizeRS   Rt   R   R:   R-   R.   R/   R0   (   R>   t   primet   modulus(    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyt   bit_size9  s    $c         C` s   t  t j |  j d ƒ ƒ S(   uV   
        :return:
            The byte size of the private key, as an integer
        i   (   R-   R.   R/   R‰   (   R>   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyt	   byte_sizeM  s    c         C` s   t  d ƒ ‚ d S(   u¤   
        :return:
            If an RSA key, an RSAPublicKey object. If a DSA key, an Integer
            object. If an EC key, an ECPointBitString object.
        u…   asn1crypto.keys.PrivateKeyInfo().public_key has been removed, please use oscrypto.asymmetric.PrivateKey().public_key.unwrap() insteadN(   R   (   R>   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR}   V  s    c         C` s   t  d ƒ ‚ d S(   u\   
        :return:
            A PublicKeyInfo object derived from this private key.
        u†   asn1crypto.keys.PrivateKeyInfo().public_key_info has been removed, please use oscrypto.asymmetric.PrivateKey().public_key.asn1 insteadN(   R   (   R>   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyt   public_key_infob  s    c         C` s   t  d ƒ ‚ d S(   uY  
        Creates a fingerprint that can be compared with a public key to see if
        the two form a pair.

        This fingerprint is not compatible with fingerprints generated by any
        other software.

        :return:
            A byte string that is a sha256 hash of selected components (based
            on the key type)
        u~   asn1crypto.keys.PrivateKeyInfo().fingerprint has been removed, please use oscrypto.asymmetric.PrivateKey().fingerprint insteadN(   R   (   R>   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyt   fingerprintm  s    N(   R   R    R!   R   Rr   R   Rp   R(   R"   Ru   t   _spec_callbacksRS   Ry   R†   Rz   t   _fingerprintRD   R€   Rc   R   R_   Rƒ   R…   Rt   R‰   RŠ   R}   R‹   RŒ   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRs   p  s.   			 		
F		"	t   EncryptedPrivateKeyInfoc           B` s&   e  Z d  Z d e f d e f g Z RS(   u<   
    Source: https://tools.ietf.org/html/rfc5208#page-4
    u   encryption_algorithmu   encrypted_data(   R   R    R!   R
   R   R"   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR   €  s   	t   ValidationParmsc           B` s&   e  Z d  Z d e f d e f g Z RS(   u=   
    Source: https://tools.ietf.org/html/rfc3279#page-10
    u   seedu   pgen_counter(   R   R    R!   R   R   R"   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR     s   	t   DomainParametersc        	   B` sU   e  Z d  Z d e f d e f d e f d e i e d 6f d e i e d 6f g Z RS(   u=   
    Source: https://tools.ietf.org/html/rfc3279#page-10
    u   pu   gu   qu   ju   optionalu   validation_params(   R   R    R!   R   R(   R   R"   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR‘   ˜  s   			t   PublicKeyAlgorithmIdc           B` s>   e  Z d  Z i d d 6d d 6d d 6d d 6d	 d
 6d d 6Z RS(   uM   
    Original Name: None
    Source: https://tools.ietf.org/html/rfc3279
    u   rsau   1.2.840.113549.1.1.1u
   rsaes_oaepu   1.2.840.113549.1.1.7u
   rsassa_pssu   1.2.840.113549.1.1.10u   dsau   1.2.840.10040.4.1u   ecu   1.2.840.10045.2.1u   dhu   1.2.840.10046.2.1(   R   R    R!   R&   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR’   ¦  s   t   PublicKeyAlgorithmc           B` s_   e  Z d  Z d e f d e i e d 6f g Z d	 Z i e d 6e	 d 6e
 d 6e d 6e d 6Z RS(
   ud   
    Original Name: AlgorithmIdentifier
    Source: https://tools.ietf.org/html/rfc5280#page-18
    u	   algorithmu
   parametersu   optionalu   dsau   ecu   dhu
   rsaes_oaepu
   rsassa_pss(   u	   algorithmu
   parameters(   R   R    R!   R’   R   R(   R"   RL   Rn   RY   R‘   R   R   RM   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR“   ¼  s   	t   PublicKeyInfoc           B` sê   e  Z d  Z d e f d e f g Z d „  Z i e d 6Z d Z	 d Z
 d Z d Z d Z e 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 RS(   ue   
    Original Name: SubjectPublicKeyInfo
    Source: https://tools.ietf.org/html/rfc5280#page-17
    u	   algorithmu
   public_keyc         C` sI   |  d d j  } i t d 6t d 6t d 6t d 6t d  f d 6t d 6| S(   Nu	   algorithmu   rsau
   rsaes_oaepu
   rsassa_pssu   dsau   ecu   dh(   R:   R)   R   RF   RS   (   R>   Rt   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyt   _public_key_specÜ  s    c         C` sÙ   t  | t ƒ r> t  | t ƒ r> t t d t | ƒ ƒ ƒ ‚ n  | d k rh t t d t | ƒ ƒ ƒ ‚ n  t ƒ  } t	 | ƒ | d <t
 ƒ  | d <|  ƒ  } | | d <t  | t ƒ rÅ | j ƒ  j ƒ  } n  t | ƒ | d <| S(   u  
        Wraps a public key in a PublicKeyInfo structure

        :param public_key:
            A byte string or Asn1Value object of the public key

        :param algorithm:
            A unicode string of "rsa"

        :return:
            A PublicKeyInfo object
        uW   
                public_key must be a byte string or Asn1Value, not %s
                u   rsau>   
                algorithm must "rsa", not %s
                u	   algorithmu
   parametersu
   public_key(   Rf   R   R   Rv   R   R   R=   R\   R“   R’   R   t   untagt   dumpR   (   R2   R}   Rt   t   algoR   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR€   ó  s"     		
c         C` s   t  d ƒ ‚ d S(   uÖ   
        Unwraps an RSA public key into an RSAPublicKey object. Does not support
        DSA or EC public keys since they do not have an unwrapped form.

        :return:
            An RSAPublicKey object
        uv   asn1crypto.keys.PublicKeyInfo().unwrap() has been removed, please use oscrypto.asymmetric.PublicKey().unwrap() insteadN(   R   (   R>   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR     s    	c         C` su   |  j  d k r0 t t d |  j  j ƒ  ƒ ƒ ‚ n  |  d d } | j } | j d k r_ d } n	 | j } | j | f S(   u#  
        Returns information about the curve used for an EC key

        :raises:
            ValueError - when the key is not an EC key

        :return:
            A two-element tuple, with the first element being a unicode string
            of "implicit_ca", "specified" or "named". If the first element is
            "implicit_ca", the second is None. If "specified", the second is
            an OrderedDict that is the native version of SpecifiedECDomain. If
            "named", the second is a unicode string of the curve name.
        u   ecuK   
                Only EC keys have a curve, this key is %s
                u	   algorithmu
   parametersu   implicit_caN(   Rt   R=   R   R‚   RZ   RU   RS   R:   (   R>   R|   RZ   Rj   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRƒ   +  s    			c         C` s‚   |  j  d k r0 t t d |  j  j ƒ  ƒ ƒ ‚ n  |  d d } | j d k rQ d St j | d j d ƒ d } | d k r~ d	 Sd
 S(   u#  
        Returns the name of the family of hash algorithms used to generate a
        DSA key

        :raises:
            ValueError - when the key is not a DSA key

        :return:
            A unicode string of "sha1" or "sha2" or None if no parameters are
            present
        u   dsaut   
                Only DSA keys are generated using a hash algorithm, this key is
                %s
                u	   algorithmu
   parametersu   qi   i   i   u   sha1u   sha2N(   Rt   R=   R   R‚   R:   RS   R.   R0   (   R>   t
   parametersR„   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR…   M  s    c         C` s-   |  j  d k r& |  d d j |  _  n  |  j  S(   uO   
        :return:
            A unicode string of "rsa", "dsa" or "ec"
        u	   algorithmN(   Ry   RS   R:   (   R>   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRt   l  s    c         C` sí   |  j  d k ræ |  j d k rC t |  d j ƒ d d d |  _  qæ |  j d k ri |  d j d j } n' |  j d k r |  d	 d
 d j } n  t t j t j	 | d ƒ ƒ ƒ |  _  |  j  d } | d k ræ |  j  d | 7_  qæ n  |  j  S(   uT   
        :return:
            The bit size of the public key, as an integer
        u   ecu
   public_keyi   i   i   u   rsau   modulusu   dsau	   algorithmu
   parametersu   pi    N(
   R†   RS   Rt   R;   R:   R   R-   R.   R/   R0   (   R>   R‡   Rˆ   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR‰   w  s    %$c         C` s   t  t j |  j d ƒ ƒ S(   uU   
        :return:
            The byte size of the public key, as an integer
        i   (   R-   R.   R/   R‰   (   R>   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRŠ     s    c         C` s;   |  j  d k r4 t j t |  d ƒ ƒ j ƒ  |  _  n  |  j  S(   ue   
        :return:
            The SHA1 hash of the DER-encoded bytes of this public key info
        u
   public_keyN(   t   _sha1RS   t   hashlibt   sha1R   t   digest(   R>   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRœ   –  s    %c         C` s;   |  j  d k r4 t j t |  d ƒ ƒ j ƒ  |  _  n  |  j  S(   uh   
        :return:
            The SHA-256 hash of the DER-encoded bytes of this public key info
        u
   public_keyN(   t   _sha256RS   R›   t   sha256R   R   (   R>   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRŸ   ¡  s    %c         C` s   t  d ƒ ‚ d S(   uZ  
        Creates a fingerprint that can be compared with a private key to see if
        the two form a pair.

        This fingerprint is not compatible with fingerprints generated by any
        other software.

        :return:
            A byte string that is a sha256 hash of selected components (based
            on the key type)
        u|   asn1crypto.keys.PublicKeyInfo().fingerprint has been removed, please use oscrypto.asymmetric.PublicKey().fingerprint insteadN(   R   (   R>   (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyRŒ   ¬  s    N(   R   R    R!   R“   R   R"   R•   R   RS   Ry   R†   RŽ   Rš   Rž   RD   R€   R   R_   Rƒ   R…   Rt   R‰   RŠ   Rœ   RŸ   RŒ   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyR”   Ñ  s*   		
+	"	(H   R!   t
   __future__R    R   R   R   R›   R.   t   _errorsR   R   t   _typesR   R   t   algosR   R	   R
   R   R   t   coreR   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   utilR   R   R   R#   R%   R'   R)   R*   R+   RE   RF   RG   RH   RI   RJ   RK   RN   RO   RP   RQ   RY   R`   Ra   Rn   Ro   Rp   Rq   Rr   Rs   R   R   R‘   R’   R“   R”   (    (    (    s.   lib/python2.7/site-packages/asn1crypto/keys.pyt   <module>   sT   "(dF%7ÿ 