ó ñ1Mc@sdZddlZddlZddlZdefd„ƒYZejeƒejZejZej 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@ejAZAejBZBejCZCejDZDejEZEejFZFejGZGddd„ƒYZHdeHfd„ƒYZId „ZJejKd „ZLejKd „ZMd „ZNd „ZOd„ZPd„ZQdS(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.iÿÿÿÿNtECErrorcBseZRS((t__name__t __module__(((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyR stECcBs¼eZdZejZdd„Zd„Zd„Zd„Z d„Z d„Z d„Z d „Z d „Zd „Zd ejd „Zd ejd„Zd„Zd„Zd„Zd„ZRS(s, Object interface to a EC key pair. icCs1tj|ƒstdƒ‚||_||_dS(Ns'ec' type error(tm2tec_key_type_checktAssertionErrortect_pyfree(tselfRR((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyt__init__is cCs)t|ddƒr%|j|jƒndS(NRi(tgetattrtm2_ec_key_freeR(R ((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyt__del__nscCs.tj|jƒstdƒ‚tj|jƒS(Ns'ec' type error(RRRRt ec_key_keylen(R ((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyt__len__rscCs2tj|jƒstdƒ‚tj|jƒdS(s® Generates the key pair from its parameters. Use:: keypair = EC.gen_params(curve) keypair.gen_key() to create an EC key pair. s'ec' type errorN(RRRRtec_key_gen_key(R ((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pytgen_keyvscCst|jdƒS(Ni(tEC_pubR(R ((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pytpub€scCs+|jƒstdƒ‚tj|j|ƒS(sw Sign the given digest using ECDSA. Returns a tuple (r,s), the two ECDSA signature parameters. s'ec' type error(t_check_key_typeRRt ecdsa_signR(R tdigest((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pytsign_dsa„scCs1|jƒstdƒ‚tj|j|||ƒS(sj Verify the given digest using ECDSA. r and s are the ECDSA signature parameters. s'ec' type error(RRRt ecdsa_verifyR(R Rtrts((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyt verify_dsaŒscCs+|jƒstdƒ‚tj|j|ƒS(Ns'ec' type error(RRRtecdsa_sign_asn1R(R R((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyt sign_dsa_asn1”scCs.|jƒstdƒ‚tj|j||ƒS(Ns'ec' type error(RRRtecdsa_verify_asn1R(R Rtblob((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pytverify_dsa_asn1˜scCs.|jƒstdƒ‚tj|j|jƒS(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. skey is not initialised(t check_keyRRtecdh_compute_keyR(R tpub_key((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pytcompute_dh_keyœst 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(tNoneRtec_key_write_bio_no_cipherRt_ptrR t ValueErrortec_key_write_bio(R tbiotciphertcallbacktciph((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyt save_key_bio¦s   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/(R tfileR,R-R+((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pytsave_key¿scCstj|j|jƒƒS(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. (Rtec_key_write_pubkeyRR((R R+((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pytsave_pub_key_bioÓscCs+tj|dƒ}tj|j|jƒƒS(sŒ Save the public key to a file in PEM format. @type file: string @param file: Name of file to save key to. R0(R1R2RR5RR((R R3R+((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyt save_pub_keyÜscCstj|jƒS(N(RRR(R ((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyRæscCs.tj|jƒstdƒ‚tj|jƒS(Ns'ec' type error(RRRRtec_key_check_key(R ((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyR!és(RRt__doc__Rt ec_key_freeR R R RRRRRRR R$tutiltpassphrase_callbackR/R4R6R7RR!(((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyRas$           RcBs5eZdZdd„Zd„ZejZejZ RS(sc Object interface to an EC public key. ((don't like this implementation inheritance)) icCs tj|||ƒd|_dS(N(RR R&tder(R RR((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyR ôscCsF|jƒstdƒ‚|jdkr?tj|jƒ|_n|jS(sJ Returns the public key in DER format as a buffer object. skey is not initialisedN(R!RR=R&Rtec_key_get_public_derR(R ((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pytget_derøs( RRR9R R?RR7R4R6R/(((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyRîs   cCsttj|ƒdƒS(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(RRtec_key_new_by_curve_name(tcurve((s1/usr/lib/python2.7/vendor-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. (R1R2t load_key_bio(R3R-R+((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pytload_keys cCsttj|jƒ|ƒdƒS(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(RRtec_key_read_bioR((R+R-((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyRCs 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. (R1R2tload_pub_key_bio(R3R+((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyt load_pub_key*s cCs8tj|jƒƒ}|dkr+tƒnt|dƒS(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(Rtec_key_read_pubkeyR(R&tec_errorR(R+R((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyRF8s   cCsttjtjƒƒ‚dS(N(RRterr_reason_error_stringt err_get_error(((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyRIHscCsttj|ƒdƒS(s! Create EC_pub from DER. i(RRtec_key_from_pubkey_der(R=((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pytpub_key_from_derKs((RR9R;R1Rt 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_wtls12RRRBR<RDRCRGRFRIRM(((s1/usr/lib/python2.7/vendor-packages/M2Crypto/EC.pyt sš$