ó
§ùþMc           @   sû  d  Z  d d l 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 d d l
 m Z m Z d d	 l
 m Z m Z d d
 l
 m Z m Z d d l
 m Z m Z m Z d d l
 m Z m Z d d l
 m Z m  Z  d d l
 m! Z! m" Z" d d l
 m# Z# m$ Z$ m% Z% d d l
 m& Z& m' Z' m( Z( d d l
 m) Z) m* Z* d d l
 m+ Z+ m, Z, d d l- m. Z. m/ Z/ m0 Z0 d „  Z1 d „  Z2 e0 d ƒ Z3 e0 d ƒ Z4 e0 d ƒ Z5 e2 e0 d ƒ ƒ Z6 e0 d ƒ Z7 e2 e0 d ƒ ƒ Z8 e0 d ƒ Z9 e2 e0 d ƒ ƒ Z: e0 d ƒ Z; e0 d ƒ Z< e0 d ƒ Z= e0 d ƒ Z> e0 d  ƒ Z? d! e. f d" „  ƒ  YZ@ d# e. f d$ „  ƒ  YZA d% e. f d& „  ƒ  YZB d' f  d( „  ƒ  YZC d) e. eC f d* „  ƒ  YZD d+ e. eC f d, „  ƒ  YZE d- e. f d. „  ƒ  YZF e jG d/ ƒ ZH e jG d0 ƒ ZI d1 „  ZJ d2 „  ZK d3 „  ZL d4 e. f d5 „  ƒ  YZM d6 e. f d7 „  ƒ  YZN d8 e. eC f d9 „  ƒ  YZO d: e. f d; „  ƒ  YZP d< e. f d= „  ƒ  YZQ d> e. f d? „  ƒ  YZR eS d@ k r÷e ƒ  n  d S(A   s#   
Unit tests for L{OpenSSL.crypto}.
iÿÿÿÿ(   t   mainN(   t   PIPEt   Popen(   t   datetimet	   timedelta(   t   TYPE_RSAt   TYPE_DSAt   Errort   PKeyt   PKeyType(   t   X509t   X509Typet   X509Namet   X509NameType(   t   X509Reqt   X509ReqType(   t   X509Extensiont   X509ExtensionType(   t   load_certificatet   load_privatekey(   t   FILETYPE_PEMt   FILETYPE_ASN1t   FILETYPE_TEXT(   t   dump_certificatet   load_certificate_request(   t   dump_certificate_requestt   dump_privatekey(   t	   PKCS7Typet   load_pkcs7_data(   t   PKCS12t
   PKCS12Typet   load_pkcs12(   t   CRLt   Revokedt   load_crl(   t   NetscapeSPKIt   NetscapeSPKIType(   t   signt   verify(   t   TestCaset   bytest   bc         C   s   t  t t t |  ƒ ƒ S(   N(   R   R   R   (   t   pem(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   normalize_certificate_pem   s    c         C   s   t  t t t |  ƒ ƒ S(   N(   R   R   R   (   R*   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   normalize_privatekey_pem!   s    s2  -----BEGIN CERTIFICATE-----
MIIC7TCCAlagAwIBAgIIPQzE4MbeufQwDQYJKoZIhvcNAQEFBQAwWDELMAkGA1UE
BhMCVVMxCzAJBgNVBAgTAklMMRAwDgYDVQQHEwdDaGljYWdvMRAwDgYDVQQKEwdU
ZXN0aW5nMRgwFgYDVQQDEw9UZXN0aW5nIFJvb3QgQ0EwIhgPMjAwOTAzMjUxMjM2
NThaGA8yMDE3MDYxMTEyMzY1OFowWDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAklM
MRAwDgYDVQQHEwdDaGljYWdvMRAwDgYDVQQKEwdUZXN0aW5nMRgwFgYDVQQDEw9U
ZXN0aW5nIFJvb3QgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAPmaQumL
urpE527uSEHdL1pqcDRmWzu+98Y6YHzT/J7KWEamyMCNZ6fRW1JCR782UQ8a07fy
2xXsKy4WdKaxyG8CcatwmXvpvRQ44dSANMihHELpANTdyVp6DCysED6wkQFurHlF
1dshEaJw8b/ypDhmbVIo6Ci1xvCJqivbLFnbAgMBAAGjgbswgbgwHQYDVR0OBBYE
FINVdy1eIfFJDAkk51QJEo3IfgSuMIGIBgNVHSMEgYAwfoAUg1V3LV4h8UkMCSTn
VAkSjch+BK6hXKRaMFgxCzAJBgNVBAYTAlVTMQswCQYDV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5haykeln3Of4M9d/4Kj+FcCQQCY
si6xwT7GzMDkk/ko684AV3KPc/h6G0yGtFIrMg7J3uExpR/VdH2KgwMkZXisSMvw
JJEQjOMCVsEJlRk54WWjAkEAzoZNH6UhDdBK5F38rVt/y4SEHgbSfJHIAmPS32Kq
f6GGcfNpip0Uk7q7udTKuX7Q/buZi/C4YW7u3VKAquv9NA==
-----END RSA PRIVATE KEY-----
s  -----BEGIN CERTIFICATE REQUEST-----
MIIBnjCCAQcCAQAwXjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAklMMRAwDgYDVQQH
EwdDaGljYWdvMRcwFQYDVQQKEw5NeSBDb21wYW55IEx0ZDEXMBUGA1UEAxMORnJl
ZGVyaWNrIERlYW4wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANp6Y17WzKSw
BsUWkXdqg6tnXy8H8hA1msCMWpc+/2KJ4mbv5NyD6UD+/SqagQqulPbF/DFea9nA
E0zhmHJELcM8gUTIlXv/cgDWnmK4xj8YkjVUiCdqKRAKeuzLG1pGmwwF5lGeJpXN
xQn5ecR0UYSOWj6TTGXB9VyUMQzCClcBAgMBAAGgADANBgkqhkiG9w0BAQUFAAOB
gQAAJGuF/R/GGbeC7FbFW+aJgr9ee0Xbl6nlhu7pTe67k+iiKT2dsl2ti68MVTnu
Vrb3HUNqOkiwsJf6kCtq5oPn3QVYzTa76Dt2y3Rtzv6boRSlmlfrgS92GNma8JfR
oICQk3nAudi6zl1Dix3BCv1pUp5KMtGn3MeDEi6QFGy2rA==
-----END CERTIFICATE REQUEST-----
sÃ  -----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,9573604A18579E9E

SHOho56WxDkT0ht10UTeKc0F5u8cqIa01kzFAmETw0MAs8ezYtK15NPdCXUm3X/2
a17G7LSF5bkxOgZ7vpXyMzun/owrj7CzvLxyncyEFZWvtvzaAhPhvTJtTIB3kf8B
8+qRcpTGK7NgXEgYBW5b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QAYDzIwMDkwNzI1MjMzNDU2WjAM
MAoGA1UdFQQDCgEEMA0GCSqGSIb3DQEBBAUAA4GBAEBt7xTs2htdD3d4ErrcGAw1
4dKcVnIWTutoI7xxen26Wwvh8VCsT7i/UeP+rBl9rC/kfjWjzQk3/zleaarGTpBT
0yp4HXRFFoRhhSE/hP+eteaPXRgrsNRLHe9ZDd69wmh7J1wMDb0m81RG7kqcbsid
vrzEeLDRiiPl92dyyWmu
-----END X509 CRL-----
t   X509ExtTestsc           B   s§   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 d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s4   
    Tests for L{OpenSSL.crypto.X509Extension}.
    c         C   s  t  ƒ  |  _ |  j j t d ƒ t ƒ  |  _ |  j j |  j ƒ d |  j j ƒ  _ t	 ƒ  |  _
 |  j
 j ƒ  |  _ |  j j ƒ  j |  j _ |  j
 j |  j ƒ |  j
 j |  j ƒ t t j ƒ  j d ƒ ƒ } t t j ƒ  t d d ƒ j d ƒ ƒ } |  j
 j | ƒ |  j
 j | ƒ d S(   s‡   
        Create a new private key and start a certificate request (for a test
        method to finish in one way or another).
        i€  s   Yoda root CAs   %Y%m%d%H%M%SZt   daysid   N(   R   t   pkeyt   generate_keyR   R   t   reqt
   set_pubkeyt   get_subjectt
   commonNameR
   t   x509t   subjectt
   set_issuerR)   R   t   nowt   strftimeR   t   set_notBeforet   set_notAfter(   t   selfR9   t   expire(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   setUp  s    (c         C   s2   |  j  t t t d ƒ t t d ƒ ƒ ƒ d ƒ d S(   sw   
        The string representation of L{X509Extension} instances as returned by
        C{str} includes stuff.
        t   basicConstraintss   CA:falses   CA:FALSEN(   t   assertEqualst   strR   R)   t   True(   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_str  s    !c         C   s9   |  j  t t ƒ |  j t d t d ƒ t t d ƒ ƒ d S(   s“   
        L{X509Extension} and L{X509ExtensionType} refer to the same type object
        and can be used to create instances of that type.
        R   R@   s   CA:trueN(   t   assertIdenticalR   R   t   assertConsistentTypeR)   RC   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt	   test_type%  s    c         C   s˜   t  t d ƒ t t d ƒ ƒ } |  j t | t ƒ d | t | ƒ t f ƒ t  t d ƒ t t d ƒ ƒ } |  j t | t ƒ d | t | ƒ t f ƒ d S(   s    
        L{X509Extension} accepts an extension type name, a critical flag,
        and an extension value and returns an L{X509ExtensionType} instance.
        R@   s   CA:trues   %r is of type %r, should be %rt	   nsComments   pyOpenSSL unit testN(   R   R)   RC   t
   assertTruet
   isinstanceR   t   typet   False(   R=   t   basict   comment(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_construction0  s    c         C   ss   |  j  t t t d ƒ t t d ƒ ƒ |  j  t t t d ƒ t t d ƒ ƒ |  j  t t t d ƒ t t d ƒ ƒ d S(   sj   
        L{X509Extension} raises something if it is passed a bad extension
        name or value.
        t   thisIsMadeUpt   hiR@   s	   blah blaht   proxyCertInfos4   language:id-ppl-anyLanguage,pathlen:1,policy:text:ABN(   t   assertRaisesR   R   R)   RL   RC   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_invalid_extensionC  s    c         C   sf   t  t d ƒ t t d ƒ ƒ } |  j | j ƒ  ƒ t  t d ƒ t t d ƒ ƒ } |  j | j ƒ  ƒ d S(   so   
        L{X509ExtensionType.get_critical} returns the value of the
        extension's critical flag.
        R@   s   CA:trueN(   R   R)   RC   RI   t   get_criticalRL   t   assertFalse(   R=   t   ext(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_criticalV  s    c         C   sx   t  t d ƒ t t d ƒ ƒ } |  j | j ƒ  t d ƒ ƒ t  t d ƒ t t d ƒ ƒ } |  j | j ƒ  t d ƒ ƒ d S(   s{   
        L{X509ExtensionType.get_short_name} returns a string giving the short
        type name of the extension.
        R@   s   CA:trueRH   s   foo barN(   R   R)   RC   t   assertEqualt   get_short_name(   R=   RW   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_short_namea  s    c         C   s>   t  t d ƒ t t d ƒ ƒ } |  j | j ƒ  t d ƒ ƒ d S(   sf   
        L{X509Extension.get_data} returns a string giving the data of the
        extension.
        R@   s   CA:trues   0ÿN(   R   R)   RC   RY   t   get_data(   R=   RW   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_datal  s    c         C   sd   t  t d ƒ t t d ƒ ƒ } |  j t | j d ƒ |  j t | j d ƒ |  j t | j d ƒ d S(   sX   
        L{X509Extension.get_data} raises L{TypeError} if passed any arguments.
        R@   s   CA:truet   fooi   N(   R   R)   RC   RS   t	   TypeErrorR\   t   None(   R=   RW   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_data_wrong_argsv  s    c         C   s˜   t  t d ƒ t t d ƒ d |  j ƒ} |  j j | g ƒ |  j j |  j d ƒ t t |  j ƒ } |  j	 t d ƒ | k ƒ |  j	 t d ƒ | k ƒ d S(   sš   
        The C{subject} parameter to L{X509Extension} may be provided for an
        extension which does not use it and is ignored in this case.
        R@   s   CA:TRUER7   t   sha1s   X509v3 Basic Constraints:N(
   R   R)   RL   R6   t   add_extensionsR%   R0   R   R   RI   (   R=   t   ext1t   text(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_unused_subject€  s    $c         C   s   t  t d ƒ t t d ƒ d |  j ƒ} |  j j | g ƒ |  j j |  j d ƒ t t |  j ƒ } |  j	 t d ƒ | k ƒ d S(   s~   
        If an extension requires a subject, the C{subject} parameter to
        L{X509Extension} provides its value.
        t   subjectKeyIdentifiert   hashR7   Rb   s   X509v3 Subject Key Identifier:N(
   R   R)   RL   R6   Rc   R%   R0   R   R   RI   (   R=   t   ext3Re   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_subject  s    $c         C   s)   |  j  t t t d ƒ t t d ƒ ƒ d S(   s   
        If an extension requires a subject and the C{subject} parameter is
        given no value, something happens.
        Rg   Rh   N(   RS   R   R   R)   RL   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_missing_subjectœ  s    c      	   C   sF   x? t  t ƒ  d g  |  g D]% } |  j t t d t d d | ƒq Wd S(   s€   
        If the C{subject} parameter is given a value which is not an L{X509}
        instance, L{TypeError} is raised.
        t   helloR@   s   CA:TRUER7   N(   RC   t   objectRS   R_   R   RL   (   R=   t   badObj(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_invalid_subject¥  s
    c         C   s˜   t  t d ƒ t t d ƒ d |  j ƒ} |  j j | g ƒ |  j j |  j d ƒ t t |  j ƒ } |  j	 t d ƒ | k ƒ |  j	 t d ƒ | k ƒ d S(   s™   
        The C{issuer} parameter to L{X509Extension} may be provided for an
        extension which does not use it and is ignored in this case.
        R@   s   CA:TRUEt   issuerRb   s   X509v3 Basic Constraints:N(
   R   R)   RL   R6   Rc   R%   R0   R   R   RI   (   R=   Rd   Re   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_unused_issuer±  s    $c         C   s˜   t  t d ƒ t t d ƒ d |  j ƒ} |  j j | g ƒ |  j j |  j d ƒ t t |  j ƒ } |  j	 t d ƒ | k ƒ |  j	 t d ƒ | k ƒ d S(   s|   
        If an extension requires a issuer, the C{issuer} parameter to
        L{X509Extension} provides its value.
        t   authorityKeyIdentifiers   issuer:alwaysRp   Rb   s    X509v3 Authority Key Identifier:s   DirName:/CN=Yoda root CAN(
   R   R)   RL   R6   Rc   R%   R0   R   R   RI   (   R=   t   ext2Re   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_issuer¿  s    c         C   s)   |  j  t t t d ƒ t t d ƒ ƒ d S(   s}   
        If an extension requires an issue and the C{issuer} parameter is given
        no value, something happens.
        Rr   s   keyid:always,issuer:alwaysN(   RS   R   R   R)   RL   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_missing_issuerÎ  s
    c      	   C   sF   x? t  t ƒ  d g  |  g D]% } |  j t t d t d d | ƒq Wd S(   s   
        If the C{issuer} parameter is given a value which is not an L{X509}
        instance, L{TypeError} is raised.
        Rl   Rr   s   keyid:always,issuer:alwaysRp   N(   RC   Rm   RS   R_   R   RL   (   R=   Rn   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_invalid_issuerÚ  s    (   t   __name__t
   __module__t   __doc__R?   RD   RG   RO   RT   RX   R[   R]   Ra   Rf   Rj   Rk   Ro   Rq   Rt   Ru   Rv   (    (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR.   ý   s$   								
	
								t	   PKeyTestsc           B   sM   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   s0   
    Unit tests for L{OpenSSL.crypto.PKey}.
    c         C   s$   |  j  t t ƒ |  j t d ƒ d S(   s   
        L{PKey} and L{PKeyType} refer to the same type object and can be used
        to create instances of that type.
        R   N(   RE   R   R	   RF   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRG   ì  s    c         C   sL   |  j  t t d ƒ t ƒ  } |  j t | t ƒ d | t | ƒ t f ƒ d S(   sP   
        L{PKey} takes no arguments and returns a new L{PKey} instance.
        s   %r is of type %r, should be %rN(   RS   R_   R   R`   RI   RJ   R	   RK   (   R=   t   key(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRO   õ  s
    	c         C   s9   t  ƒ  } |  j | j ƒ  d ƒ |  j | j ƒ  d ƒ d S(   sh   
        L{PKeyType.bits} and L{PKeyType.type} return C{0} before the key is
        generated.
        i    N(   R   RY   RK   t   bits(   R=   R{   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_pregeneration   s    	c         C   s    t  ƒ  } |  j t | j ƒ |  j t | j d d d ƒ |  j t | j d d ƒ |  j t | j d d ƒ |  j t | j t d ƒ |  j t | j t d ƒ d S(	   ss  
        L{PKeyType.generate_key} takes two arguments, the first giving the key
        type as one of L{TYPE_RSA} or L{TYPE_DSA} and the second giving the
        number of bits to generate.  If an invalid type is specified or
        generation fails, L{Error} is raised.  If an invalid number of bits is
        specified, L{ValueError} or L{Error} is raised.
        i   i   i   R^   t   bariÿÿÿÿi    N(   R   RS   R_   R1   R   t
   ValueErrorR   (   R=   R{   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_failedGeneration
  s    	c         C   sO   d } t  ƒ  } | j t | ƒ |  j | j ƒ  t ƒ |  j | j ƒ  | ƒ d S(   sŠ   
        L{PKeyType.generate_key} generates an RSA key when passed
        L{TYPE_RSA} as a type and a reasonable number of bits.
        i€   N(   R   R1   R   RY   RK   R|   (   R=   R|   R{   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_rsaGeneration-  s
    	c         C   sO   d } t  ƒ  } | j t | ƒ |  j | j ƒ  t ƒ |  j | j ƒ  | ƒ d S(   s‰   
        L{PKeyType.generate_key} generates a DSA key when passed
        L{TYPE_DSA} as a type and a reasonable number of bits.
        i   N(   R   R1   R   RY   RK   R|   (   R=   R|   R{   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_dsaGeneration9  s
    	c         C   sr   t  ƒ  } xb t d f t d f g D]H \ } } | j | | ƒ |  j | j ƒ  | ƒ |  j | j ƒ  | ƒ q" Wd S(   su   
        L{PKeyType.generate_key} can be called multiple times on the same
        key to generate new keys.
        i   i@  N(   R   R   R   R1   RY   RK   R|   (   R=   R{   RK   R|   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_regenerationH  s
    	%(
   Rw   Rx   Ry   RG   RO   R}   R€   R   R‚   Rƒ   (    (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRz   è  s   				
	#		t   X509NameTestsc           B   s_   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(
   s4   
    Unit tests for L{OpenSSL.crypto.X509Name}.
    c         K   se   t  ƒ  j ƒ  } t | j ƒ  ƒ } d „  } | j d | ƒ x$ | D] \ } } t | | | ƒ qA W| S(   Nc         S   s   |  d S(   Ni   (    (   t   attr(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR{   ^  s    R{   (   R
   R4   t   listt   itemst   sortt   setattr(   R=   t   attrst   nameR{   t   kt   v(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt	   _x509nameY  s    	c         C   su   |  j  t t ƒ |  j t j d ƒ |  j t t t ƒ ƒ |  j ƒ  } |  j t | t ƒ d | t | ƒ t f ƒ d S(   sB   
        The type of X509Name objects is L{X509NameType}.
        R   s   %r is of type %r, should be %rN(	   RE   R   R   RY   Rw   RI   RJ   RK   RŽ   (   R=   R‹   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRG   f  s    c         C   sÌ   |  j  ƒ  } d | _ |  j | j d ƒ |  j | j d ƒ d | _ |  j | j d ƒ |  j | j d ƒ d | _ |  j | j d ƒ |  j | j d ƒ d | _ |  j | j d ƒ |  j | j d ƒ d S(   si   
        L{X509NameType} instances have attributes for each standard (?)
        X509Name field.
        R^   t   bazR~   t   quuxN(   RŽ   R5   RY   t   CN(   R=   R‹   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_attributesu  s    				c         C   s†   |  j  d d d d ƒ } t | ƒ } |  j | j d ƒ |  j | j d ƒ d | _ |  j | j d ƒ d | _ |  j | j d ƒ d S(   s¯   
        L{X509Name} creates a new L{X509NameType} instance with all the same
        attributes as an existing L{X509NameType} instance when called with
        one.
        R5   R^   t   emailAddresss   bar@example.comR   s   quux@example.comN(   RŽ   R   RY   R5   R“   (   R=   R‹   t   copy(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt	   test_copy‰  s    		c         C   s2   |  j  d d d d ƒ } |  j t | ƒ d ƒ d S(   s°   
        L{repr} passed an L{X509NameType} instance should return a string
        containing a description of the type and the NIDs which have been set
        on it.
        R5   R^   R“   R~   s,   <X509Name object '/emailAddress=bar/CN=foo'>N(   RŽ   RY   t   repr(   R=   R‹   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt	   test_reprž  s    	c            sŸ  d „  ‰ ‡ ‡  f d †  } ˆ  j  ƒ  } | | | ƒ | ˆ  j  ƒ  ˆ  j  ƒ  ƒ | ˆ  j  d d ƒ ˆ  j  d d ƒ ƒ | ˆ  j  d d ƒ ˆ  j  d d ƒ ƒ | ˆ  j  d d d d ƒ ˆ  j  d d d d ƒ ƒ ‡ ‡  f d	 †  } | ˆ  j  d d ƒ ˆ  j  d d ƒ ƒ | ˆ  j  d d ƒ ˆ  j  d d ƒ ƒ d
 „  ‰ ‡  ‡ f d †  } | ˆ  j  d d ƒ ˆ  j  d d ƒ ƒ ‡  ‡ f d †  } | ˆ  j  d d ƒ ˆ  j  d d ƒ ƒ d S(   sO   
        L{X509NameType} instances should compare based on their NIDs.
        c         S   sQ   | |  | k d |  | f ƒ | |  | k ƒ | | |  k ƒ | | |  k ƒ d  S(   Ns   (%r == %r) --> False(    (   t   aR)   RI   RV   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt	   _equality®  s    c            s   ˆ  |  | ˆ j  ˆ j ƒ d  S(   N(   RI   RV   (   R˜   R)   (   R™   R=   (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRY   ´  s    R5   R^   R‘   t   organizationalUnitNameR~   t   OUc            s   ˆ  |  | ˆ j  ˆ j ƒ d  S(   N(   RV   RI   (   R˜   R)   (   R™   R=   (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   assertNotEqualÌ  s    c         S   s„   | |  | k  ƒ | |  | k ƒ | | |  k ƒ | | |  k ƒ | |  | k ƒ | |  | k ƒ | | |  k  ƒ | | |  k ƒ d  S(   N(    (   R˜   R)   RI   RV   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   _inequalityØ  s    c            s   ˆ |  | ˆ  j  ˆ  j ƒ d  S(   N(   RI   RV   (   R˜   R)   (   R=   R   (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   assertLessThanâ  s    t   abct   defc            s   ˆ |  | ˆ  j  ˆ  j ƒ d  S(   N(   RV   RI   (   R˜   R)   (   R=   R   (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   assertGreaterThanë  s    N(   RŽ   (   R=   RY   R‹   Rœ   Rž   R¡   (    (   R=   R   R™   s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_comparisonª  s.    		
c         C   si   |  j  d d ƒ } |  j  d d ƒ } |  j | j ƒ  | j ƒ  ƒ d | _ |  j | j ƒ  | j ƒ  ƒ d S(   sb   
        L{X509Name.hash} returns an integer hash based on the value of the
        name.
        R‘   R^   R~   N(   RŽ   RY   Rh   R‘   Rœ   (   R=   R˜   R)   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt	   test_hashõ  s
    	c         C   s8   |  j  d d d d ƒ } |  j | j ƒ  t d ƒ ƒ d S(   sK   
        L{X509Name.der} returns the DER encoded form of the name.
        R‘   R^   t   Ct   USs   010	UUS10
UfooN(   RŽ   RY   t   derR)   (   R=   R˜   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_der  s    	c         C   s£   |  j  ƒ  } |  j | j ƒ  g  ƒ d | _ |  j | j ƒ  t d ƒ t d ƒ f g ƒ d | _ |  j | j ƒ  t d ƒ t d ƒ f t d ƒ t d ƒ f g ƒ d S(   sœ   
        L{X509Name.get_components} returns a C{list} of two-tuples of C{str}
        giving the NIDs and associated values which make up the name.
        R^   R‘   R~   R›   N(   RŽ   RY   t   get_componentsR‘   R)   Rš   (   R=   R˜   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_components  s    	+		(   Rw   Rx   Ry   RŽ   RG   R’   R•   R—   R¢   R£   R§   R©   (    (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR„   U  s   						K		t   _PKeyInteractionTestsMixinc           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s7   
    Tests which involve another thing and a PKey.
    c         C   s   t  ƒ  ‚ d S(   s[   
        Return something with a C{set_pubkey}, C{set_pubkey}, and C{sign} method.
        N(   t   NotImplementedError(   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   signable  s    c         C   s2   |  j  ƒ  } t ƒ  } |  j t | j | d ƒ d S(   sY   
        L{X509Req.sign} raises L{ValueError} when pass a L{PKey} with no parts.
        t   MD5N(   R¬   R   RS   R   R%   (   R=   t   requestR{   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_signWithUngenerated&  s    	c         C   s[   |  j  ƒ  } t ƒ  } | j t d ƒ | j | ƒ | j ƒ  } |  j t | j | d ƒ d S(   s{   
        L{X509Req.sign} raises L{ValueError} when pass a L{PKey} with no
        private part as the signing key.
        i   R­   N(	   R¬   R   R1   R   R3   t
   get_pubkeyRS   R   R%   (   R=   R®   R{   t   pub(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_signWithPublicKey/  s    	c         C   sB   |  j  ƒ  } t ƒ  } | j t d ƒ |  j t | j | d ƒ d S(   sl   
        L{X509Req.sign} raises L{ValueError} when passed a digest name which is
        not known.
        i   t   monkeysN(   R¬   R   R1   R   RS   R   R%   (   R=   R®   R{   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_signWithUnknownDigest<  s    	c         C   s²   |  j  ƒ  } t ƒ  } | j t d ƒ | j | ƒ | j | d ƒ t | d d ƒ d k	 r® | j ƒ  } |  j	 | j
 | ƒ ƒ t ƒ  } | j t d ƒ |  j t | j
 | ƒ n  d S(   s§   
        L{X509Req.sign} succeeds when passed a private key object and a valid
        digest function.  C{X509Req.verify} can be used to check the signature.
        i   R­   R&   N(   R¬   R   R1   R   R3   R%   t   getattrR`   R°   RI   R&   RS   R   (   R=   R®   R{   R±   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt	   test_signG  s    		(   Rw   Rx   Ry   R¬   R¯   R²   R´   R¶   (    (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRª     s   					t   X509ReqTestsc           B   s_   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(
   s.   
    Tests for L{OpenSSL.crypto.X509Req}.
    c         C   s   t  ƒ  S(   s5   
        Create and return a new L{X509Req}.
        (   R   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR¬   a  s    c         C   s$   |  j  t t ƒ |  j t d ƒ d S(   s‡   
        L{X509Req} and L{X509ReqType} refer to the same type object and can be
        used to create instances of that type.
        R   N(   RE   R   R   RF   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRG   h  s    c         C   s9   t  ƒ  } |  j t | t ƒ d | t | ƒ t f ƒ d S(   sW   
        L{X509Req} takes no arguments and returns an L{X509ReqType} instance.
        s   %r is of type %r, should be %rN(   R   RI   RJ   R   RK   (   R=   R®   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRO   q  s    	c         C   si   t  ƒ  } |  j | j ƒ  d ƒ | j d ƒ |  j | j ƒ  d ƒ | j d ƒ |  j | j ƒ  d ƒ d S(   sé   
        L{X509ReqType.set_version} sets the X.509 version of the certificate
        request.  L{X509ReqType.get_version} returns the X.509 version of
        the certificate request.  The initial value of the version is 0.
        i    i   i   N(   R   RY   t   get_versiont   set_version(   R=   R®   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_version{  s    	c         C   se   t  ƒ  } |  j t | j ƒ |  j t | j d ƒ |  j t | j d d ƒ |  j t | j d ƒ d S(   sñ   
        L{X509ReqType.set_version} raises L{TypeError} if called with the wrong
        number of arguments or with a non-C{int} argument.
        L{X509ReqType.get_version} raises L{TypeError} if called with any
        arguments.
        R^   i   i   N(   R   RS   R_   R¹   R¸   R`   (   R=   R®   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_version_wrong_args‰  s
    	c         C   s†   t  ƒ  } | j ƒ  } |  j t | t ƒ d | t | ƒ t f ƒ d | _ |  j | j ƒ  j d ƒ ~ d | _ |  j | j d ƒ d S(   s¶   
        L{X509ReqType.get_subject} returns an L{X509Name} for the subject of
        the request and which is valid even after the request object is
        otherwise dead.
        s   %r is of type %r, should be %rR^   R~   N(   R   R4   RI   RJ   R   RK   R5   RY   (   R=   R®   R7   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_subject—  s    			c         C   s#   t  ƒ  } |  j t | j d ƒ d S(   sf   
        L{X509ReqType.get_subject} raises L{TypeError} if called with any
        arguments.
        N(   R   RS   R_   R4   R`   (   R=   R®   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_subject_wrong_args©  s    	c         C   s5   t  ƒ  } | j t t d ƒ t t d ƒ ƒ g ƒ d S(   s†   
        L{X509Req.add_extensions} accepts a C{list} of L{X509Extension}
        instances and adds them to the X509 request.
        R@   s   CA:falseN(   R   Rc   R   R)   RC   (   R=   R®   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_add_extensions²  s    	c         C   sn   t  ƒ  } |  j t | j ƒ |  j t | j t ƒ  ƒ |  j t | j t ƒ  g ƒ |  j t | j g  d ƒ d S(   s
  
        L{X509Req.add_extensions} raises L{TypeError} if called with the wrong
        number of arguments or with a non-C{list}.  Or it raises L{ValueError}
        if called with a C{list} containing objects other than L{X509Extension}
        instances.
        N(   R   RS   R_   Rc   Rm   R   R`   (   R=   R®   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_add_extensions_wrong_args½  s
    	(   Rw   Rx   Ry   R¬   RG   RO   Rº   R»   R¼   R½   R¾   R¿   (    (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR·   ]  s   				
						t	   X509Testsc           B   sb  e  Z d  Z e 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 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  d „  Z! d „  Z" d „  Z# d „  Z$ d  „  Z% d! „  Z& d" „  Z' d# „  Z( d$ „  Z) d% „  Z* RS(&   s+   
    Tests for L{OpenSSL.crypto.X509}.
    s#  
-----BEGIN CERTIFICATE-----
MIIC3jCCAkegAwIBAgIJAJHFjlcCgnQzMA0GCSqGSIb3DQEBBQUAMEcxCzAJBgNV
BAYTAlNFMRUwEwYDVQQIEwxXZXN0ZXJib3R0b20xEjAQBgNVBAoTCUNhdGFsb2dp
eDENMAsGA1UEAxMEUm9vdDAeFw0wODA0MjIxNDQ1MzhaFw0wOTA0MjIxNDQ1Mzha
MFQxCzAJBgNVBAYTAlNFMQswCQYDVQQIEwJXQjEUMBIGA1UEChMLT3Blbk1ldGFk
aXIxIjAgBgNVBAMTGW5vZGUxLm9tMi5vcGVubWV0YWRpci5vcmcwgZ8wDQYJKoZI
hvcNAQEBBQADgY0AMIGJAoGBAPIcQMrwbk2nESF/0JKibj9i1x95XYAOwP+LarwT
Op4EQbdlI9SY+uqYqlERhF19w7CS+S6oyqx0DRZSk4Y9dZ9j9/xgm2u/f136YS1u
zgYFPvfUs6PqYLPSM8Bw+SjJ+7+2+TN+Tkiof9WP1cMjodQwOmdsiRbR0/J7+b1B
hec1AgMBAAGjgcQwgcEwCQYDVR0TBAIwADAsBglghkgBhvhCAQ0EHxYdT3BlblNT
TCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFIdHsBcMVVMbAO7j6NCj
03HgLnHaMB8GA1UdIwQYMBaAFL2h9Bf9Mre4vTdOiHTGAt7BRY/8MEYGA1UdEQQ/
MD2CDSouZXhhbXBsZS5vcmeCESoub20yLmV4bWFwbGUuY29thwSC7wgKgRNvbTJA
b3Blbm1ldGFkaXIub3JnMA0GCSqGSIb3DQEBBQUAA4GBALd7WdXkp2KvZ7/PuWZA
MPlIxyjS+Ly11+BNE0xGQRp9Wz+2lABtpgNqssvU156+HkKd02rGheb2tj7MX9hG
uZzbwDAZzJPjzDQDD7d3cWsrVcfIdqVU7epHqIadnOF+X0ghJ39pAm6VVadnSXCt
WpOdIpB8KksUTCzV591Nr1wd
-----END CERTIFICATE-----
    c         C   s   t  ƒ  S(   s2   
        Create and return a new L{X509}.
        (   R
   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR¬   æ  s    c         C   s$   |  j  t t ƒ |  j t d ƒ d S(   s   
        L{X509} and L{X509Type} refer to the same type object and can be used
        to create instances of that type.
        R
   N(   RE   R
   R   RF   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRG   í  s    c         C   s—   t  ƒ  } |  j t | t ƒ d | t | ƒ t f ƒ |  j t t ƒ j d ƒ |  j t | ƒ j d ƒ |  j t | ƒ t ƒ |  j t | ƒ t  ƒ d S(   sT   
        L{X509} takes no arguments and returns an instance of L{X509Type}.
        s   %r is of type %r, should be %rRK   R
   N(   R
   RI   RJ   R   RK   RY   Rw   (   R=   t   certificate(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRO   ö  s    		c         C   s#   t  ƒ  } |  j t | j d ƒ d S(   sX   
        L{X509.get_version} raises L{TypeError} if invoked with any arguments.
        N(   R
   RS   R_   R¸   R`   (   R=   t   cert(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_version_wrong_args  s    	c         C   sO   t  ƒ  } |  j t | j ƒ |  j t | j d ƒ |  j t | j d d ƒ d S(   s’   
        L{X509.set_version} raises L{TypeError} if invoked with the wrong number
        of arguments or an argument not of type C{int}.
        i   N(   R
   RS   R_   R¹   R`   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_set_version_wrong_args  s    	c         C   s0   t  ƒ  } | j d ƒ |  j | j ƒ  d ƒ d S(   st   
        L{X509.set_version} sets the certificate version number.
        L{X509.get_version} retrieves it.
        iÒ  N(   R
   R¹   RA   R¸   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRº     s    	c         C   s#   t  ƒ  } |  j t | j d ƒ d S(   sf   
        L{X509.get_serial_number} raises L{TypeError} if invoked with any
        arguments.
        N(   R
   RS   R_   t   get_serial_numberR`   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt!   test_get_serial_number_wrong_args#  s    	c         C   s  t  ƒ  } |  j t | j ƒ |  j t | j d d ƒ |  j t | j d ƒ |  j t | j d ƒ |  j | j ƒ  d ƒ | j d ƒ |  j | j ƒ  d ƒ | j d ƒ |  j | j ƒ  d ƒ | j d ƒ |  j | j ƒ  d ƒ | j d ƒ |  j | j ƒ  d ƒ d	 S(   s¡   
        The serial number of an L{X509Type} can be retrieved and modified with
        L{X509Type.get_serial_number} and L{X509Type.set_serial_number}.
        i   i   t   1g      @i    i    i@   i€   Nl        l       l        l       l            l           l            l           l	                    l	                   l	                    l	                   (   R
   RS   R_   t   set_serial_numberRY   RÅ   (   R=   RÁ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_serial_number,  s    	c         C   s%  t  ƒ  } t | d | ƒ } t | d | ƒ } |  j | ƒ  d ƒ t d ƒ } | | ƒ |  j | ƒ  | ƒ t d ƒ } | | ƒ |  j | ƒ  | ƒ t d ƒ } | | ƒ |  j | ƒ  | ƒ |  j t | t d ƒ ƒ |  j t | ƒ |  j t | t d ƒ t d ƒ ƒ |  j t | t d ƒ ƒ d S(   s¶   
        L{X509Type.set_notBefore} takes a string in the format of an ASN1
        GENERALIZEDTIME and sets the beginning of the certificate's validity
        period to it.
        t   set_nott   get_nott   20040203040506Zs   20040203040506+0530s   20040203040506-0115s   foo barN(   R
   Rµ   RY   R`   R)   RS   R   R_   (   R=   t   whichRÁ   t   sett   gett   when(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   _setBoundTestA  s"    	


"c         C   s   |  j  d ƒ d S(   s¶   
        L{X509Type.set_notBefore} takes a string in the format of an ASN1
        GENERALIZEDTIME and sets the beginning of the certificate's validity
        period to it.
        t   BeforeN(   RÑ   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_set_notBeforeh  s    c         C   s   |  j  d ƒ d S(   s¯   
        L{X509Type.set_notAfter} takes a string in the format of an ASN1
        GENERALIZEDTIME and sets the end of the certificate's validity period
        to it.
        t   AfterN(   RÑ   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_set_notAfterq  s    c         C   s2   t  t |  j ƒ } |  j | j ƒ  t d ƒ ƒ d S(   s±   
        L{X509Type.get_notBefore} returns a string in the format of an ASN1
        GENERALIZEDTIME even for certificates which store it as UTCTIME
        internally.
        t   20090325123658ZN(   R   R   t   pemDataRY   t   get_notBeforeR)   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_notBeforez  s    c         C   s2   t  t |  j ƒ } |  j | j ƒ  t d ƒ ƒ d S(   s°   
        L{X509Type.get_notAfter} returns a string in the format of an ASN1
        GENERALIZEDTIME even for certificates which store it as UTCTIME
        internally.
        t   20170611123658ZN(   R   R   R×   RY   t   get_notAfterR)   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_notAfter„  s    c         C   sO   t  ƒ  } |  j t | j ƒ |  j t | j d ƒ |  j t | j d d ƒ d S(   s•   
        L{X509Type.gmtime_adj_notBefore} raises L{TypeError} if called with the
        wrong number of arguments or a non-C{int} argument.
        i{   N(   R
   RS   R_   t   gmtime_adj_notBeforeR`   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt$   test_gmtime_adj_notBefore_wrong_argsŽ  s    	c         C   sa   t  t |  j ƒ } t j ƒ  t d d ƒ } | j d ƒ |  j | j ƒ  t	 | j
 d ƒ ƒ ƒ d S(   s˜   
        L{X509Type.gmtime_adj_notBefore} changes the not-before timestamp to be
        the current time plus the number of seconds passed in.
        t   secondsid   s   %Y%m%d%H%M%SZN(   R   R   R×   R   t   utcnowR   RÝ   RY   RØ   R)   R:   (   R=   RÂ   R9   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_gmtime_adj_notBefore™  s    c         C   sO   t  ƒ  } |  j t | j ƒ |  j t | j d ƒ |  j t | j d d ƒ d S(   s”   
        L{X509Type.gmtime_adj_notAfter} raises L{TypeError} if called with the
        wrong number of arguments or a non-C{int} argument.
        i{   N(   R
   RS   R_   t   gmtime_adj_notAfterR`   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt#   test_gmtime_adj_notAfter_wrong_args¤  s    	c         C   sa   t  t |  j ƒ } t j ƒ  t d d ƒ } | j d ƒ |  j | j ƒ  t	 | j
 d ƒ ƒ ƒ d S(   s–   
        L{X509Type.gmtime_adj_notAfter} changes the not-after timestamp to be
        the current time plus the number of seconds passed in.
        Rß   id   s   %Y%m%d%H%M%SZN(   R   R   R×   R   Rà   R   Râ   RY   RÛ   R)   R:   (   R=   RÂ   R9   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_gmtime_adj_notAfter¯  s    c         C   s#   t  ƒ  } |  j t | j d ƒ d S(   sc   
        L{X509Type.has_expired} raises L{TypeError} if called with any
        arguments.
        N(   R
   RS   R_   t   has_expiredR`   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_has_expired_wrong_argsº  s    	c         C   s-   t  ƒ  } | j d ƒ |  j | j ƒ  ƒ d S(   su   
        L{X509Type.has_expired} returns C{True} if the certificate's not-after
        time is in the past.
        iÿÿÿÿN(   R
   Râ   RI   Rå   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_has_expiredÃ  s    	c         C   s-   t  ƒ  } | j d ƒ |  j | j ƒ  ƒ d S(   sx   
        L{X509Type.has_expired} returns C{False} if the certificate's not-after
        time is in the future.
        i   N(   R
   Râ   RV   Rå   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_has_not_expiredÍ  s    	c         C   s,   t  ƒ  } |  j | j d ƒ t d ƒ ƒ d S(   s‚   
        L{X509.digest} returns a string giving ":"-separated hex-encoded words
        of the digest of the certificate.
        t   md5s/   A8:EB:07:F8:53:25:0A:F2:56:05:C5:A5:C4:C4:C7:15N(   R
   RY   t   digestR)   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_digest×  s    	c         C   sŒ   t  ƒ  } | j | ƒ d | j ƒ  _ d | j ƒ  _ t t j ƒ  j d ƒ ƒ } | j	 | ƒ | j
 | ƒ | j | ƒ t t t t | ƒ ƒ S(   Ns
   Unit Testss   %Y%m%d%H%M%SZ(   R
   R3   R4   R5   t
   get_issuerR)   R   R9   R:   R;   R<   Rc   R   R   R   (   R=   R0   t
   extensionsRÂ   RÐ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   _extcertâ  s    	c         C   sñ   t  t t ƒ } t t d ƒ t t d ƒ ƒ } t t d ƒ t t d ƒ ƒ } t t d ƒ t t d ƒ ƒ } |  j | g  ƒ } |  j | j ƒ  d ƒ |  j | | g ƒ } |  j | j ƒ  d ƒ |  j | | | | g ƒ } |  j | j ƒ  d	 ƒ d
 S(   s{   
        L{X509.get_extension_count} returns the number of extensions that are
        present in the certificate.
        R@   s   CA:FALSEt   keyUsaget   digitalSignaturet   subjectAltNames   DNS:example.comi    i   i   N(	   R   R   t   client_key_pemR   R)   RC   Rî   RY   t   get_extension_count(   R=   R0   t   caR{   Rñ   t   c(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_extension_countð  s    c         C   sÆ  t  t t ƒ } t t d ƒ t t d ƒ ƒ } t t d ƒ t t d ƒ ƒ } t t d ƒ t t d ƒ ƒ } |  j | | | | g ƒ } | j d ƒ } |  j	 t
 | t ƒ ƒ |  j	 | j ƒ  ƒ |  j | j ƒ  t d ƒ ƒ | j d ƒ } |  j	 t
 | t ƒ ƒ |  j	 | j ƒ  ƒ |  j | j ƒ  t d ƒ ƒ | j d	 ƒ } |  j	 t
 | t ƒ ƒ |  j | j ƒ  ƒ |  j | j ƒ  t d ƒ ƒ |  j t | j d
 ƒ |  j t | j d ƒ |  j t | j d ƒ d S(   sŽ   
        L{X509.get_extension} takes an integer and returns an L{X509Extension}
        corresponding to the extension at that index.
        R@   s   CA:FALSERï   Rð   Rñ   s   DNS:example.comi    i   i   iÿÿÿÿi   Rl   N(   R   R   Rò   R   R)   RC   RL   Rî   t   get_extensionRI   RJ   RU   RY   RZ   RV   RS   t
   IndexErrorR_   (   R=   R0   Rô   R{   Rñ   RÂ   RW   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_extension  s*    c         C   s#   t  ƒ  } |  j t | j d ƒ d S(   sl   
        L{X509.digest} raises L{ValueError} if called with an unrecognized hash
        algorithm.
        R³   N(   R
   RS   R   Rê   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_invalid_digest_algorithm)  s    	c         C   s#   t  ƒ  } |  j t | j d ƒ d S(   sW   
        L{X509.get_subject} raises L{TypeError} if called with any arguments.
        N(   R
   RS   R_   R4   R`   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR½   2  s    	c      	   C   s·   t  t |  j ƒ } | j ƒ  } |  j t | t ƒ ƒ |  j | j ƒ  t	 d ƒ t	 d ƒ f t	 d ƒ t	 d ƒ f t	 d ƒ t	 d ƒ f t	 d ƒ t	 d ƒ f t	 d	 ƒ t	 d
 ƒ f g ƒ d S(   sF   
        L{X509.get_subject} returns an L{X509Name} instance.
        R¤   R¥   t   STt   ILt   Lt   Chicagot   Ot   TestingR‘   s   Testing Root CAN(
   R   R   R×   R4   RI   RJ   R   RA   R¨   R)   (   R=   RÂ   t   subj(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR¼   :  s    	?c         C   sU   t  ƒ  } |  j t | j ƒ |  j t | j d ƒ |  j t | j | j ƒ  d ƒ d S(   s˜   
        L{X509.set_subject} raises a L{TypeError} if called with the wrong
        number of arguments or an argument not of type L{X509Name}.
        N(   R
   RS   R_   t   set_subjectR`   R4   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_set_subject_wrong_argsG  s    	c         C   s~   t  ƒ  } | j ƒ  } d | _ d | _ | j | ƒ |  j | j ƒ  j ƒ  t d ƒ t d ƒ f t d ƒ t d ƒ f g ƒ d S(   sj   
        L{X509.set_subject} changes the subject of the certificate to the one
        passed in.
        t   AUs
   Unit TestsR¤   Rÿ   N(   R
   R4   R¤   Rÿ   R  RA   R¨   R)   (   R=   RÂ   R‹   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_set_subjectR  s    			c         C   s#   t  ƒ  } |  j t | j d ƒ d S(   sV   
        L{X509.get_issuer} raises L{TypeError} if called with any arguments.
        N(   R
   RS   R_   Rì   R`   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_issuer_wrong_argsa  s    	c      	   C   s½   t  t |  j ƒ } | j ƒ  } |  j t | t ƒ ƒ | j ƒ  } |  j | t	 d ƒ t	 d ƒ f t	 d ƒ t	 d ƒ f t	 d ƒ t	 d ƒ f t	 d ƒ t	 d ƒ f t	 d	 ƒ t	 d
 ƒ f g ƒ d S(   sE   
        L{X509.get_issuer} returns an L{X509Name} instance.
        R¤   R¥   Rû   Rü   Rý   Rþ   Rÿ   R   R‘   s   Testing Root CAN(
   R   R   R×   Rì   RI   RJ   R   R¨   RA   R)   (   R=   RÂ   R  t   comp(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_issueri  s    ?c         C   sU   t  ƒ  } |  j t | j ƒ |  j t | j d ƒ |  j t | j | j ƒ  d ƒ d S(   s—   
        L{X509.set_issuer} raises a L{TypeError} if called with the wrong
        number of arguments or an argument not of type L{X509Name}.
        N(   R
   RS   R_   R8   R`   Rì   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_set_issuer_wrong_argsw  s    	c         C   s~   t  ƒ  } | j ƒ  } d | _ d | _ | j | ƒ |  j | j ƒ  j ƒ  t d ƒ t d ƒ f t d ƒ t d ƒ f g ƒ d S(   sh   
        L{X509.set_issuer} changes the issuer of the certificate to the one
        passed in.
        R  s
   Unit TestsR¤   Rÿ   N(   R
   Rì   R¤   Rÿ   R8   RA   R¨   R)   (   R=   RÂ   R‹   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_set_issuer‚  s    			c         C   s    t  ƒ  } |  j t | j ƒ d S(   s}   
        When called on a certificate with no public key, L{X509.get_pubkey}
        raises L{OpenSSL.crypto.Error}.
        N(   R
   RS   R   R°   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_pubkey_uninitialized‘  s    	c         C   s#   t  ƒ  } |  j t | j d ƒ d S(   se   
        L{X509.subject_name_hash} raises L{TypeError} if called with any
        arguments.
        N(   R
   RS   R_   t   subject_name_hashR`   (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt!   test_subject_name_hash_wrong_argsš  s    	c         C   s2   t  t |  j ƒ } |  j | j ƒ  d d g ƒ d S(   sg   
        L{X509.subject_name_hash} returns the hash of the certificate's subject
        name.
        l   ‚,[ l   8Và N(   R   R   R×   t   assertInR  (   R=   RÂ   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_subject_name_hash£  s
    	(+   Rw   Rx   Ry   t   cleartextCertificatePEMt   cleartextPrivateKeyPEMR×   t   extpemR¬   RG   RO   RÃ   RÄ   Rº   RÆ   RÉ   RÑ   RÓ   RÕ   RÙ   RÜ   RÞ   Rá   Rã   Rä   Ræ   Rç   Rè   Rë   Rî   Rö   Rù   Rú   R½   R¼   R  R  R  R  R	  R
  R  R  R  (    (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRÀ   Ì  sN   
							
				'					
	
							
	
				!														t   PKCS12Testsc           B   sÕ   e  Z d  Z e e Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d d d d d „ Z d d d d d d „ Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sN   
    Test for L{OpenSSL.crypto.PKCS12} and L{OpenSSL.crypto.load_pkcs12}.
    c         C   s$   |  j  t t ƒ |  j t d ƒ d S(   s1   
        L{PKCS12Type} is a type object.
        R   N(   RE   R   R   RF   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRG   ·  s    c         C   se   t  ƒ  } |  j d | j ƒ  ƒ |  j d | j ƒ  ƒ |  j d | j ƒ  ƒ |  j d | j ƒ  ƒ d S(   sŒ   
        L{PKCS12} returns a new instance of L{PKCS12} with no certificate,
        private key, CA certificates, or friendly name.
        N(   R   RY   R`   t   get_certificatet   get_privatekeyt   get_ca_certificatest   get_friendlyname(   R=   t   p12(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_empty_construction¿  s
    	c         C   s$  t  ƒ  } |  j t | j d ƒ |  j t | j t ƒ  ƒ |  j t | j t ƒ |  j t | j d ƒ |  j t | j d ƒ |  j t | j t ƒ  ƒ |  j t | j d ƒ |  j t | j t ƒ  ƒ |  j t | j d ƒ |  j t | j t ƒ  f ƒ |  j t | j d ƒ |  j t | j d	 ƒ d S(
   sä   
        The L{PKCS12} setter functions (C{set_certificate}, C{set_privatekey},
        C{set_ca_certificates}, and C{set_friendlyname}) raise L{TypeError}
        when passed objects of types other than those expected.
        i   t   legbonei   i   R^   R~   N(   i   i   (   s   foos   bar(	   R   RS   R_   t   set_certificateR   R
   t   set_privatekeyt   set_ca_certificatest   set_friendlyname(   R=   R  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_type_errorsË  s    	c         C   sõ   d } t  ƒ  } t t t ƒ } | j | ƒ |  j d | j ƒ  ƒ |  j | | j ƒ  ƒ y" | j	 d | d d d d ƒ } Wn t
 k
 r d SXt | | ƒ } |  j d | j ƒ  ƒ |  j d | j ƒ  ƒ |  j t | j ƒ  t t d ƒ f ƒ ƒ d S(   s‹   
        A L{PKCS12} with only a private key can be exported using
        L{PKCS12.export} and loaded again using L{load_pkcs12}.
        t   blaht
   passphraset   iteri   t   maciteri   N(   R   R   R   R  R  RY   R`   R  R  t   exportR   R   R  RI   RJ   R   RK   (   R=   t   passwdR  R0   t
   dumped_p12(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_key_onlyà  s    	"c         C   s  d } t  ƒ  } t t t ƒ } | j | ƒ |  j | | j ƒ  ƒ |  j d | j ƒ  ƒ y" | j	 d | d d d d ƒ } Wn t
 k
 r d SXt | | ƒ } |  j d | j ƒ  ƒ |  j t | j ƒ  t t d ƒ f ƒ ƒ |  j t t t | j ƒ  d ƒ ƒ d S(	   s‹   
        A L{PKCS12} with only a certificate can be exported using
        L{PKCS12.export} and loaded again using L{load_pkcs12}.
        R   R!  R"  i   R#  i   Ni    (   R   R   R   R  R  RY   R  R`   R  R$  R   R   RI   RJ   R
   RK   R   R  (   R=   R%  R  RÂ   R&  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_cert_onlyû  s     	"(c         C   sË   t  ƒ  } | r: | j t t | ƒ ƒ } |  j | d ƒ n  | rk | j t t | ƒ ƒ } |  j | d ƒ n  | rŸ | j t t | ƒ f ƒ } |  j | d ƒ n  | rÇ | j	 | ƒ } |  j | d ƒ n  | S(   sx   
        Generate a PKCS12 object with components from PEM.  Verify that the set
        functions return None.
        N(
   R   R  R   R   RY   R`   R  R   R  R  (   R=   t   cert_pemt   key_pemt   ca_pemt   friendly_nameR  t   ret(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt
   gen_pkcs12  s    	t    c   	   	   C   sÜ   | rF t  | d d d d d | | Œ } |  j | t | ƒ | ƒ n  | r t  | d d d d d | d | Œ } |  j | t | ƒ | ƒ n  | rØ t  | d d d d d | d | Œ } |  j | t | ƒ | ƒ n  d	 S(
   so   
        Use openssl program to confirm three components are recoverable from a
        PKCS12 string.
        t   pkcs12s   -nocertss   -nodess   -passins   pass:s   -clcertss   -nokeyss   -cacertsN(   t   _runopensslRY   t   len(	   R=   t   p12_strR{   RÂ   Rô   R%  t   extrat   recovered_keyt   recovered_cert(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   check_recovery3  s    c         C   s¸   d } t  t } t | d d d d d | ƒ } t | | ƒ } |  j t | t ƒ ƒ t t | j	 ƒ  ƒ } |  j
 | t ƒ t t | j ƒ  ƒ } |  j
 | t  ƒ |  j
 d | j ƒ  ƒ d S(   sŸ   
        A PKCS12 string generated using the openssl command line can be loaded
        with L{load_pkcs12} and its components extracted and examined.
        t   whateverR0  s   -exports   -clcertss   -passouts   pass:N(   Rò   t   client_cert_pemR1  R   RI   RJ   R   R   R   R  RY   R   R  R`   R  (   R=   R%  R*   R3  R  R)  R*  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_load_pkcs12J  s    
c         C   sb   d } |  j  t t d | ƒ } |  j | j d d d d ƒ |  j t | j d d ƒ d ƒ d S(   sx   
        L{load_pkcs12} raises L{OpenSSL.crypto.Error} when passed a string
        which is not a PKCS12 dump.
        R8  s   fruit loopsi    s   asn1 encoding routinesi   N(   RS   R   R   RY   t   argsR2  (   R=   R%  t   e(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_load_pkcs12_garbage]  s    c         C   s  |  j  t t t ƒ } | j t t t ƒ ƒ | j t	 t t
 ƒ ƒ t t t ƒ } t t t ƒ } | j | g ƒ |  j d t | j ƒ  ƒ ƒ |  j | | j ƒ  d ƒ | j | | g ƒ |  j d t | j ƒ  ƒ ƒ |  j | | j ƒ  d ƒ |  j | | j ƒ  d ƒ d S(   sØ   
        L{PKCS12.set_certificate} replaces the certificate in a PKCS12 cluster.
        L{PKCS12.set_privatekey} replaces the private key.
        L{PKCS12.set_ca_certificates} replaces the CA certificates.
        i   i    i   N(   R.  R9  Rò   t   root_cert_pemR  R   R   t   server_cert_pemR  R   t   server_key_pemR  RY   R2  R  (   R=   R  t	   root_certt   client_cert(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_replaceh  s    c         C   sÖ   d } |  j  t t t ƒ } x´ t d ƒ d t d ƒ g D]— } | j | ƒ |  j | j ƒ  | ƒ | j	 d | d d d d ƒ } t
 | | ƒ } |  j | j ƒ  | j ƒ  ƒ |  j | d	 t d
 t d t d | ƒq7 Wd S(   sç   
        The I{friendlyName} of a PKCS12 can be set and retrieved via
        L{PKCS12.get_friendlyname} and L{PKCS12_set_friendlyname}, and a
        L{PKCS12} with a friendly name set can be dumped with L{PKCS12.export}.
        s$   Dogmeat[]{}!@#$%^&*()~`?/.,<>-_+=";:t   Serverliciouss   ###R!  R"  i   R#  i   R{   RÂ   Rô   R%  N(   R.  R?  R@  R>  R)   R`   R  RY   R  R$  R   R7  (   R=   R%  R  R,  R&  t   reloaded_p12(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_friendly_name|  s    "c         C   s²   |  j  t t t ƒ } d } | j d d d d d | ƒ } | j d d d d d d ƒ } | j d d d d	 ƒ } x< | | | g D]+ } |  j | d
 t d t d t d | ƒq Wd S(   sf   
        Test that missing, None, and '' passphrases are identical for PKCS12
        export.
        R/  R"  i   R#  i    R!  i   i	   i   R{   RÂ   Rô   R%  N(   R.  R9  Rò   R>  R$  R`   R7  (   R=   R  R%  t   dumped_p12_emptyt   dumped_p12_nonet   dumped_p12_nopwR&  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_various_empty_passphrases”  s    c         C   s<   |  j  t t t ƒ } | j d ƒ |  j d | j ƒ  ƒ d S(   sg   
        Passing C{None} to L{PKCS12.set_ca_certificates} removes all CA
        certificates.
        N(   R.  R?  R@  R>  R  R`   RY   R  (   R=   R  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_removing_ca_cert¤  s    c      
   C   sb   d } |  j  t t t ƒ } | j d d d | d d ƒ } |  j | d t d t d	 | d
 d ƒd S(   sb   
        Exporting a PKCS12 with a C{maciter} of C{-1} excludes the MAC
        entirely.
        s   Lake MichiganR#  iÿÿÿÿR!  R"  i   R{   RÂ   R%  R4  s	   -nomacverN(   s	   -nomacver(   R.  R?  R@  R>  R$  R7  (   R=   R%  R  R&  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_export_without_mac®  s    c         C   sz   d } |  j  t t t ƒ } | j d d d | d d ƒ } y) t | | ƒ } |  j t | t ƒ ƒ Wn t	 k
 ru n Xd S(   sQ   
        Loading a PKCS12 without a MAC does something other than crash.
        s   Lake MichiganR#  iÿÿÿÿR!  R"  i   N(
   R.  R?  R@  R>  R$  R   RI   RJ   R   R   (   R=   R%  R  R&  t   recovered_p12(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_load_without_mac»  s    c         C   sv   d } |  j  t t ƒ } | j g  ƒ |  j d	 | j ƒ  ƒ | j d | d d ƒ } |  j | d t d t d | ƒd S(
   sN   
        A PKCS12 with an empty CA certificates list can be exported.
        s   Hobie 18R!  R"  i   R{   RÂ   R%  N(    (   R.  R?  R@  R  RY   R  R$  R7  (   R=   R%  R  R&  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_zero_len_list_for_caÐ  s    c         C   sD   |  j  t t t ƒ } | j ƒ  } |  j | d t d t d d ƒd S(   sE   
        All the arguments to L{PKCS12.export} are optional.
        R{   RÂ   R%  R/  N(   R.  R?  R@  R>  R$  R7  (   R=   R  R&  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_export_without_argsÞ  s    c         C   s,   |  j  t t t ƒ } |  j t | j ƒ d S(   sc   
        L{PKCS12.export} raises an exception when a key and certificate
        mismatch.
        N(   R.  R?  Rò   R>  RS   R   R$  (   R=   R  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_key_cert_mismatchè  s    N(    (   Rw   Rx   Ry   R  R  R×   RG   R  R  R'  R(  R`   R.  R7  R:  R=  RC  RF  RJ  RK  RL  RN  RO  RP  RQ  (    (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR  ±  s*   
					#						
				
s   (\\*)"s   (\\+)\Zc         C   s&   t  j d t j d |  ƒ ƒ }  d |  S(   s<  
    Internal method for quoting a single command-line argument.

    @type: C{str}
    @param s: A single unquoted string to quote for something that is expecting
        cmd.exe-style quoting

    @rtype: C{str}
    @return: A cmd.exe-style quoted string

    @see: U{http://www.perlmonks.org/?node_id=764004}
    s   \1\1s   \1\1\\"s   "%s"(   t   _cmdLineQuoteRe2t   subt   _cmdLineQuoteRe(   t   s(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   cmdLineQuoteõ  s    c         C   s   d j  t t |  ƒ ƒ S(   s©  
    Quote an iterable of command-line arguments for passing to CreateProcess or
    a similar API.  This allows the list passed to C{reactor.spawnProcess} to
    match the child process's C{sys.argv} properly.

    @type arguments: C{iterable} of C{str}
    @param arguments: An iterable of unquoted arguments to quote

    @rtype: C{str}
    @return: A space-delimited string containing quoted versions of L{arguments}
    t    (   t   joint   mapRV  (   t	   arguments(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   quoteArguments  s    c         G   s£   t  j d k rK d d j g  | D] } d | j d d ƒ f ^ q ƒ } n d t | ƒ } t | d t d t d	 t ƒ} | j j	 |  ƒ | j j
 ƒ  | j j ƒ  S(
   s„   
    Run the command line openssl tool with the given arguments and write
    the given PEM to its stdin.  Not safe for quotes.
    t   posixs   openssl RW  s   '%s't   's   '\''t   shellt   stdint   stdout(   t   osR‹   RX  t   replaceR[  R   RC   R   R_  t   writet   closeR`  t   read(   R*   R;  t   argt   commandt   proc(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR1    s    	3t   FunctionTestsc           B   s°   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 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sC   
    Tests for free-functions in the L{OpenSSL.crypto} module.
    c         C   s   |  j  t t d t ƒ d S(   sX   
        L{load_privatekey} raises L{ValueError} if passed an unknown filetype.
        id   N(   RS   R   R   t   root_key_pem(   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt#   test_load_privatekey_invalid_format-  s    c         C   s    |  j  t t t t t ƒ  ƒ d S(   s€   
        L{load_privatekey} raises L{TypeError} if passed a passphrase that is
        neither a c{str} nor a callable.
        N(   RS   R_   R   R   t    encryptedPrivateKeyPEMPassphraseRm   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt,   test_load_privatekey_invalid_passphrase_type4  s    c         C   s   |  j  t t ƒ d S(   sn   
        L{load_privatekey} raises L{TypeError} if called with the wrong number
        of arguments.
        N(   RS   R_   R   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_load_privatekey_wrong_args?  s    c         C   s#   |  j  t t t t t d ƒ ƒ d S(   s‹   
        L{load_privatekey} raises L{OpenSSL.crypto.Error} when it is passed an
        encrypted PEM and an incorrect passphrase.
        t   quackN(   RS   R   R   R   t   encryptedPrivateKeyPEMR)   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt$   test_load_privatekey_wrongPassphraseG  s    c         C   s,   t  t t t ƒ } |  j t | t ƒ ƒ d S(   s~   
        L{load_privatekey} can create a L{PKey} object from an encrypted PEM
        string if given the passphrase.
        N(   R   R   Rp  Rl  RI   RJ   R	   (   R=   R{   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_load_privatekey_passphraseQ  s    	c            s?   g  ‰  ‡  f d †  } |  j  t t t t | ƒ |  j ˆ  ƒ d S(   s·   
        L{load_privatekey} raises L{OpenSSL.crypto.Error} when it is passed an
        encrypted PEM and a passphrase callback which returns an incorrect
        passphrase.
        c             s   ˆ  j  d  ƒ d S(   NRo  (   t   appendR`   (   R˜   (   t   called(    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   cbc  s    N(   RS   R   R   R   Rp  RI   (   R=   Ru  (    (   Rt  s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt,   test_load_privatekey_wrongPassphraseCallback\  s    c            sT   g  ‰  ‡  f d †  } t  t t | ƒ } |  j t | t ƒ ƒ |  j ˆ  t g ƒ d S(   s°   
        L{load_privatekey} can create a L{PKey} object from an encrypted PEM
        string if given a passphrase callback which returns the correct
        password.
        c            s   ˆ  j  |  ƒ t S(   N(   Rs  Rl  (   t   writing(   Rt  (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRu  s  s    N(   R   R   Rp  RI   RJ   R	   RY   RL   (   R=   Ru  R{   (    (   Rt  s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt'   test_load_privatekey_passphraseCallbackl  s
    c         C   s&   d „  } |  j  t t t t | ƒ d S(   s  
        An exception raised by the passphrase callback passed to
        L{load_privatekey} causes L{OpenSSL.crypto.Error} to be raised.

        This isn't as nice as just letting the exception pass through.  The
        behavior might be changed to that eventually.
        c         S   s   t  d ƒ ‚ d  S(   Ns   This is not working.(   t   RuntimeError(   t   ignored(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   brokenƒ  s    N(   RS   R   R   R   Rp  (   R=   R{  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt)   test_load_privatekey_passphrase_exception{  s
    	c         C   s   |  j  t t ƒ d S(   sn   
        L{dump_privatekey} raises L{TypeError} if called with the wrong number
        of arguments.
        N(   RS   R_   R   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_dump_privatekey_wrong_args‹  s    c         C   s9   t  ƒ  } | j t d ƒ |  j t t t | d d ƒ d S(   sm   
        L{dump_privatekey} raises L{ValueError} if called with an unrecognized
        cipher name.
        i   t   zippersR!  N(   R   R1   R   RS   R   R   R   (   R=   R{   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt#   test_dump_privatekey_unknown_cipher“  s
    	c         C   s<   t  ƒ  } | j t d ƒ |  j t t t | d t ƒ  ƒ d S(   s†   
        L{dump_privatekey} raises L{TypeError} if called with a passphrase which
        is neither a C{str} nor a callable.
        i   t   blowfishN(   R   R1   R   RS   R_   R   R   Rm   (   R=   R{   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt,   test_dump_privatekey_invalid_passphrase_typeŸ  s
    	c         C   s3   t  ƒ  } | j t d ƒ |  j t t d | ƒ d S(   sj   
        L{dump_privatekey} raises L{ValueError} if called with an unrecognized
        filetype.
        i   id   N(   R   R1   R   RS   R   R   (   R=   R{   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt%   test_dump_privatekey_invalid_filetype«  s    	c         C   sª   t  d ƒ } t t t ƒ } t t | d | ƒ } |  j t | t ƒ ƒ t t | | ƒ } |  j t | t ƒ ƒ |  j	 | j
 ƒ  | j
 ƒ  ƒ |  j	 | j ƒ  | j ƒ  ƒ d S(   sU   
        L{dump_privatekey} writes an encrypted PEM when given a passphrase.
        R^   R€  N(   R)   R   R   R  R   RI   RJ   R(   R	   RY   RK   R|   (   R=   R!  R{   R*   t	   loadedKey(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_dump_privatekey_passphraseµ  s    c   
      C   sÒ   t  t } t t | ƒ } t t | ƒ } |  j | t  ƒ t t | ƒ } t | d d d ƒ } |  j | | ƒ t t | ƒ } t t | ƒ } |  j | t  ƒ t t | ƒ } t | d d d ƒ }	 |  j | |	 ƒ d S(   s@   
        L{dump_certificate} writes PEM, DER, and text.
        R6   s   -outformt   DERs   -noouts   -textN(	   R  R  R   R   R   RY   R   R1  R   (
   R=   R×   RÂ   t
   dumped_pemt
   dumped_dert   good_dert   cert2t   dumped_pem2t   dumped_textt	   good_text(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_dump_certificateÃ  s    
c   	      C   sÈ   t  t t ƒ } t t | ƒ } |  j | t ƒ t t | ƒ } t | d d d ƒ } |  j | | ƒ t  t | ƒ } t t | ƒ } |  j | t ƒ t t | ƒ } t | d d d ƒ } |  j | | ƒ d S(   sA   
        L{dump_privatekey} writes a PEM, DER, and text.
        t   rsas   -outformR…  s   -noouts   -textN(   R   R   R  R   RY   R   R1  R   (	   R=   R{   R†  R‡  Rˆ  t   key2RŠ  R‹  RŒ  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_dump_privatekeyÖ  s    c   	      C   sÞ   t  t t ƒ } t t | ƒ } |  j | t ƒ t t | ƒ } t | d d d ƒ } |  j | | ƒ t  t | ƒ } t t | ƒ } |  j | t ƒ t t | ƒ } t | d d d ƒ } |  j | | ƒ |  j t	 t d | ƒ d S(   sJ   
        L{dump_certificate_request} writes a PEM, DER, and text.
        R2   s   -outformR…  s   -noouts   -textid   N(
   R   R   t   cleartextCertificateRequestPEMR   RY   R   R1  R   RS   R   (	   R=   R2   R†  R‡  Rˆ  t   req2RŠ  R‹  RŒ  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_dump_certificate_requesté  s    c            sÕ   t  d ƒ ‰  g  ‰ ‡ ‡  f d †  } t t t ƒ } t t | d | ƒ } |  j t | t ƒ ƒ |  j ˆ t	 g ƒ t t | ˆ  ƒ } |  j t | t
 ƒ ƒ |  j | j ƒ  | j ƒ  ƒ |  j | j ƒ  | j ƒ  ƒ d S(   s€   
        L{dump_privatekey} writes an encrypted PEM when given a callback which
        returns the correct passphrase.
        R^   c            s   ˆ  j  |  ƒ ˆ S(   N(   Rs  (   Rw  (   Rt  R!  (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRu    s    R€  N(   R)   R   R   R  R   RI   RJ   R(   RY   RC   R	   RK   R|   (   R=   Ru  R{   R*   Rƒ  (    (   R!  Rt  s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt'   test_dump_privatekey_passphraseCallbackü  s    c         C   s)   t  t t ƒ } |  j t | t ƒ ƒ d S(   sm   
        L{load_pkcs7_data} accepts a PKCS#7 string and returns an instance of
        L{PKCS7Type}.
        N(   R   R   t	   pkcs7DataRI   RJ   R   (   R=   t   pkcs7(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_load_pkcs7_data  s    (   Rw   Rx   Ry   Rk  Rm  Rn  Rq  Rr  Rv  Rx  R|  R}  R  R  R‚  R„  R  R  R“  R”  R—  (    (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRi  (  s&   				
								
					t
   PKCS7Testsc           B   sz   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 RS(   s!   
    Tests for L{PKCS7Type}.
    c         C   s-   |  j  t t t ƒ ƒ |  j t j d ƒ d S(   s0   
        L{PKCS7Type} is a type object.
        t   PKCS7N(   RI   RJ   R   RK   RY   Rw   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRG     s    c         C   s)   t  t t ƒ } |  j t | j d ƒ d S(   sg   
        L{PKCS7Type.type_is_signed} raises L{TypeError} if called with any
        arguments.
        N(   R   R   R•  RS   R_   t   type_is_signedR`   (   R=   R–  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_type_is_signed_wrong_args+  s    c         C   s&   t  t t ƒ } |  j | j ƒ  ƒ d S(   ss   
        L{PKCS7Type.type_is_signed} returns C{True} if the PKCS7 object is of
        the type I{signed}.
        N(   R   R   R•  RI   Rš  (   R=   R–  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_type_is_signed4  s    c         C   s)   t  t t ƒ } |  j t | j d ƒ d S(   sj   
        L{PKCS7Type.type_is_enveloped} raises L{TypeError} if called with any
        arguments.
        N(   R   R   R•  RS   R_   t   type_is_envelopedR`   (   R=   R–  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt!   test_type_is_enveloped_wrong_args=  s    c         C   s&   t  t t ƒ } |  j | j ƒ  ƒ d S(   s~   
        L{PKCS7Type.type_is_enveloped} returns C{False} if the PKCS7 object is
        not of the type I{enveloped}.
        N(   R   R   R•  RV   R  (   R=   R–  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_type_is_envelopedF  s    c         C   s)   t  t t ƒ } |  j t | j d ƒ d S(   ss   
        L{PKCS7Type.type_is_signedAndEnveloped} raises L{TypeError} if called
        with any arguments.
        N(   R   R   R•  RS   R_   t   type_is_signedAndEnvelopedR`   (   R=   R–  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt*   test_type_is_signedAndEnveloped_wrong_argsO  s    c         C   s&   t  t t ƒ } |  j | j ƒ  ƒ d S(   s’   
        L{PKCS7Type.type_is_signedAndEnveloped} returns C{False} if the PKCS7
        object is not of the type I{signed and enveloped}.
        N(   R   R   R•  RV   R   (   R=   R–  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_type_is_signedAndEnvelopedX  s    c         C   s&   t  t t ƒ } |  j | j ƒ  ƒ d S(   sq   
        L{PKCS7Type.type_is_data} returns C{False} if the PKCS7 object is not of
        the type data.
        N(   R   R   R•  RV   t   type_is_data(   R=   R–  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_type_is_dataa  s    c         C   s)   t  t t ƒ } |  j t | j d ƒ d S(   se   
        L{PKCS7Type.type_is_data} raises L{TypeError} if called with any
        arguments.
        N(   R   R   R•  RS   R_   R£  R`   (   R=   R–  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_type_is_data_wrong_argsj  s    c         C   s)   t  t t ƒ } |  j t | j d ƒ d S(   sf   
        L{PKCS7Type.get_type_name} raises L{TypeError} if called with any
        arguments.
        N(   R   R   R•  RS   R_   t   get_type_nameR`   (   R=   R–  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_type_name_wrong_argss  s    c         C   s/   t  t t ƒ } |  j | j ƒ  t d ƒ ƒ d S(   sS   
        L{PKCS7Type.get_type_name} returns a C{str} giving the type name.
        s   pkcs7-signedDataN(   R   R   R•  RA   R¦  R)   (   R=   R–  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_type_name|  s    c         C   s)   t  t t ƒ } |  j t t | d ƒ d S(   sœ   
        If an attribute other than one of the methods tested here is accessed on
        an instance of L{PKCS7Type}, L{AttributeError} is raised.
        R^   N(   R   R   R•  RS   t   AttributeErrorRµ   (   R=   R–  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_attribute„  s    (   Rw   Rx   Ry   RG   R›  Rœ  Rž  RŸ  R¡  R¢  R¤  R¥  R§  R¨  Rª  (    (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR˜    s   																				t   NetscapeSPKITestsc           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s3   
    Tests for L{OpenSSL.crypto.NetscapeSPKI}.
    c         C   s   t  ƒ  S(   sJ   
        Return a new L{NetscapeSPKI} for use with signing tests.
        (   R#   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR¬   ’  s    c         C   s$   |  j  t t ƒ |  j t d ƒ d S(   s‘   
        L{NetscapeSPKI} and L{NetscapeSPKIType} refer to the same type object
        and can be used to create instances of that type.
        R#   N(   RE   R#   R$   RF   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRG   ™  s    c         C   s#   t  ƒ  } |  j t | t ƒ ƒ d S(   sM   
        L{NetscapeSPKI} returns an instance of L{NetscapeSPKIType}.
        N(   R#   RI   RJ   R$   (   R=   t   nspki(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRO   ¢  s    	c            s&   t  ƒ  ‰  |  j t ‡  f d †  ƒ d S(   s„   
        Accessing a non-existent attribute of a L{NetscapeSPKI} instance causes
        an L{AttributeError} to be raised.
        c              s   ˆ  j  S(   N(   R^   (    (   R¬  (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   <lambda>°  s    N(   R#   RS   R©  (   R=   (    (   R¬  s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_invalid_attributeª  s    	c         C   s/   t  ƒ  } | j ƒ  } |  j t | t ƒ ƒ d S(   sV   
        L{NetscapeSPKI.b64_encode} encodes the certificate to a base64 blob.
        N(   R#   t
   b64_encodeRI   RJ   R(   (   R=   R¬  t   blob(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_b64_encode³  s    	(   Rw   Rx   Ry   R¬   RG   RO   R®  R±  (    (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR«  Ž  s   						t   RevokedTestsc           B   sM   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   s-   
    Tests for L{OpenSSL.crypto.Revoked}
    c         C   s   t  ƒ  } |  j t | t  ƒ ƒ |  j t | ƒ t  ƒ |  j | j ƒ  t d ƒ ƒ |  j | j ƒ  d ƒ |  j | j	 ƒ  d ƒ d S(   sc   
        Confirm we can create L{OpenSSL.crypto.Revoked}.  Check
        that it is empty.
        t   00N(
   R!   RI   RJ   RA   RK   t
   get_serialR)   t   get_rev_dateR`   t
   get_reason(   R=   t   revoked(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRO   Á  s    	c         C   s=   |  j  t t d ƒ |  j  t t d ƒ |  j  t t d ƒ d S(   sv   
        Calling L{OpenSSL.crypto.Revoked} with any arguments results
        in a L{TypeError} being raised.
        i   R^   N(   RS   R_   R!   R`   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_construction_wrong_argsÎ  s    c         C   sý   t  ƒ  } | j t d ƒ ƒ } |  j | d	 ƒ | j ƒ  } |  j | t d ƒ ƒ | j t d ƒ ƒ | j ƒ  } |  j | t d ƒ ƒ |  j t | j t d ƒ ƒ |  j t | j d ƒ |  j t | j d ƒ |  j t | j d	 ƒ |  j t | j d ƒ d	 S(
   s“   
        Confirm we can set and get serial numbers from
        L{OpenSSL.crypto.Revoked}.  Confirm errors are handled
        with grace.
        t   10bt   010Bt   31pppt   31t   pqrstid   i   R/  N(	   R!   t
   set_serialR)   RA   R`   R´  RS   R   R_   (   R=   R·  R-  t   ser(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_serialØ  s    	c         C   s   t  ƒ  } | j ƒ  } |  j | d ƒ t t j ƒ  j d ƒ ƒ } | j | ƒ } |  j	 | d ƒ | j ƒ  } |  j	 | | ƒ d S(   s•   
        Confirm we can set and get revocation dates from
        L{OpenSSL.crypto.Revoked}.  Confirm errors are handled
        with grace.
        s   %Y%m%d%H%M%SZN(
   R!   Rµ  RA   R`   R)   R   R9   R:   t   set_rev_dateRY   (   R=   R·  t   dateR9   R-  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt	   test_dateï  s    	c         C   sÛ   t  ƒ  } x¨ | j ƒ  D]š } x‘ t d ƒ D]ƒ } | j | ƒ } |  j | d ƒ | j ƒ  } |  j | j ƒ  j t	 d ƒ t	 d ƒ ƒ | j ƒ  j t	 d ƒ t	 d ƒ ƒ ƒ | } q) Wq W| j d ƒ |  j
 | j ƒ  d ƒ d S(   sÄ   
        Confirm we can set and get revocation reasons from
        L{OpenSSL.crypto.Revoked}.  The "get" need to work
        as "set".  Likewise, each reason of all_reasons() must work.
        i   RW  R/  N(   R!   t   all_reasonst   ranget
   set_reasonRA   R`   R¶  t   lowerRb  R)   RY   (   R=   R·  t   rt   xR-  t   reason(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_reason 	  s    	!%c         C   s?   t  ƒ  } |  j t | j d ƒ |  j t | j t d ƒ ƒ d S(   sÎ   
        Calling L{OpenSSL.crypto.Revoked.set_reason} with other than
        one argument, or an argument which isn't a valid reason,
        results in L{TypeError} or L{ValueError} being raised.
        id   t   blueN(   R!   RS   R_   RÆ  R   R)   (   R=   R·  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_set_reason_wrong_arguments	  s    	c         C   sO   t  ƒ  } |  j t | j d ƒ |  j t | j d ƒ |  j t | j d ƒ d S(   s   
        Calling L{OpenSSL.crypto.Revoked.get_reason} with any
        arguments results in L{TypeError} being raised.
        i   R^   N(   R!   RS   R_   R¶  R`   (   R=   R·  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_reason_wrong_arguments 	  s    	(
   Rw   Rx   Ry   RO   R¸  RÀ  RÃ  RË  RÍ  RÎ  (    (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR²  ½  s   		
				t   CRLTestsc           B   s¡   e  Z d  Z e e e ƒ Z e e 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 RS(   s)   
    Tests for L{OpenSSL.crypto.CRL}
    c         C   s9   t  ƒ  } |  j t | t  ƒ ƒ |  j | j ƒ  d ƒ d S(   s^   
        Confirm we can create L{OpenSSL.crypto.CRL}.  Check
        that it is empty
        N(   R    RI   RJ   RY   t   get_revokedR`   (   R=   t   crl(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRO   3	  s    	c         C   s=   |  j  t t d ƒ |  j  t t d ƒ |  j  t t d ƒ d S(   s|   
        Calling L{OpenSSL.crypto.CRL} with any number of arguments
        results in a L{TypeError} being raised.
        i   R/  N(   RS   R_   R    R`   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyR¸  =	  s    c         C   sz  t  ƒ  } t ƒ  } t t j ƒ  j d ƒ ƒ } | j | ƒ | j t d ƒ ƒ | j t d ƒ ƒ | j	 | ƒ | j
 |  j |  j d d ƒ} t | d d d ƒ } | j t d	 ƒ ƒ | j t d
 ƒ ƒ | j t d ƒ ƒ | j
 |  j |  j t ƒ } t | d d d d d ƒ } | j t d	 ƒ ƒ | j t d
 ƒ ƒ | j t d ƒ ƒ | j
 |  j |  j d t ƒ} |  j | | ƒ d S(   sÀ   
        Use python to create a simple CRL with a revocation, and export
        the CRL in formats of PEM, DER and text.  Those outputs are verified
        with the openssl program.
        s   %Y%m%d%H%M%SZt   3abt
   sUpErSeDEdR/   i   RÑ  s   -noouts   -texts   Serial Number: 03ABt
   Supersededs:   Issuer: /C=US/ST=IL/L=Chicago/O=Testing/CN=Testing Root CAs   -informR…  RK   N(   R    R!   R)   R   R9   R:   RÁ  R¾  RÆ  t   add_revokedR$  RÂ   R0   R1  t   indexR   R   RY   (   R=   RÑ  R·  R9   t
   dumped_crlRe   R‹  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_exportG	  s&    		c         C   sF   t  ƒ  } t ƒ  } | j d | ƒ |  j t | j ƒ  d t ƒ ƒ d S(   st   
        L{OpenSSL.CRL.add_revoked} accepts its single argument as the
        I{revoked} keyword argument.
        R·  i    N(   R    R!   RÕ  RI   RJ   RÐ  (   R=   RÑ  R·  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_add_revoked_keywordh	  s    		c         C   sé   t  ƒ  } |  j t | j ƒ |  j t | j |  j ƒ |  j t | j |  j |  j t d d ƒ |  j t | j d |  j t d ƒ |  j t | j |  j d t d ƒ |  j t | j |  j |  j d d ƒ |  j t | j |  j t d ƒ d S(   s  
        Calling L{OpenSSL.CRL.export} with fewer than two or more than
        four arguments, or with arguments other than the certificate,
        private key, integer file type, and integer number of days it
        expects, results in a L{TypeError} being raised.
        i
   R^   N(   R    RS   R_   R$  RÂ   R0   R   R`   (   R=   RÑ  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_export_wrong_argss	  s    	(""%c         C   s2   t  ƒ  } |  j t | j |  j |  j d d ƒ d S(   s»   
        Calling L{OpenSSL.CRL.export} with a file type other than
        L{FILETYPE_PEM}, L{FILETYPE_ASN1}, or L{FILETYPE_TEXT} results
        in a L{ValueError} being raised.
        id   i
   N(   R    RS   R   R$  RÂ   R0   (   R=   RÑ  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_export_unknown_filetype…	  s    	c         C   s[  t  ƒ  } t ƒ  } t t j ƒ  j d ƒ ƒ } | j | ƒ | j t d ƒ ƒ | j | ƒ | j t d ƒ ƒ | j	 t d ƒ ƒ | j | ƒ | j
 ƒ  } |  j t | ƒ d ƒ |  j t | d ƒ t ƒ |  j t | d ƒ t ƒ |  j | d j ƒ  t d ƒ ƒ |  j | d j ƒ  t d	 ƒ ƒ |  j | d j ƒ  | ƒ |  j | d j ƒ  | ƒ d
 S(   s£   
        Use python to create a simple CRL with two revocations.
        Get back the L{Revoked} using L{OpenSSL.CRL.get_revoked} and
        verify them.
        s   %Y%m%d%H%M%SZRÒ  t   100RÓ  i   i    i   t   03ABt   0100N(   R    R!   R)   R   R9   R:   RÁ  R¾  RÕ  RÆ  RÐ  RY   R2  RK   R´  Rµ  (   R=   RÑ  R·  R9   t   revs(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_revoked	  s"    		  c         C   sk   t  ƒ  } |  j t | j d ƒ |  j t | j d ƒ |  j t | j d ƒ |  j t | j d d d ƒ d S(   sw   
        Calling L{OpenSSL.CRL.get_revoked} with any arguments results
        in a L{TypeError} being raised.
        i   R/  N(   R    RS   R_   RÐ  R`   (   R=   RÑ  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_get_revoked_wrong_argsª	  s
    	c         C   sR   t  ƒ  } |  j t | j ƒ |  j t | j d d ƒ |  j t | j d d ƒ d S(   s   
        Calling L{OpenSSL.CRL.add_revoked} with other than one
        argument results in a L{TypeError} being raised.
        i   i   R^   R~   N(   R    RS   R_   RÕ  (   R=   RÑ  (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_add_revoked_wrong_args¶	  s    	c         C   so  t  t t ƒ } | j ƒ  } |  j t | ƒ d ƒ |  j | d j ƒ  t d ƒ ƒ |  j | d j ƒ  d
 ƒ |  j | d j ƒ  t d ƒ ƒ |  j | d j ƒ  t d ƒ ƒ t
 t d d d	 ƒ } t  t | ƒ } | j ƒ  } |  j t | ƒ d ƒ |  j | d j ƒ  t d ƒ ƒ |  j | d j ƒ  d
 ƒ |  j | d j ƒ  t d ƒ ƒ |  j | d j ƒ  t d ƒ ƒ d
 S(   sm   
        Load a known CRL and inspect its revocations.  Both
        PEM and DER formats are loaded.
        i   i    RÝ  i   RÞ  RÔ  RÑ  s   -outformR…  N(   R"   R   t   crlDataRÐ  RY   R2  R´  R)   R¶  R`   R1  R   (   R=   RÑ  Rß  R¦   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_load_crlÁ	  s         c         C   s@   |  j  t t ƒ |  j  t t t ƒ |  j  t t t t d ƒ d S(   s‚   
        Calling L{OpenSSL.crypto.load_crl} with other than two
        arguments results in a L{TypeError} being raised.
        N(   RS   R_   R"   R   Rã  R`   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_load_crl_wrong_argsØ	  s    c         C   s   |  j  t t d t ƒ d S(   sn   
        Calling L{OpenSSL.crypto.load_crl} with an unknown file type
        raises a L{ValueError}.
        id   N(   RS   R   R"   Rã  (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_load_crl_bad_filetypeâ	  s    c         C   s   |  j  t t t d ƒ d S(   sƒ   
        Calling L{OpenSSL.crypto.load_crl} with file data which can't
        be loaded raises a L{OpenSSL.crypto.Error}.
        s   hello, worldN(   RS   R   R"   R   (   R=   (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_load_crl_bad_dataê	  s    (   Rw   Rx   Ry   R   R   R  RÂ   R   R  R0   RO   R¸  RØ  RÙ  RÚ  RÛ  Rà  Rá  Râ  Rä  Rå  Ræ  Rç  (    (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRÏ  ,	  s    	
	
	!			
					
	t   SignVerifyTestsc           B   s   e  Z d  Z d „  Z RS(   sH   
    Tests for L{OpenSSL.crypto.sign} and L{OpenSSL.crypto.verify}.
    c      	   C   sð   t  d ƒ } t t t ƒ } t t t ƒ } t t t ƒ } x{ d d g D]m } t | | | ƒ } t | | | | ƒ |  j	 t
 t | | | | ƒ |  j	 t
 t | | | t  d ƒ | ƒ qF W|  j	 t t | | d ƒ |  j	 t t | | | d ƒ d S(   sX   
        L{sign} generates a cryptographic signature which L{verify} can check.
        s6  It was a bright cold day in April, and the clocks were striking thirteen. Winston Smith, his chin nuzzled into his breast in an effort to escape the vile wind, slipped quickly through the glass doors of Victory Mansions, though not quickly enough to prevent a swirl of gritty dust from entering along with him.Ré   Rb   t   tainteds   strange-digestN(   R)   R   R   Rj  R   R>  R?  R%   R&   RS   R   R   (   R=   t   contentt   priv_keyt	   good_certt   bad_certRê   t   sig(    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   test_sign_verifyö	  s     	(   Rw   Rx   Ry   Rï  (    (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyRè  ò	  s   t   __main__(T   Ry   t   unittestR    Ra  t   ret
   subprocessR   R   R   R   t   OpenSSL.cryptoR   R   R   R   R	   R
   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R    R!   R"   R#   R$   R%   R&   t   OpenSSL.test.utilR'   R(   R)   R+   R,   R>  Rj  R?  R@  R9  Rò   R  R  R‘  Rp  Rl  R•  Rã  R.   Rz   R„   Rª   R·   RÀ   R  t   compileRT  RR  RV  R[  R1  Ri  R˜  R«  R²  RÏ  Rè  Rw   (    (    (    s<   /usr/lib/python2.7/dist-packages/OpenSSL/test/test_crypto.pyt   <module>   s†   ("											ëmÆBoÿ æÿ C			òt/oÆ-