ó Ú_e[c@s¬dZddlmZddlmZddlmZmZddlm Z m Z ddl m Z ddl mZddlmZdd lmZd efd „ƒYZd S( s RSA keys. iÿÿÿÿ(tInvalidSignature(tdefault_backend(thashest serialization(trsatpadding(tMessage(tPKey(tPY2(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|_d|_|dk r2|j||ƒdS|dk rR|j||ƒdS|dkry|dk ryt|ƒ}n|dk r‘||_nO|jd|ddddƒtjd|j ƒd|j ƒƒj t ƒƒ|_dS(Ntmsgtkey_typesssh-rsat cert_typesssh-rsa-cert-v01@openssh.comtetn( tNonetkeyt public_blobt_from_private_keyt_from_private_key_fileRt_check_type_and_load_certRtRSAPublicNumberst get_mpintt public_keyR(tselfR tdatatfilenametpasswordRtfile_obj((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pyt__init__(s&        cCs |jjS(N(Rtkey_size(R((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pytsize@scCs6t|jtjƒr%|jjƒjS|jjƒSdS(N(t isinstanceRRt RSAPrivateKeytprivate_numberstpublic_numbers(R((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pyR$DscCsFtƒ}|jdƒ|j|jjƒ|j|jjƒ|jƒS(Nsssh-rsa(Rt add_stringt add_mpintR$RRtasbytes(Rtm((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pyR'Ks   cCs-tr|jƒS|jƒjdddƒSdS(Ntutf8terrorstignore(RR'tdecode(R((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pyt__str__Rs cCs%t|jƒ|jj|jjfƒS(N(thashtget_nameR$RR(R((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pyt__hash__^scCsdS(Nsssh-rsa((R((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pyR/bscCs|jS(N(R (R((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pytget_bitsescCst|jtjƒS(N(R!RRR"(R((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pytcan_signhscCsQ|jj|dtjƒdtjƒƒ}tƒ}|jdƒ|j|ƒ|S(NRt algorithmsssh-rsa(RtsignRtPKCS1v15RtSHA1RR%(RRtsigR(((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pyt sign_ssh_dataks     cCs‰|jƒdkrtS|j}t|tjƒr@|jƒ}ny,|j|jƒ|t j ƒt j ƒƒWnt k r€tSXtSdS(Nsssh-rsa(tget_texttFalseRR!RR"Rtverifyt get_binaryRR5RR6RtTrue(RRR R((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pytverify_ssh_sigws & cCs&|j||jtjjd|ƒdS(NR(t_write_private_key_fileRRt PrivateFormattTraditionalOpenSSL(RRR((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pytwrite_private_key_file‡s  cCs&|j||jtjjd|ƒdS(NR(t_write_private_keyRRR@RA(RRR((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pytwrite_private_keys  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 progress_func: Unused :return: new `.RSAKey` private key tpublic_exponentiRtbackendR(Rtgenerate_private_keyRR (tbitst progress_funcR((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pytgenerate—s cCs&|jd||ƒ}|j|ƒdS(NtRSA(t_read_private_key_filet _decode_key(RRRR((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pyR¨scCs&|jd||ƒ}|j|ƒdS(NRK(t_read_private_keyRM(RRRR((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pyR¬scCsoy"tj|dddtƒƒ}Wn%tk rI}tt|ƒƒ‚nXt|tj ƒsbt ‚||_ dS(NRRF( Rtload_der_private_keyRRt ValueErrorR tstrR!RR"tAssertionErrorR(RRRR((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pyRM°sN(t__name__t __module__t__doc__RRtpropertyR R$R'R-R0R/R1R2R8R>RBRDt staticmethodRJRRRM(((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pyR "s(           N(RUtcryptography.exceptionsRtcryptography.hazmat.backendsRtcryptography.hazmat.primitivesRRt)cryptography.hazmat.primitives.asymmetricRRtparamiko.messageRt paramiko.pkeyRtparamiko.py3compatRtparamiko.ssh_exceptionR R (((s3/tmp/pip-install-KP2Jbq/paramiko/paramiko/rsakey.pyts