ó =OXc@sœdZddlmZddlmZddlmZmZddlm Z m Z ddl m Z ddl mZddlmZd efd „ƒYZd S( s RSA keys. iÿÿÿÿ(tInvalidSignature(tdefault_backend(thashest serialization(trsatpadding(tMessage(tPKey(t SSHExceptiontRSAKeycBsÔeZdZddddddd„Zed„ƒZed„ƒZd„Zd„Z d„Z d„Z d„Z d „Z d „Zd „Zdd „Zdd „Zedd„ƒZd„Zd„Zd„ZRS(sZ Representation of an RSA key which can be used to sign and verify SSH2 data. cCsûd|_|dk r)|j||ƒdS|dk rI|j||ƒdS|dkrp|dk rpt|ƒ}n|dk rˆ||_no|dkr£tdƒ‚n|jƒdkrÄtdƒ‚ntjd|j ƒd|j ƒƒj t ƒƒ|_dS(NsKey object may not be emptysssh-rsas Invalid keytetn( tNonetkeyt_from_private_keyt_from_private_key_fileRRtget_textRtRSAPublicNumberst get_mpintt public_keyR(tselftmsgtdatatfilenametpasswordR tfile_obj((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pyt__init__'s$       cCs |jjS(N(R tkey_size(R((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pytsize<scCs6t|jtjƒr%|jjƒjS|jjƒSdS(N(t isinstanceR Rt RSAPrivateKeytprivate_numberstpublic_numbers(R((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pyR @scCsFtƒ}|jdƒ|j|jjƒ|j|jjƒ|jƒS(Nsssh-rsa(Rt add_stringt add_mpintR R R tasbytes(Rtm((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pyR#Gs   cCs |jƒS(N(R#(R((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pyt__str__NscCsPt|jƒƒ}|dt|jjƒ}|dt|jjƒ}t|ƒS(Ni%(thashtget_nameR R R (Rth((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pyt__hash__QscCsdS(Nsssh-rsa((R((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pyR'WscCs|jS(N(R(R((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pytget_bitsZscCst|jtjƒS(N(RR RR(R((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pytcan_sign]scCsg|jjdtjƒdtjƒƒ}|j|ƒ|jƒ}tƒ}|j dƒ|j |ƒ|S(NRt algorithmsssh-rsa( R tsignerRtPKCS1v15RtSHA1tupdatetfinalizeRR!(RRR-tsigR$((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pyt sign_ssh_data`s       cCs¨|jƒdkrtS|j}t|tjƒr@|jƒ}n|jd|jƒdt j ƒdt j ƒƒ}|j |ƒy|jƒWntk rŸtSXtSdS(Nsssh-rsat signatureRR,(RtFalseR RRRRtverifiert get_binaryRR.RR/R0tverifyRtTrue(RRRR R6((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pytverify_ssh_sigms      cCs&|j||jtjjd|ƒdS(NR(t_write_private_key_fileR Rt PrivateFormattTraditionalOpenSSL(RRR((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pytwrite_private_key_files  cCs&|j||jtjjd|ƒdS(NR(t_write_private_keyR RR<R=(RRR((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pytwrite_private_key‰s  cCs.tjddd|dtƒƒ}td|ƒS(s- Generate a new private RSA key. This factory function can be used to generate a new host key or authentication key. :param int bits: number of bits the generated key should be. :param function progress_func: Unused :return: new `.RSAKey` private key tpublic_exponentiRtbackendR (Rtgenerate_private_keyRR (tbitst progress_funcR ((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pytgenerate‘s cCs&|jd||ƒ}|j|ƒdS(NtRSA(t_read_private_key_filet _decode_key(RRRR((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pyR¢scCs&|jd||ƒ}|j|ƒdS(NRG(t_read_private_keyRI(RRRR((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pyR¦scCsoy"tj|dddtƒƒ}Wn%tk rI}tt|ƒƒ‚nXt|tj ƒsbt ‚||_ dS(NRRB( Rtload_der_private_keyR Rt ValueErrorRtstrRRRtAssertionErrorR (RRR R ((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pyRIªsN(t__name__t __module__t__doc__R RtpropertyRR R#R%R)R'R*R+R3R:R>R@t staticmethodRFRRRI(((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pyR !s&           N(RQtcryptography.exceptionsRtcryptography.hazmat.backendsRtcryptography.hazmat.primitivesRRt)cryptography.hazmat.primitives.asymmetricRRtparamiko.messageRt paramiko.pkeyRtparamiko.ssh_exceptionRR (((s3/usr/lib/python2.7/site-packages/paramiko/rsakey.pyts