1Mc@sdZddlZddlZddlZdefdYZejeejZejZej Z ej Z ej Z ej Z ej Z ejZejZejZejZejZejZejZejZejZejZejZejZejZejZejZejZejZejZej Z ej!Z!ej"Z"ej#Z#ej$Z$ej%Z%ej&Z&ej'Z'ej(Z(ej)Z)ej*Z*ej+Z+ej,Z,ej-Z-ej.Z.ej/Z/ej0Z0ej1Z1ej2Z2ej3Z3ej4Z4ej5Z5ej6Z6ej7Z7ej8Z8ej9Z9ej:Z:ej;Z;ej<Z<ej=Z=ej>Z>ej?Z?ej@Z@ejAZAejBZBejCZCejDZDejEZEejFZFejGZGdddYZHdeHfdYZId ZJejKd ZLejKd ZMd ZNd ZOdZPdZQdS(s M2Crypto wrapper for OpenSSL ECDH/ECDSA API. @requires: OpenSSL 0.9.8 or newer Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved. Portions copyright (c) 2005-2006 Vrije Universiteit Amsterdam. All rights reserved.iNtECErrorcBseZRS((t__name__t __module__(((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyR stECcBseZdZejZddZdZdZdZ dZ dZ dZ d Z d Zd Zd ejd Zd ejdZdZdZdZdZRS(s, Object interface to a EC key pair. icCs||_||_dS(N(tect_pyfree(tselfRR((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyt__init__is cCs)t|ddr%|j|jndS(NRi(tgetattrtm2_ec_key_freeR(R((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyt__del__nscCstj|jS(N(tm2t ec_key_keylenR(R((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyt__len__rscCstj|jdS(s Generates the key pair from its parameters. Use:: keypair = EC.gen_params(curve) keypair.gen_key() to create an EC key pair. N(R tec_key_gen_keyR(R((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pytgen_keyvscCst|jdS(Ni(tEC_pubR(R((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pytpubscCstj|j|S(sw Sign the given digest using ECDSA. Returns a tuple (r,s), the two ECDSA signature parameters. (R t ecdsa_signR(Rtdigest((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pytsign_dsascCstj|j|||S(sj Verify the given digest using ECDSA. r and s are the ECDSA signature parameters. (R t ecdsa_verifyR(RRtrts((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyt verify_dsascCstj|j|S(N(R tecdsa_sign_asn1R(RR((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyt sign_dsa_asn1scCstj|j||S(N(R tecdsa_verify_asn1R(RRtblob((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pytverify_dsa_asn1scCstj|j|jS(s Compute the ECDH shared key of this key pair and the given public key object. They must both use the same curve. Returns the shared key in binary as a buffer object. No Key Derivation Function is applied. (R tecdh_compute_keyR(Rtpub_key((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pytcompute_dh_keyst aes_128_cbccCs|dkr(tj|j|j|Stt|d}|dkrYtd|ntj|j|j||SdS(sR Save the key pair to an M2Crypto.BIO.BIO object in PEM format. @type bio: M2Crypto.BIO.BIO @param bio: M2Crypto.BIO.BIO object to save key to. @type cipher: string @param cipher: Symmetric cipher to protect the key. The default cipher is 'aes_128_cbc'. If cipher is None, then the key is saved in the clear. @type callback: Python callable @param callback: A Python callable object that is invoked to acquire a passphrase with which to protect the key. The default is util.passphrase_callback. snot such cipher %sN(tNoneR tec_key_write_bio_no_cipherRt_ptrRt ValueErrortec_key_write_bio(Rtbiotciphertcallbacktciph((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyt save_key_bios   cCs%tj|d}|j|||S(s+ Save the key pair to a file in PEM format. @type file: string @param file: Name of file to save key to. @type cipher: string @param cipher: Symmetric cipher to protect the key. The default cipher is 'aes_128_cbc'. If cipher is None, then the key is saved in the clear. @type callback: Python callable @param callback: A Python callable object that is invoked to acquire a passphrase with which to protect the key. The default is util.passphrase_callback. twb(tBIOtopenfileR+(RtfileR(R)R'((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pytsave_keyscCstj|j|jS(s Save the public key to an M2Crypto.BIO.BIO object in PEM format. @type bio: M2Crypto.BIO.BIO @param bio: M2Crypto.BIO.BIO object to save key to. (R tec_key_write_pubkeyRR$(RR'((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pytsave_pub_key_bioscCs+tj|d}tj|j|jS(s Save the public key to a file in PEM format. @type file: string @param file: Name of file to save key to. R,(R-R.R R1RR$(RR/R'((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyt save_pub_keyscCstj|jS(N(R tec_key_type_checkR(R((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyt_check_key_typescCstj|jS(N(R tec_key_check_keyR(R((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyt check_keys(RRt__doc__R t ec_key_freeR RR R RRRRRRR tutiltpassphrase_callbackR+R0R2R3R5R7(((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyRas$           RcBs5eZdZddZdZejZejZ RS(sc Object interface to an EC public key. ((don't like this implementation inheritance)) icCs tj|||d|_dS(N(RRR"tder(RRR((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyRscCs.|jdkr'tj|j|_n|jS(sJ Returns the public key in DER format as a buffer object. N(R<R"R tec_key_get_public_derR(R((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pytget_ders( RRR8RR>RR3R0R2R+(((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyRs   cCsttj|dS(s Factory function that generates EC parameters and instantiates a EC object from the output. @param curve: This is the OpenSSL nid of the curve to use. i(RR tec_key_new_by_curve_name(tcurve((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyt gen_paramsscCstj|}t||S(s  Factory function that instantiates a EC object. @param file: Names the file that contains the PEM representation of the EC key pair. @param callback: Python callback object that will be invoked if the EC key pair is passphrase-protected. (R-R.t load_key_bio(R/R)R'((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pytload_keys cCsttj|j|dS(s Factory function that instantiates a EC object. @param bio: M2Crypto.BIO object that contains the PEM representation of the EC key pair. @param callback: Python callback object that will be invoked if the EC key pair is passphrase-protected. i(RR tec_key_read_bioR$(R'R)((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyRBs cCstj|}t|S(s Load an EC public key from file. @type file: string @param file: Name of file containing EC public key in PEM format. @rtype: M2Crypto.EC.EC_pub @return: M2Crypto.EC.EC_pub object. (R-R.tload_pub_key_bio(R/R'((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyt load_pub_key*s cCs8tj|j}|dkr+tnt|dS(s Load an EC public key from an M2Crypto.BIO.BIO object. @type bio: M2Crypto.BIO.BIO @param bio: M2Crypto.BIO.BIO object containing EC public key in PEM format. @rtype: M2Crypto.EC.EC_pub @return: M2Crypto.EC.EC_pub object. iN(R tec_key_read_pubkeyR$R"tec_errorR(R'R((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyRE8s   cCsttjtjdS(N(RR terr_reason_error_stringt err_get_error(((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyRHHscCsttj|dS(s! Create EC_pub from DER. i(RR tec_key_from_pubkey_der(R<((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pytpub_key_from_derKs((RR8R:R-R t ExceptionRtec_initt NID_secp112r1t NID_secp112r2t NID_secp128r1t NID_secp128r2t NID_secp160k1t NID_secp160r1t NID_secp160r2t NID_secp192k1t NID_secp224k1t NID_secp224r1t NID_secp256k1t NID_secp384r1t NID_secp521r1t NID_sect113r1t NID_sect113r2t NID_sect131r1t NID_sect131r2t NID_sect163k1t NID_sect163r1t NID_sect163r2t NID_sect193r1t NID_sect193r2t NID_sect233k1t NID_sect233r1t NID_sect239k1t NID_sect283k1t NID_sect283r1t NID_sect409k1t NID_sect409r1t NID_sect571k1t NID_sect571r1tNID_X9_62_prime192v1tNID_X9_62_prime192v2tNID_X9_62_prime192v3tNID_X9_62_prime239v1tNID_X9_62_prime239v2tNID_X9_62_prime239v3tNID_X9_62_prime256v1tNID_X9_62_c2pnb163v1tNID_X9_62_c2pnb163v2tNID_X9_62_c2pnb163v3tNID_X9_62_c2pnb176v1tNID_X9_62_c2tnb191v1tNID_X9_62_c2tnb191v2tNID_X9_62_c2tnb191v3tNID_X9_62_c2pnb208w1tNID_X9_62_c2tnb239v1tNID_X9_62_c2tnb239v2tNID_X9_62_c2tnb239v3tNID_X9_62_c2pnb272w1tNID_X9_62_c2pnb304w1tNID_X9_62_c2tnb359v1tNID_X9_62_c2pnb368w1tNID_X9_62_c2tnb431r1tNID_wap_wsg_idm_ecid_wtls1tNID_wap_wsg_idm_ecid_wtls3tNID_wap_wsg_idm_ecid_wtls4tNID_wap_wsg_idm_ecid_wtls5tNID_wap_wsg_idm_ecid_wtls6tNID_wap_wsg_idm_ecid_wtls7tNID_wap_wsg_idm_ecid_wtls8tNID_wap_wsg_idm_ecid_wtls9tNID_wap_wsg_idm_ecid_wtls10tNID_wap_wsg_idm_ecid_wtls11tNID_wap_wsg_idm_ecid_wtls12RRRAR;RCRBRFRERHRL(((s1/usr/lib64/python2.7/site-packages/M2Crypto/EC.pyt s$