1Mc@s"dZddlZddlZddlZddlZddlZdefdYZejeej Z ej Z ej Z ej Z dddYZ de fdYZd Zejd Zed Zejd Zejd ZejdZdZdZdZdS(scM2Crypto wrapper for OpenSSL RSA API. Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.iNtRSAErrorcBseZRS((t__name__t __module__(((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyRstRSAcBs eZdZejZddZdZdZdZ dZ dZ dZ d Z d Zd ejd Zd ejd ZeZd ejdZdZdZdZdZdZdddZdddZddZddZRS(s RSA Key Pair. icCs||_||_dS(N(trsat_pyfree(tselfRR((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyt__init__s cCs)t|ddr%|j|jndS(NRi(tgetattrt m2_rsa_freeR(R((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyt__del__scCstj|jd>S(Ni(tm2trsa_sizeR(R((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyt__len__"scCsB|dkrtj|jS|dkr8tj|jStdS(Ntetn(R t rsa_get_eRt rsa_get_ntAttributeError(Rtname((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyt __getattr__%s   cCs"tj|jtj|jfS(N(R RRR(R((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytpub-scCstj|j||S(N(R trsa_public_encryptR(Rtdatatpadding((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytpublic_encrypt1scCstj|j||S(N(R trsa_public_decryptR(RRR((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytpublic_decrypt5scCstj|j||S(N(R trsa_private_encryptR(RRR((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytprivate_encrypt9scCstj|j||S(N(R trsa_private_decryptR(RRR((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytprivate_decrypt=st aes_128_cbccCs|dkr(tj|j|j|Stt|d}|dkrVtd|n |}tj|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 trsa_write_key_no_cipherRt_ptrRRt rsa_write_key(Rtbiotciphertcallbacktciph((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyt save_key_bioAs   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%((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytsave_key\scCs)tj}|j||||jS(sB Returns the key(pair) as a string in PEM format. (R+t MemoryBufferR)tread(RR&R'R%((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytas_pemrs cCstj|j|jS(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. (R trsa_write_key_derRR#(RR%((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytsave_key_der_biozscCstj|d}|j|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,R3(RR-R%((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyt save_key_derscCstj|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 trsa_write_pub_keyRR#(RR%((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.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 R5RR#(RR-R%((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyt save_pub_keyscCstj|jS(N(R t rsa_check_keyR(R((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyt check_keystsha1icCsbtt|d}|dkr1tdtntj|j|||}|j|tjS(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( RR R!t ValueErrort hash_algotrsa_padding_add_pkcs1_pssRRt no_padding(Rtdigesttalgot salt_lengththasht signature((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytsign_rsassa_psss  cCsett|d}|dkr1tdtn|j|tj}tj|j||||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( RR R!R;R<RR>trsa_verify_pkcs1_pssR(RRRCR@RARBtplain_signature((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytverify_rsassa_psss  cCsJttd|d}|dkr4td|fntj|j||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(RR R!R;trsa_signR(RR?R@t digest_type((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytsigns cCsMttd|d}|dkr4td|fntj|j|||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. RHsunknown algorithmN(RR R!R;t rsa_verifyR(RRRCR@RJ((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytverifys (RRt__doc__R trsa_freeR RR R RRRRRRtutiltpassphrase_callbackR)R.tsave_pemR1R3R4R6R7R9RDRGRKRM(((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyRs0            tRSA_pubcBsDeZdZdZdZdZdZdZdZRS(s0 Object interface to an RSA public key. cCs)|dkrtdn ||j|t pkcs1_paddingtsslv23_paddingtpkcs1_oaep_paddingRRSR]tstdoutRfRiRQRkRjRnRpRoRv(((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyts& 0     '