Ñò ñ1Mc@s"dZddkZddkZddkZddkZddkZdefd„ƒYZeieƒei Z ei Z ei Z ei Z ddd„ƒYZ de fd„ƒYZd „Zeid „Zed „Zeid „Zeid „Zeid„Zd„Zd„Zd„ZdS(scM2Crypto wrapper for OpenSSL RSA API. Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.iÿÿÿÿNtRSAErrorcBseZRS((t__name__t __module__(((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pyRstRSAcBs eZdZeiZdd„Zd„Zd„Zd„Z d„Z d„Z d„Z d „Z d „Zd eid „Zd eid „ZeZd eid„Zd„Zd„Zd„Zd„Zd„Zddd„Zddd„Zdd„Zdd„ZRS(s RSA Key Pair. icCs0ti|ƒp td‚||_||_dS(Ns'rsa' type error(tm2trsa_type_checktAssertionErrortrsat_pyfree(tselfRR((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pyt__init__s cCs+t|ddƒo|i|iƒndS(NRi(tgetattrt m2_rsa_freeR(R ((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pyt__del__scCsti|iƒd>S(Ni(Rtrsa_sizeR(R ((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pyt__len__"scCsF|djoti|iƒS|djoti|iƒSt‚dS(Ntetn(Rt rsa_get_eRt rsa_get_ntAttributeError(R tname((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pyt __getattr__%s   cCs9|iƒp td‚ti|iƒti|iƒfS(Nskey is not initialised(t check_keyRRRRR(R ((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pytpub-scCs-|iƒp td‚ti|i||ƒS(Nskey is not initialised(RRRtrsa_public_encryptR(R tdatatpadding((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pytpublic_encrypt1scCs-|iƒp td‚ti|i||ƒS(Nskey is not initialised(RRRtrsa_public_decryptR(R RR((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pytpublic_decrypt5scCs-|iƒp td‚ti|i||ƒS(Nskey is not initialised(RRRtrsa_private_encryptR(R RR((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pytprivate_encrypt9scCs-|iƒp td‚ti|i||ƒS(Nskey is not initialised(RRRtrsa_private_decryptR(R RR((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pytprivate_decrypt=st aes_128_cbccCs†|djoti|i|iƒ|ƒStt|dƒ}|djotd|‚n |ƒ}ti|i|iƒ||ƒ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(tNoneRtrsa_write_key_no_cipherRt_ptrR Rt rsa_write_key(R tbiotciphertcallbacktciph((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pyt save_key_bioAs   cCs%ti|dƒ}|i|||ƒ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(((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pytsave_key\scCs)tiƒ}|i|||ƒ|iƒS(sB Returns the key(pair) as a string in PEM format. (R.t MemoryBufferR,tread(R R)R*R(((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pytas_pemrs cCsti|i|iƒƒS(s± Save the key pair to an M2Crypto.BIO.BIO object in DER format. @type bio: M2Crypto.BIO.BIO @param bio: M2Crypto.BIO.BIO object to save key to. (Rtrsa_write_key_derRR&(R R(((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pytsave_key_der_biozscCsti|dƒ}|i|ƒS(s‚ Save the key pair to a file in DER format. @type file: str @param file: Filename to save key to R-(R.R/R6(R R0R(((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pyt save_key_derƒscCsti|i|iƒƒ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. (Rtrsa_write_pub_keyRR&(R R(((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pytsave_pub_key_bioscCs+ti|dƒ}ti|i|iƒƒS(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/RR8RR&(R R0R(((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pyt save_pub_key–scCsti|iƒS(N(Rt rsa_check_keyR(R ((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pyR stsha1icCsdtt|dƒ}|djotdtƒ‚nti|i||ƒ|ƒ}|i|tiƒS(sµ Signs a digest with the private key using RSASSA-PSS @requires: OpenSSL 0.9.7h or later. @type digest: str @param digest: A digest created by using the digest method @type salt_length: int @param salt_length: The length of the salt to use @type algo: str @param algo: The hash algorithm to use @return: a string which is the signature snot such hash algorithm %sN( R RR$t ValueErrort hash_algotrsa_padding_add_pkcs1_pssRR t no_padding(R tdigesttalgot salt_lengththasht signature((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pytsign_rsassa_pss£s  cCsgtt|dƒ}|djotdtƒ‚n|i|tiƒ}ti|i|||ƒ|ƒS(s Verifies the signature RSASSA-PSS @requires: OpenSSL 0.9.7h or later. @type data: str @param data: Data that has been signed @type signature: str @param signature: The signature signed with RSASSA-PSS @type salt_length: int @param salt_length: The length of the salt that was used @type algo: str @param algo: The hash algorithm to use @return: 1 or 0, depending on whether the signature was verified or not. snot such hash algorithm %sN( R RR$R=R>RR@trsa_verify_pkcs1_pssR(R RRERBRCRDtplain_signature((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pytverify_rsassa_pss¼s  cCsLttd|dƒ}|djotd|f‚nti|i||ƒS(st Signs a digest with the private key @type digest: str @param digest: A digest created by using the digest method @type algo: str @param algo: The method that created the digest. Legal values are 'sha1','sha224', 'sha256', 'ripemd160', and 'md5'. @return: a string which is the signature tNID_sunknown algorithmN(R RR$R=trsa_signR(R RARBt digest_type((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pytsignÙs cCsOttd|dƒ}|djotd|f‚nti|i|||ƒS(s  Verifies the signature with the public key @type data: str @param data: Data that has been signed @type signature: str @param signature: The signature signed with the private key @type algo: str @param algo: The method use to create digest from the data before it was signed. Legal values are 'sha1','sha224', 'sha256', 'ripemd160', and 'md5'. @return: True or False, depending on whether the signature was verified. RJsunknown algorithmN(R RR$R=t rsa_verifyR(R RRERBRL((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pytverifyís (RRt__doc__Rtrsa_freeR R R RRRRRR R"tutiltpassphrase_callbackR,R1tsave_pemR4R6R7R9R:RRFRIRMRO(((s2/usr/lib/python2.6/vendor-packages/M2Crypto/RSA.pyRs0            tRSA_pubcBsDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(s0 Object interface to an RSA public key. cCs+|djo td‚n||i|s& 0     ô'