ok

Mini Shell

Direktori : /proc/thread-self/root/proc/thread-self/root/usr/lib64/python2.7/site-packages/M2Crypto/
Upload File :
Current File : //proc/thread-self/root/proc/thread-self/root/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyo

�

�1Mc@s�dZddlZddlZddlZddlZdefd��YZeje�ddd��YZdefd��YZ	ej
d	�Zd
�Zej
d�Zej
d�Zej
d
�Zej
d�Zej
d�Zej
d�ZdS(s�
    M2Crypto wrapper for OpenSSL DSA API.

    Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.

    Portions created by Open Source Applications Foundation (OSAF) are
    Copyright (C) 2004 OSAF. All Rights Reserved.
i����NtDSAErrorcBseZRS((t__name__t
__module__(((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyR
stDSAcBs�eZdZejZdd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zdejd�Zdejd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(sA
    This class is a context supporting DSA key and parameter
    values, signing and verifying.
    
    Simple example::
    
        from M2Crypto import EVP, DSA, util
        
        message = 'Kilroy was here!'
        md = EVP.MessageDigest('sha1')
        md.update(message)        
        digest = md.final()
        
        dsa = DSA.gen_params(1024)
        dsa.gen_key()
        r, s = dsa.sign(digest)
        good = dsa.verify(digest, r, s)
        if good:
            print '  ** success **'
        else:
            print '  ** verification failed **'
    icCs||_||_dS(sI
        Use one of the factory functions to create an instance.
        N(tdsat_pyfree(tselfRR((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyt__init__,s	cCs)t|dd�r%|j|j�ndS(NRi(tgetattrtm2_dsa_freeR(R((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyt__del__4scCstj|j�S(sp
        Return the key length.
    
        @rtype:   int
        @return:  the DSA key length in bits
        (tm2t
dsa_keylenR(R((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyt__len__8scCs9|dkr/ttd|f�}||j�St�dS(	s5
        Return specified DSA parameters and key values.
    
        @type  name: str
        @param name: name of variable to be returned.  Must be 
                     one of 'p', 'q', 'g', 'pub', 'priv'.
        @rtype:      str
        @return:     value of specified variable (a "byte string")
        tptqtgtpubtprivs
dsa_get_%sN(RRRRR(RRRtAttributeError(Rtnametmethod((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyt__getattr__Bs

cCsG|dkrtd��n(|d	kr6td��n
||j|<dS(
NRRRsset (p, q, g) via set_params()RRs"generate (pub, priv) via gen_key()(RRR(spubspriv(Rt__dict__(RRtvalue((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyt__setattr__Ss
cCs=tj|j|�tj|j|�tj|j|�dS(s�
        Set new parameters.
        
        @warning: This does not change the private key, so it may be
                  unsafe to use this method. It is better to use
                  gen_params function to create a new DSA object.
        N(Rt	dsa_set_pRt	dsa_set_qt	dsa_set_g(RRRR((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyt
set_params[scCstj|j�dS(s&
        Generate a key pair.
        N(Rtdsa_gen_keyR(R((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pytgen_keygscCs;tj|d�}tj|j|j��}|j�|S(s�
        Save the DSA parameters to a file.
    
        @type  filename: str
        @param filename: Save the DSA parameters to this file.
        @return:         1 (true) if successful
        twb(tBIOtopenfileRtdsa_write_params_bioRt_ptrtclose(Rtfilenametbiotret((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pytsave_paramsns
cCstj|j|j��S(s�
        Save DSA parameters to a BIO object.
    
        @type  bio: M2Crypto.BIO object
        @param bio: Save DSA parameters to this object.
        @return:    1 (true) if successful
        (RR#RR$(RR'((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pytsave_params_bio{staes_128_cbccCs5tj|d�}|j|||�}|j�|S(sU
        Save the DSA key pair to a file.
    
        @type  filename: str
        @param filename: Save the DSA key pair to this file.
        @type  cipher:   str
        @param cipher:   name of symmetric key algorithm and mode
                         to encrypt the private key.
        @return:         1 (true) if successful
        R (R!R"tsave_key_bioR%(RR&tciphertcallbackR'R(((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pytsave_key�s
cCs�|dkr(tj|j|j�|�Stt|d�}|dkrYtd|��n	|�}tj|j|j�||�SdS(s[
        Save DSA key pair to a BIO object.
    
        @type  bio:    M2Crypto.BIO object
        @param bio:    Save DSA parameters to this object.
        @type  cipher: str
        @param cipher: name of symmetric key algorithm and mode
                       to encrypt the private key.
        @return:       1 (true) if successful
        sno such cipher: %sN(tNoneRtdsa_write_key_bio_no_cipherRR$RRtdsa_write_key_bio(RR'R-R.tciph((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyR,�s	cCs/tj|d�}|j|�}|j�|S(s�
        Save the DSA public key (with parameters) to a file.
    
        @type  filename: str
        @param filename: Save DSA public key (with parameters) 
                         to this file.
        @return:         1 (true) if successful
        R (R!R"tsave_pub_key_bioR%(RR&R'R(((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pytsave_pub_key�s	
cCstj|j|j��S(s�
        Save DSA public key (with parameters) to a BIO object.
    
        @type  bio: M2Crypto.BIO object
        @param bio: Save DSA public key (with parameters) 
                    to this object.
        @return:  1 (true) if successful
        (Rtdsa_write_pub_key_bioRR$(RR'((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyR4�s	cCstj|j|�S(sK
        Sign the digest.
    
        @type  digest: str
        @param digest: SHA-1 hash of message (same as output 
                       from MessageDigest, a "byte string")
        @rtype:        tuple
        @return:       DSA signature, a tuple of two values, r and s,
                       both "byte strings".
        (Rtdsa_signR(Rtdigest((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pytsign�scCstj|j|||�S(s
        Verify a newly calculated digest against the signature 
        values r and s.
    
        @type  digest: str
        @param digest: SHA-1 hash of message (same as output 
                       from MessageDigest, a "byte string")
        @type  r:      str
        @param r:      r value of the signature, a "byte string"
        @type  s:      str
        @param s:      s value of the signature, a "byte string"
        @rtype:        int
        @return:       1 (true) if verify succeeded, 0 if failed
        (Rt
dsa_verifyR(RR8trts((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pytverify�scCstj|j|�S(N(Rt
dsa_sign_asn1R(RR8((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyt	sign_asn1�scCstj|j||�S(N(Rtdsa_verify_asn1R(RR8tblob((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pytverify_asn1�scCstj|j�S(s�
        Check to be sure the DSA object has a valid private key.
    
        @rtype:   int
        @return:  1 (true) if a valid private key
        (Rt
dsa_check_keyR(R((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyt	check_key�s(RRt__doc__Rtdsa_freeR	RR
R
RRRRR)R*tutiltpassphrase_callbackR/R,R5R4R9R=R?RBRD(((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyRs,			
					
	
						tDSA_pubcBs8eZdZd�ZeZd�ZejZej	Z
RS(s�
    This class is a DSA context that only supports a public key 
    and verification.  It does NOT support a private key or 
    signing.
    
    cGstd��dS(Ns!DSA_pub object has no private key(R(Rtargv((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyR9scCstj|j�S(N(Rtdsa_check_pub_keyR(R((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyRDs(RRRER9R?RDRR5R/R4R,(((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyRI�s			cCs:tj||�}|dkr-td��nt|d�S(s�
    Factory function that generates DSA parameters and 
    instantiates a DSA object from the output.

    @type  bits: int
    @param bits: The length of the prime to be generated. If 
                 'bits' < 512, it is set to 512.
    @type  callback: function
    @param callback: A Python callback object that will be 
                 invoked during parameter generation; it usual 
                 purpose is to provide visual feedback.
    @rtype:   DSA
    @return:  instance of DSA.
    s!problem generating DSA parametersiN(Rtdsa_generate_parametersR0RR(tbitsR.R((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyt
gen_paramsscCsItj�}tj||�tj||�tj||�t|d�S(s8
    Factory function that instantiates a DSA object with DSA
    parameters.

    @type  p: str
    @param p: value of p, a "byte string"
    @type  q: str
    @param q: value of q, a "byte string"
    @type  g: str
    @param g: value of g, a "byte string"
    @rtype:   DSA
    @return:  instance of DSA.
    i(Rtdsa_newRRRR(RRRR((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyR&s
cCs,tj|�}t||�}|j�|S(s
    Factory function that instantiates a DSA object with DSA 
    parameters from a file.

    @type  file:     str
    @param file:     Names the file (a path) that contains the PEM 
                     representation of the DSA parameters. 
    @type  callback: A Python callable
    @param callback: A Python callback object that will be 
                     invoked if the DSA parameters file is 
                     passphrase-protected.
    @rtype:          DSA
    @return:         instance of DSA.
    (R!R"tload_params_bioR%(tfileR.R'R(((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pytload_params:s
cCs@tj|j�|�}|dkr3td��nt|d�S(s
    Factory function that instantiates a DSA object with DSA
    parameters from a M2Crypto.BIO object.

    @type  bio:      M2Crypto.BIO object
    @param bio:      Contains the PEM representation of the DSA 
                     parameters. 
    @type  callback: A Python callable
    @param callback: A Python callback object that will be 
                     invoked if the DSA parameters file is 
                     passphrase-protected.
    @rtype:          DSA
    @return:         instance of DSA.
    sproblem loading DSA parametersiN(Rtdsa_read_paramsR$R0RR(R'R.R((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyRPOscCs,tj|�}t||�}|j�|S(s�
    Factory function that instantiates a DSA object from a
    PEM encoded DSA key pair.

    @type  file:     str
    @param file:     Names the file (a path) that contains the PEM 
                     representation of the DSA key pair. 
    @type  callback: A Python callable
    @param callback: A Python callback object that will be 
                     invoked if the DSA key pair is 
                     passphrase-protected.
    @rtype:          DSA
    @return:         instance of DSA.
    (R!R"tload_key_bioR%(RQR.R'R(((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pytload_keyds
cCs:tj|j�|�}|s-td��nt|d�S(s�
    Factory function that instantiates a DSA object from a
    PEM encoded DSA key pair.

    @type  bio:      M2Crypto.BIO object
    @param bio:      Contains the PEM representation of the DSA 
                     key pair. 
    @type  callback: A Python callable
    @param callback: A Python callback object that will be 
                     invoked if the DSA key pair is 
                     passphrase-protected.
    @rtype:          DSA
    @return:         instance of DSA.
    sproblem loading DSA key pairi(Rtdsa_read_keyR$RR(R'R.R((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyRTyscCs,tj|�}t||�}|j�|S(sg
    Factory function that instantiates a DSA_pub object using
    a DSA public key contained in PEM file.  The PEM file 
    must contain the parameters in addition to the public key.

    @type  file:     str
    @param file:     Names the file (a path) that contains the PEM 
                     representation of the DSA public key. 
    @type  callback: A Python callable
    @param callback: A Python callback object that will be 
                     invoked should the DSA public key be 
                     passphrase-protected.
    @rtype:          DSA_pub
    @return:         instance of DSA_pub.
    (R!R"tload_pub_key_bioR%(RQR.R'R(((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pytload_pub_key�s
cCs:tj|j�|�}|s-td��nt|d�S(se
    Factory function that instantiates a DSA_pub object using
    a DSA public key contained in PEM format.  The PEM 
    must contain the parameters in addition to the public key.

    @type  bio:      M2Crypto.BIO object
    @param bio:      Contains the PEM representation of the DSA 
                     public key (with params). 
    @type  callback: A Python callable
    @param callback: A Python callback object that will be 
                     invoked should the DSA public key be 
                     passphrase-protected.
    @rtype:          DSA_pub
    @return:         instance of DSA_pub.
    sproblem loading DSA public keyi(Rtdsa_read_pub_keyR$RRI(R'R.tdsapub((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyRW�s((REtsysRGR!Rt	ExceptionRtdsa_initRRItgenparam_callbackRNRRHRRRPRURTRXRW(((s2/usr/lib64/python2.7/site-packages/M2Crypto/DSA.pyt<module>s$
�	

Zerion Mini Shell 1.0