/usr/lib/python2.6/site-packages/rsa
NameSizeModeActions
asn1.py17810644editdlrm
asn1.pyc16530644editdlrm
asn1.pyo16530644editdlrm
bigfile.py51850644editdlrm
bigfile.pyc47860644editdlrm
bigfile.pyo47860644editdlrm
cli.py121850644editdlrm
cli.pyc133190644editdlrm
cli.pyo133190644editdlrm
common.py46400644editdlrm
common.pyc42350644editdlrm
common.pyo42350644editdlrm
core.py16560644editdlrm
core.pyc14850644editdlrm
core.pyo14850644editdlrm
key.py228670644editdlrm
key.pyc239860644editdlrm
key.pyo239860644editdlrm
parallel.py22990644editdlrm
parallel.pyc20980644editdlrm
parallel.pyo20980644editdlrm
pem.py35370644editdlrm
pem.pyc28430644editdlrm
pem.pyo28430644editdlrm
pkcs1.py122300644editdlrm
pkcs1.pyc111730644editdlrm
pkcs1.pyo111260644editdlrm
prime.py45600644editdlrm
prime.pyc36640644editdlrm
prime.pyo36180644editdlrm
randnum.py26430644editdlrm
randnum.pyc20740644editdlrm
randnum.pyo20740644editdlrm
transform.py68920644editdlrm
transform.pyc58560644editdlrm
transform.pyo58560644editdlrm
util.py30590644editdlrm
util.pyc25200644editdlrm
util.pyo24490644editdlrm
varblock.py54060644editdlrm
varblock.pyc48560644editdlrm
varblock.pyo48560644editdlrm
_compat.py38900644editdlrm
_compat.pyc36550644editdlrm
_compat.pyo36550644editdlrm
_version133.py117640644editdlrm
_version133.pyc136390644editdlrm
_version133.pyo136390644editdlrm
_version200.py151230644editdlrm
_version200.pyc152640644editdlrm
_version200.pyo152640644editdlrm
__init__.py14760644editdlrm
__init__.pyc11120644editdlrm
__init__.pyo11120644editdlrm
Edit: /usr/lib/python2.6/site-packages/rsa/_version200.pyo (15264B)
Ñò |~úVc @sèdZdZdZdZddkZddkZddkZddkZddkZddk l Z ddk Z e i de ƒe i deƒd „Zd „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z!d„Z"d„Z#d„Z$d„Z%d „Z&d!„Z'd"„Z(d#„Z)d$„Z*d%„Z+d&„Z,d'„Z-e d(joddk.Z.e.i/ƒnd)d*d+d,d-gZ0dS(.sDeprecated version of the RSA module .. deprecated:: 3.0 This submodule is deprecated and will be completely removed as of version 4.0. s;Sybren Stuvel, Marloes de Boer, Ivo Tamboer, and Barry Meads 2010-02-08s2.0iÿÿÿÿN(tbytes4Insecure version of the RSA module is imported as %ssNThis submodule is deprecated and will be completely removed as of version 4.0.cCsttiti|dƒƒƒS(sBReturns the number of bits required to hold a specific long numberi(tinttmathtceiltlog(tnumber((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytbit_size+scCsHxA|djo3||jo||}}n|||}}qW|S(sOReturns the greatest common divisor of p and q >>> gcd(48, 180) 12 i((tptq((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytgcd0s   cCs‘t|ƒtijpt|ƒtijptdƒ‚nd}xH|D]@}|d9}t|ƒtijot|ƒ}n||7}qIW|S(s7Converts a list of bytes or a string to an integer s You must pass a string or a listii(ttypettypestListTypet StringTypet TypeErrortord(tbytestintegerR((s3/usr/lib/python2.6/site-packages/rsa/_version200.pyt bytes2int<s, cCst|ƒtijpt|ƒtijptdƒ‚nd}x6|djo(dt|d@ƒ|f}|d:}qEW|S(s0 Converts a number to a string of bytes sYou must pass a long or an inttis%s%siÿi(R R tLongTypetIntTypeRR(Rtstring((s3/usr/lib/python2.6/site-packages/rsa/_version200.pyt int2bytesLs, cCst|ƒtijpt|ƒtijptdƒ‚nd|jo djnot|dƒSd|jo djnot|dƒSd|jo d jnot|d ƒS|d jo td ƒS|d jo td ƒStd|ƒ‚dS(s‚Converts a number in the range of 0 to 63 into base 64 digit character in the range of '0'-'9', 'A'-'Z', 'a'-'z','-','_'. sYou must pass a long or an intii i0i i#i7i$i=i>i-i?i_sInvalid Base64 value: %iN(R R RRRRt ValueError(R((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytto64\s,    cCsét|ƒtijpt|ƒtijptdƒ‚nd|jo djno |dSd|jo djno |dSd|jo djno |d S|d jod S|d jod Std|ƒ‚dS(snConverts an ordinal character value in the range of 0-9,A-Z,a-z,-,_ to a number in the range of 0-63. sYou must pass a long or an inti0i9iAiZi7iaizi=i-i>i_i?sInvalid Base64 value: %iN(R R RRRR(R((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytfrom64vs,     cCst|ƒtijpt|ƒtijptdƒ‚nd}x6|djo(dt|d@ƒ|f}|d:}qEW|S(ssConverts a number to a string of base64 encoded characters in the range of '0'-'9','A'-'Z,'a'-'z','-','_'. sYou must pass a long or an intRis%s%si?i@(R R RRRR(RR((s3/usr/lib/python2.6/site-packages/rsa/_version200.pyt int2str64s, cCs—t|ƒtijpt|ƒtijptdƒ‚nd}xN|D]F}|d9}t|ƒtijot|ƒ}n|t|ƒ7}qIW|S(sƒConverts a base64 encoded string into an integer. The chars of this string in in the range '0'-'9','A'-'Z','a'-'z','-','_' s You must pass a string or a listii@(R R R R RRR(RRR((s3/usr/lib/python2.6/site-packages/rsa/_version200.pyt str642int¡s, cCs2tti|dƒƒ}ti|ƒ}t|ƒS(sPReads a random integer of approximately nbits bits rounded up to whole bytesg @(RRRtosturandomR(tnbitstnbytest randomdata((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytread_random_int±scCscd}||d}t|ƒdd}t|d|dƒ}ti||ƒ}t|ƒ||S(s9Returns a random integer x with minvalue <= x <= maxvaluei iiii(RtmaxtrandomtrandintR"(tminvaluetmaxvaluet min_nbitstranget rangebytest rangebitsR((s3/usr/lib/python2.6/site-packages/rsa/_version200.pyR%¹s cCsµ|djodSd}x„|djov|d@o;|d|dd?d@o | }n|||}}q||dd?d@o | }n|dL}qW|djodS|S(soCalculates the value of the Jacobi symbol (a/b) where both a and b are positive integers, and b is odd iiii((tatbtresult((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytjacobiÎs      cCsCt||ƒ|}t||dd|ƒ}||jotStS(sUReturns False if n is an Euler pseudo-prime with base x, and True otherwise. ii(R/tpowtFalsetTrue(txtntjtf((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytjacobi_witnessás  cCsCx<t|ƒD].}td|dƒ}t||ƒotSq WtS(sÓCalculates whether n is composite (which is always correct) or prime (which is incorrect with error probability 2**-k) Returns False if the number is composite, and True if it's probably prime. i(R)R%R7R1R2(R4tktiR3((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytrandomized_primality_testingìs  cCst|dƒotStS(s>Returns True if the number is prime, and False otherwise. i(R:R2R1(R((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytis_primeüscCs;x4to,t|ƒ}|dO}t|ƒoPqqW|S(sxReturns a prime number of max. 'math.ceil(nbits/8)*8' bits. In other words: nbits is rounded up to whole bytes. i(R2R"R;(RR((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytgetprimes   cCst||ƒ}|djS(s¤Returns True if a and b are relatively prime, and False if they are not. >>> are_relatively_prime(2, 3) 1 >>> are_relatively_prime(2, 4) 0 i(R (R,R-td((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytare_relatively_primes cCs_||d}||d}t|ƒ}x*to"t|ƒ}||jpPq+q+W||fS(s5Returns a tuple of two different primes of nbits bitsi(R<R2(RtpbitstqbitsRR((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytfind_p_q's   c CsÇd}d}d}d}|}|}x]|djoOt||ƒ}|||}}||||}}||||}}q'W|djo||7}n|djo||7}n|||fS(s@Returns a tuple (r, i, j) such that r = gcd(a, b) = ia + jb ii(tlong( R,R-R3tytlxtlytoatobR((s3/usr/lib/python2.6/site-packages/rsa/_version200.pyt extended_gcd2s"   c Cs||}|d|d}xJtoBtdt|dƒƒ}t||ƒot||ƒoPqqWt||ƒ\}}}|djptd||fƒ‚n|djotdƒ‚n|||djptd|||fƒ‚n||fS(saCalculates an encryption and a decryption key for p and q, and returns them as a tuple (e, d)iiis.e (%d) and phi_n (%d) are not relatively primeis1New extended_gcd shouldn't return negative valuess6e (%d) and i (%d) are not mult. inv. modulo phi_n (%d)(R2R#R<R>RHt Exception( RRRR4tphi_nteR=R9R5((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytcalculate_keysIs    cCs:t|ƒ\}}t|||ƒ\}}||||fS(s|Generate RSA keys of nbits bits. Returns (p, q, e, d). Note: this can take a long time, depending on the key size. (RARL(RRRRKR=((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytgen_keysbscCsXtd|ƒ}t|ƒ\}}}}h|d6||d6h|d6|d6|d6fS(sÌGenerates public and private keys, and returns them as (pub, priv). The public key consists of a dict {e: ..., , n: ....). The private key consists of a dict {d: ...., p: ...., q: ....). i RKR4R=RR(R#RM(RRRRKR=((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytnewkeysmscCs¤t|ƒtijot|ƒ}nt|ƒtij otdƒ‚n|djp ||jotdƒ‚nt|ƒd}|d|>7}t|||ƒS(s@Encrypts a message using encryption key 'ekey', working modulo nsYou must pass a long or intisThe message is too longii( R R RRBRRt OverflowErrorRR0(tmessagetekeyR4tsafebit((s3/usr/lib/python2.6/site-packages/rsa/_version200.pyt encrypt_intyscCs4t|||ƒ}t|ƒd}|d|>8}|S(sLDecrypts a cypher text using the decryption key 'dkey', working modulo nii(R0R(t cyphertexttdkeyR4RPRR((s3/usr/lib/python2.6/site-packages/rsa/_version200.pyt decrypt_int‹scCs=g}x!|D]}|it|ƒƒq Wdi|ƒ}|S(sAbase64encodes chops and combines them into a ',' delimited stringt,(tappendRtjoin(tchopstchipstvaluetencoded((s3/usr/lib/python2.6/site-packages/rsa/_version200.pyt encode64chops–s cCs=|idƒ}g}x!|D]}|it|ƒƒqW|S(s9base64decodes and makes a ',' delimited string into chopsRW(tsplitRXR(RR[RZ((s3/usr/lib/python2.6/site-packages/rsa/_version200.pyt decode64chops£s cCsÀt|ƒ}|d}t|ƒd}|d}||}||djo|d7}ng} xTt|ƒD]F} | |} || | |!} t| ƒ} | i|| ||ƒƒqlWt| ƒS(sÅChops the 'message' into integers that fit into n, leaving room for a safebit to be added to ensure that all messages fold during exponentiation. The MSB of the number n is not independant modulo n (setting it could cause overflow), so use the next lower bit for the safebit. Therefore reserve 2-bits in the number n for non-data bits. Calls specified encryption function for each chop. Used by 'encrypt' and 'sign'. iiii(tlenRR)RRXR^(RPtkeyR4tfuncreftmsglentmbitsRR tblockstcyphertbindextoffsettblockR\((s3/usr/lib/python2.6/site-packages/rsa/_version200.pyt chopstring¯s       cCsId}t|ƒ}x0|D](}||||ƒ}|t|ƒ7}qW|S(s…Glues chops back together into a string. calls funcref(integer, key, n) for each chop. Used by 'decrypt' and 'verify'. R(R`R(RRbR4RcRPRZtcparttmpart((s3/usr/lib/python2.6/site-packages/rsa/_version200.pyt gluechopsÏs cCs8d|jotdƒ‚nt||d|dtƒS(s5Encrypts a string 'message' with the public key 'key'R4s(You must use the public key with encryptRK(RIRkRS(RPRb((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytencryptßs cCs@d|jotdƒ‚nt||d|d|dtƒS(s3Signs a string 'message' with the private key 'key'Rs&You must use the private key with signR=R(RIRkRS(RPRb((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytsignæs cCs@d|jotdƒ‚nt||d|d|dtƒS(s5Decrypts a string 'cypher' with the private key 'key'Rs)You must use the private key with decryptR=R(RIRnRV(RgRb((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytdecryptís cCs8d|jotdƒ‚nt||d|dtƒS(s4Verifies a string 'cypher' with the public key 'key'R4s'You must use the public key with verifyRK(RIRnRV(RgRb((s3/usr/lib/python2.6/site-packages/rsa/_version200.pytverifyôs t__main__RNRoRqRpRr(1t__doc__t __author__t__date__t __version__RRR$tsysR t rsa._compatRtwarningstwarnt__name__tDeprecationWarningRR RRRRRRR"R%R/R7R:R;R<R>RARHRLRMRNRSRVR^R`RkRnRoRpRqRrtdoctestttestmodt__all__(((s3/usr/lib/python2.6/site-packages/rsa/_version200.pyts`