Tryag File Manager
Home
-
Turbo Force
Current Path :
/
usr
/
lib
/
python2.4
/
site-packages
/
M2Crypto
/
Upload File :
New :
File
Dir
//usr/lib/python2.4/site-packages/M2Crypto/DSA.pyo
mò Ô'rDc�����������@���sì���d��Z��d�k�Z�d�k�Z�d�k�Z�d�k�Z�d�e�f�d�„��ƒ��YZ�e�i�e�ƒ�d�f��d�„��ƒ��YZ�d�e�f�d�„��ƒ��YZ �e�i �d�„�Z�d �„��Z�e�i �d �„�Z�e�i �d�„�Z�e�i �d�„�Z�e�i �d �„�Z�e�i �d�„�Z�e�i �d�„�Z�d�S(���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. Nt���DSAErrorc�����������B���s���t��Z�RS(���N(���t���__name__t ���__module__(����(����(����t0���/usr/lib/python2.4/site-packages/M2Crypto/DSA.pyR���� ���s����t���DSAc�����������B���sÎ���t��Z�d��Z�e�i�Z�d�d�„�Z�d�„��Z�d�„��Z�d�„��Z �d�„��Z �d�„��Z�d�„��Z�d �„��Z �d �„��Z�d�e�i�d�„�Z�d�e�i�d �„�Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�d�„��Z�RS(���s@�� 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 **' i����c���������C���s���|�|��_��|�|��_�d�S(���sI��� Use one of the factory functions to create an instance. N(���t���dsat���selft���_pyfree(���R���R���R���(����(����R���t���__init__,���s������ c���������C���s+���t��|��d�d�ƒ�o�|��i�|��i�ƒ�n�d��S(���NR���i����(���t���getattrR���t���m2_dsa_freeR���(���R���(����(����R���t���__del__4���s����c���������C���s���t��i�|��i�ƒ�S(���sp��� Return the key length. @rtype: int @return: the DSA key length in bits N(���t���m2t ���dsa_keylenR���R���(���R���(����(����R���t���__len__8���s������c���������C���sM���|�d�d�d�d�d�g�j�o'�t�t�d�|�f�ƒ�}�|�|��i�ƒ�Sn�t�‚�d�S(���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") t���pt���qt���gt���pubt���privs ���dsa_get_%sN(���t���nameR ���R���t���methodR���R���t���AttributeError(���R���R���R���(����(����R���t���__getattr__B���s���� ��c���������C���sZ���|�d�d�d�g�j�o�t�d�ƒ�‚�n1�|�d�d�g�j�o�t�d�ƒ�‚�n�|�|��i�|�<d��S(���NR���R���R���s���set (p, q, g) via set_params()R���R���s"���generate (pub, priv) via gen_key()(���R���R����t���valueR���t���__dict__(���R���R���R���(����(����R���t���__setattr__S���s ����c���������C���s=���t��i�|��i�|�ƒ�t��i�|��i�|�ƒ�t��i�|��i�|�ƒ�d�S(���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( ���R���t ���dsa_set_pR���R���R���t ���dsa_set_qR���t ���dsa_set_gR���(���R���R���R���R���(����(����R���t ���set_params[���s�����c���������C���s���t��i�|��i�ƒ�d�S(���s&��� Generate a key pair. N(���R���t���dsa_gen_keyR���R���(���R���(����(����R���t���gen_keyg���s������c���������C���s;���t��i�|�d�ƒ�}�t�i�|��i�|�i�ƒ��ƒ�}�|�i �ƒ��|�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 t���wbN(���t���BIOt���openfilet���filenamet���bioR���t���dsa_write_params_bioR���R���t���_ptrt���rett���close(���R���R$���R%���R(���(����(����R���t���save_paramsn���s ����� c���������C���s���t��i�|��i�|�i�ƒ��ƒ�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 N(���R���R&���R���R���R%���R'���(���R���R%���(����(����R���t���save_params_bio{���s�����t���aes_128_cbcc���������C���s5���t��i�t�d�ƒ�}�|��i�|�|�|�ƒ�}�|�i �ƒ��|�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!���N( ���R"���R#���t���filepathR%���R���t���save_key_biot���ciphert���callbackR(���R)���(���R���R$���R/���R0���R%���R(���(����(����R���t���save_key…���s ����� c���������C���sŒ���|�d�j�o �t�i�|��i�|�i�ƒ��|�ƒ�Sn\�t �t�|�d�ƒ�}�|�d�j�o�t�d�|�ƒ�‚�n �|�ƒ��}�t�i�|��i�|�i�ƒ��|�|�ƒ�Sd�S(���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 s���no such cipher: %sN( ���R/���t���NoneR���t���dsa_write_key_bio_no_cipherR���R���R%���R'���R0���R ���t���ciphR����t���dsa_write_key_bio(���R���R%���R/���R0���R4���(����(����R���R.���–���s����� c���������C���s/���t��i�t�d�ƒ�}�|��i�|�ƒ�}�|�i�ƒ��|�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!���N(���R"���R#���R-���R%���R���t���save_pub_key_bioR(���R)���(���R���R$���R%���R(���(����(����R���t���save_pub_key���s ����� c���������C���s���t��i�|��i�|�i�ƒ��ƒ�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 N(���R���t���dsa_write_pub_key_bioR���R���R%���R'���(���R���R%���(����(����R���R6���»���s�����c���������C���s���t��i�|��i�|�ƒ�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". N(���R���t���dsa_signR���R���t���digest(���R���R:���(����(����R���t���signÆ���s���� ��c���������C���s���t��i�|��i�|�|�|�ƒ�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 N(���R���t ���dsa_verifyR���R���R:���t���rt���s(���R���R:���R=���R>���(����(����R���t���verifyÔ���s������c���������C���s���t��i�|��i�|�ƒ�S(���N(���R���t ���dsa_sign_asn1R���R���R:���(���R���R:���(����(����R���t ���sign_asn1æ���s�����c���������C���s���t��i�|��i�|�|�ƒ�S(���N(���R���t���dsa_verify_asn1R���R���R:���t���blob(���R���R:���RC���(����(����R���t���verify_asn1ê���s�����c���������C���s���t��i�|��i�ƒ�S(���s—��� Check to be sure the DSA object has a valid private key. @rtype: int @return: 1 (true) if a valid private key N(���R���t ���dsa_check_keyR���R���(���R���(����(����R���t ���check_keyî���s������(���R���R���t���__doc__R���t���dsa_freeR ���R���R���R���R���R���R���R ���R*���R+���t���utilt���passphrase_callbackR1���R.���R7���R6���R;���R?���RA���RD���RF���(����(����(����R���R������s(���� t���DSA_pubc�����������B���s8���t��Z�d��Z�d�„��Z�e�Z�d�„��Z�e�i�Z�e�i �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. c���������G���s���t��d�ƒ�‚�d��S(���Ns!���DSA_pub object has no private key(���R����(���R���t���argv(����(����R���R;�����s����c���������C���s���t��i�|��i�ƒ�S(���N(���R���t���dsa_check_pub_keyR���R���(���R���(����(����R���RF�����s����(���R���R���RG���R;���RA���RF���R���R7���R1���R6���R.���(����(����(����R���RK���ú���s���� c���������C���s<���t��i�|��|�ƒ�}�|�d�j�o�t�d�ƒ�‚�n�t�|�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 parametersi���N(���R���t���dsa_generate_parameterst���bitsR0���R���R2���R����R���(���RO���R0���R���(����(����R���t ���gen_params��s ����� c���������C���sI���t��i�ƒ��}�t��i�|�|��ƒ�t��i�|�|�ƒ�t��i�|�|�ƒ�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���N( ���R���t���dsa_newR���R���R���R���R���R���R���R���(���R���R���R���R���(����(����R���R���&��s���� �c���������C���s,���t��i�|��ƒ�}�t�|�|�ƒ�}�|�i�ƒ��|�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. N(���R"���R#���t���fileR%���t���load_params_bioR0���R(���R)���(���RR���R0���R%���R(���(����(����R���t���load_params:��s ����� c���������C���sB���t��i�|��i�ƒ��|�ƒ�}�|�d�j�o�t�d�ƒ�‚�n�t�|�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. s���problem loading DSA parametersi���N( ���R���t���dsa_read_paramsR%���R'���R0���R���R2���R����R���(���R%���R0���R���(����(����R���RS���O��s ����� c���������C���s,���t��i�|��ƒ�}�t�|�|�ƒ�}�|�i�ƒ��|�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. N(���R"���R#���RR���R%���t���load_key_bioR0���R(���R)���(���RR���R0���R%���R(���(����(����R���t���load_keyd��s ����� c���������C���s<���t��i�|��i�ƒ��|�ƒ�}�|�p�t�d�ƒ�‚�n�t�|�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. s���problem loading DSA key pairi���N(���R���t���dsa_read_keyR%���R'���R0���R���R����R���(���R%���R0���R���(����(����R���RV���y��s �����c���������C���s,���t��i�|��ƒ�}�t�|�|�ƒ�}�|�i�ƒ��|�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. N(���R"���R#���RR���R%���t���load_pub_key_bioR0���R(���R)���(���RR���R0���R%���R(���(����(����R���t���load_pub_keyŽ��s ����� c���������C���s<���t��i�|��i�ƒ��|�ƒ�}�|�p�t�d�ƒ�‚�n�t�|�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. s���problem loading DSA public keyi���N(���R���t���dsa_read_pub_keyR%���R'���R0���t���dsapubR����RK���(���R%���R0���R\���(����(����R���RY���¤��s �����(���RG���t���sysRI���R"���R���t ���ExceptionR����t���dsa_initR���RK���t���genparam_callbackRP���R���RJ���RT���RS���RW���RV���RZ���RY���(���RI���RP���R"���RW���RK���RY���R����R]���RZ���R���RT���R���RV���RS���R���(����(����R���t���?���s��� é