Ñò &5š@c @sþdZddklZddklZyddklZWnej o dZnXdefd„ƒYZ dd„Z d„Z d eifd „ƒYZ d eifd „ƒYZ dd „Zd„Ze Ze Ze ZeoeZ eZ ei Z ndS(s6$Id: RSA.py,v 1.20 2004/05/06 12:52:54 akuchling Exp $iÿÿÿÿ(tpubkey(tnumber(t _fastmathterrorcBseZRS((t__name__t __module__(((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyRscCsVtƒ}|o|dƒnd}}xKti||ƒ|jo0ti|d|ƒ}ti|d|ƒ}q+W||jo||}}n||_||_|o|dƒnti|i|iƒ|_|i|i|_ d|_ |o|dƒnti|i |id|idƒ|_ |d|iƒjp t d‚|S( ségenerate(bits:int, randfunc:callable, progress_func:callable) Generate an RSA key of length 'bits', using 'randfunc' to get random data and 'progress_func', if present, to display the progress of the key generation. sp,q lisu lsd isGenerated key is too small( tRSAobjRtsizeRtgetPrimetptqtinversetutntetdtAssertionError(tbitstrandfunct progress_functobjR R ((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pytgenerates,      *!cCsätƒ}t|ƒdjo td‚nx;tt|ƒƒD]'}|i|}t||||ƒq<Wt|ƒdjo4|i|ijo|i|i|_|_q®nt|ƒdjoti |i|iƒ|_ n|S(skconstruct(tuple:(long,) : RSAobj Construct an RSA object from a 2-, 3-, 5-, or 6-tuple of numbers. iiiis%argument for construct() wrong length(iiii( RtlenRtrangetkeydatatsetattrR R RR R (ttupleRtitfield((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyt construct?s   !RcBs€eZddddddgZdd„Zd„Zdd „Zd „Zd „Zd „Zd „Z d„Z d„Z d„Z RS(R RRR R R tcCs6|i|jo td‚nt||i|iƒfS(NsPlaintext too large(R RtpowR(tselft plaintexttK((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyt_encryptWs cCsXt|dƒp td‚n|i|djo td‚nt|d|i|iƒS(NRs(Private key not available in this objectisCiphertext too large(thasattrRR RR(R t ciphertext((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyt_decrypt\s   cCs|i|fƒfS(N(R&(R tMR"((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyt_signcscCs1|i|dƒ}|d|jodSdSdS(Nii(R#(R R'tsigtm2((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyt_verifyfscCs't||i|iƒ}|||iS(N(RRR (R R'tBttmp((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyt_blindlscCs$ti||iƒ}|||iS(N(RR R (R R'R,R-((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyt_unblindpscCsdS(söcan_blind() : bool Return a Boolean value recording whether this algorithm can blind data. (This does not imply that this particular key object has the private information required to to blind a message.) i((R ((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyt can_blindtscCsti|iƒdS(s`size() : int Return the maximum number of bits that can be handled by this key. i(RRR (R ((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyR}scCst|dƒodSdSdS(swhas_private() : bool Return a Boolean denoting whether the object contains private components. RiiN(R$(R ((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyt has_privateƒscCst|i|ifƒS(shpublickey(): RSAobj Return a new key object containing only the public key information. (RR R(R ((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyt publickeyŒs( RRRR#R&R(R+R.R/R0RR1R2(((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyRUs        tRSAobj_ccBsžeZddddddgZd„Zd„Zd„Zd „Zd „Zd „Zd „Z d „Z d„Z d„Z d„Z d„Zd„Zd„ZRS(R RRR R R cCs ||_dS(N(tkey(R R4((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyt__init__•scCs]||ijot|i|ƒS|ii|ƒo|i|ntd|i|f‚dS(Ns%s instance has no attribute %s(RtgetattrR4t__dict__thas_keytAttributeErrort __class__(R tattr((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyt __getattr__˜s cCsKh}x>|iD]3}t|i|ƒot|i|ƒ||RAR#R&R(R+R.R/R0RR1R2(((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyR3’s           c CsD|o|dƒnd}}xKti||ƒ|jo0ti|d|ƒ}ti|d|ƒ}q"W||jo||}}n|o|dƒnti||ƒ}||}d}|o|dƒnti||d|dƒ}ti||||||ƒ} t| ƒ} |d| iƒjp td‚| S( Nsp,q lisu lsd isGenerated key is too small( RRRRR RR?R3R( RRRR R R R RRR4R((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyt generate_cÒs*    !cCstti|ƒ}t|ƒS(N(tapplyRR?R3(RR4((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyRDósN(t __revision__tCrypto.PublicKeyRt Crypto.UtilRRt ImportErrortNonet ExceptionRRRRR3RERDtobjectt generate_pyt construct_py(((s:/usr/lib64/python2.6/site-packages/Crypto/PublicKey/RSA.pyt s(  % =@ !