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. icCs1tj|std||_||_dS(Ns'rsa' type error(tm2trsa_type_checktAssertionErrortrsat_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(Rtrsa_sizeR(R ((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyt__len__"scCsB|dkrtj|jS|dkr8tj|jStdS(Ntetn(Rt rsa_get_eRt rsa_get_ntAttributeError(R tname((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyt __getattr__%s   cCs:|jstdtj|jtj|jfS(Nskey is not initialised(t check_keyRRRRR(R ((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytpub-scCs.|jstdtj|j||S(Nskey is not initialised(RRRtrsa_public_encryptR(R tdatatpadding((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytpublic_encrypt1scCs.|jstdtj|j||S(Nskey is not initialised(RRRtrsa_public_decryptR(R RR((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytpublic_decrypt5scCs.|jstdtj|j||S(Nskey is not initialised(RRRtrsa_private_encryptR(R RR((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytprivate_encrypt9scCs.|jstdtj|j||S(Nskey is not initialised(RRRtrsa_private_decryptR(R RR((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(tNoneRtrsa_write_key_no_cipherRt_ptrR Rt rsa_write_key(R tbiotciphertcallbacktciph((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,(R tfileR)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(R R)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. (Rtrsa_write_key_derRR&(R R(((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/R6(R R0R(((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. (Rtrsa_write_pub_keyRR&(R R(((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/RR8RR&(R R0R(((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyt save_pub_keyscCstj|jS(N(Rt rsa_check_keyR(R ((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyRstsha1icCsbtt|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( R RR$t ValueErrort hash_algotrsa_padding_add_pkcs1_pssRR t no_padding(R tdigesttalgot 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( R RR$R=R>RR@trsa_verify_pkcs1_pssR(R RRERBRCRDtplain_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(R RR$R=trsa_signR(R RARBt 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. RJsunknown algorithmN(R RR$R=t rsa_verifyR(R RRERBRL((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pytverifys (RRt__doc__Rtrsa_freeR R R RRRRRR R"tutiltpassphrase_callbackR,R1tsave_pemR4R6R7R9R:RRFRIRMRO(((s2/usr/lib64/python2.7/site-packages/M2Crypto/RSA.pyRs0            tRSA_pubcBsDeZdZdZdZdZdZdZdZRS(s0 Object interface to an RSA public key. cCs)|dkrtdn ||j|s& 0     '