/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/pkcs1.pyc (11173B)
Ñò |~úVc @sódZddkZddkZddklZddklZlZlZhedƒd6edƒd6ed ƒd 6ed ƒd 6ed ƒd6Z hei d6ei d6ei d 6ei d 6eid6Zdefd„ƒYZdefd„ƒYZdefd„ƒYZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zdddd dddgZed!jotd"GHddkZxWed#ƒD]IZ ei!ƒ\Z"Z#e"oPne oe d$d%jo d&e GHq™q™Wd'GHndS((sbFunctions for PKCS#1 version 1.5 encryption and signing This module implements certain functionality from PKCS#1 version 1.5. For a very clear example, read http://www.di-mgt.com.au/rsa_alg.html#pkcs1schemes At least 8 bytes of random padding is used when encrypting a message. This makes these methods much more secure than the ones in the ``rsa`` module. WARNING: this module leaks information when decryption fails. The exceptions that are raised contain the Python traceback information, which can be used to deduce where in the process the failure occurred. DO NOT PASS SUCH INFORMATION to your users. iÿÿÿÿN(tb(tcommont transformtcores0 0 *†H†÷ tMD5s0!0 +sSHA-1s010  `†He sSHA-256s0A0  `†He0sSHA-384s0Q0  `†He@sSHA-512t CryptoErrorcBseZdZRS(s-Base class for all exceptions in this module.(t__name__t __module__t__doc__(((s-/usr/lib/python2.6/site-packages/rsa/pkcs1.pyR7stDecryptionErrorcBseZdZRS(sRaised when decryption fails.(RRR(((s-/usr/lib/python2.6/site-packages/rsa/pkcs1.pyR ;stVerificationErrorcBseZdZRS(sRaised when verification fails.(RRR(((s-/usr/lib/python2.6/site-packages/rsa/pkcs1.pyR ?scCs|d}t|ƒ}||jotd||fƒ‚ntdƒ}||d}xgt|ƒ|joS|t|ƒ}ti|dƒ}|itdƒtdƒƒ}||| }qZWt|ƒ|jpt‚tdƒitdƒ|tdƒ|gƒS(sPads the message for encryption, returning the padded message. :return: 00 02 RANDOM_DATA 00 MESSAGE >>> block = _pad_for_encryption(b'hello', 16) >>> len(block) 16 >>> block[0:2] b'\x00\x02' >>> block[-6:] b'\x00hello' i s;%i bytes needed for message, but there is only space for %itiitt(tlent OverflowErrorRtosturandomtreplacetAssertionErrortjoin(tmessaget target_lengtht max_msglengtht msglengthtpaddingtpadding_lengtht needed_bytest new_padding((s-/usr/lib/python2.6/site-packages/rsa/pkcs1.pyt_pad_for_encryptionCs$     cCs€|d}t|ƒ}||jotd||fƒ‚n||d}tdƒitdƒ|tdƒtdƒ|gƒS(sjPads the message for signing, returning the padded message. The padding is always a repetition of FF bytes. :return: 00 01 PADDING 00 MESSAGE >>> block = _pad_for_signing(b'hello', 16) >>> len(block) 16 >>> block[0:2] b'\x00\x01' >>> block[-6:] b'\x00hello' >>> block[2:-6] b'\xff\xff\xff\xff\xff\xff\xff\xff' i s;%i bytes needed for message, but there is only space for %iiR tsÿR (RRRR(RRRRR((s-/usr/lib/python2.6/site-packages/rsa/pkcs1.pyt_pad_for_signingqs     cCsati|iƒ}t||ƒ}ti|ƒ}ti||i|iƒ}ti ||ƒ}|S(sÂEncrypts the given message using PKCS#1 v1.5 :param message: the message to encrypt. Must be a byte string no longer than ``k-11`` bytes, where ``k`` is the number of bytes needed to encode the ``n`` component of the public key. :param pub_key: the :py:class:`rsa.PublicKey` to encrypt with. :raise OverflowError: when the message is too large to fit in the padded block. >>> from rsa import key, common >>> (pub_key, priv_key) = key.newkeys(256) >>> message = b'hello' >>> crypto = encrypt(message, pub_key) The crypto text should be just as long as the public key 'n' component: >>> len(crypto) == common.byte_size(pub_key.n) True ( Rt byte_sizetnRRt bytes2intRt encrypt_inttet int2bytes(Rtpub_keyt keylengthtpaddedtpayloadt encryptedtblock((s-/usr/lib/python2.6/site-packages/rsa/pkcs1.pytencrypt“s cCs¶ti|iƒ}ti|ƒ}|i|ƒ}ti||ƒ}|dd!tdƒjotdƒ‚ny|i tdƒdƒ}Wnt j otdƒ‚nX||dS(saDecrypts the given message using PKCS#1 v1.5 The decryption is considered 'failed' when the resulting cleartext doesn't start with the bytes 00 02, or when the 00 byte between the padding and the message cannot be found. :param crypto: the crypto text as returned by :py:func:`rsa.encrypt` :param priv_key: the :py:class:`rsa.PrivateKey` to decrypt with. :raise DecryptionError: when the decryption fails. No details are given as to why the code thinks the decryption fails, as this would leak information about the private key. >>> import rsa >>> (pub_key, priv_key) = rsa.newkeys(256) It works with strings: >>> crypto = encrypt(b'hello', pub_key) >>> decrypt(crypto, priv_key) b'hello' And with binary data: >>> crypto = encrypt(b'\x00\x00\x00\x00\x01', pub_key) >>> decrypt(crypto, priv_key) b'\x00\x00\x00\x00\x01' Altering the encrypted information will *likely* cause a :py:class:`rsa.pkcs1.DecryptionError`. If you want to be *sure*, use :py:func:`rsa.sign`. .. warning:: Never display the stack trace of a :py:class:`rsa.pkcs1.DecryptionError` exception. It shows where in the code the exception occurred, and thus leaks information about the key. It's only a tiny bit of information, but every bit makes cracking the keys easier. >>> crypto = encrypt(b'hello', pub_key) >>> crypto = crypto[0:5] + b'X' + crypto[6:] # change a byte >>> decrypt(crypto, priv_key) Traceback (most recent call last): ... rsa.pkcs1.DecryptionError: Decryption failed iiR sDecryption failedR i( RR R!RR"tblinded_decryptR%RR tindext ValueError(tcryptotpriv_keyt blocksizeR*t decryptedt cleartexttsep_idx((s-/usr/lib/python2.6/site-packages/rsa/pkcs1.pytdecrypt³s3c Cs™|tjotd|ƒ‚nt|}t||ƒ}||}ti|iƒ}t||ƒ}ti|ƒ}|i |ƒ}ti ||ƒ} | S(s¼Signs the message with the private key. Hashes the message, then signs the hash with the given key. This is known as a "detached signature", because the message itself isn't altered. :param message: the message to sign. Can be an 8-bit string or a file-like object. If ``message`` has a ``read()`` method, it is assumed to be a file-like object. :param priv_key: the :py:class:`rsa.PrivateKey` to sign with :param hash: the hash method used on the message. Use 'MD5', 'SHA-1', 'SHA-256', 'SHA-384' or 'SHA-512'. :return: a message signature block. :raise OverflowError: if the private key is too small to contain the requested hash. sInvalid hash method: %s( t HASH_ASN1R/t_hashRR R!RRR"tblinded_encryptR%( RR1thashtasn1codeR4R'R(R)R*R+((s-/usr/lib/python2.6/site-packages/rsa/pkcs1.pytsignøs   c Cs§ti|iƒ}ti|ƒ}ti||i|iƒ}ti||ƒ}t |ƒ}t ||ƒ}t ||} t | |ƒ} | |jot dƒ‚ntS(s!Verifies that the signature matches the message. The hash method is detected automatically from the signature. :param message: the signed message. Can be an 8-bit string or a file-like object. If ``message`` has a ``read()`` method, it is assumed to be a file-like object. :param signature: the signature block, as created with :py:func:`rsa.sign`. :param pub_key: the :py:class:`rsa.PublicKey` of the person signing the message. :raise VerificationError: when the signature doesn't match the message. sVerification failed(RR R!RR"Rt decrypt_intR$R%t_find_method_hashR8R7RR tTrue( Rt signatureR&R'R*R3tclearsigt method_namet message_hashR4texpected((s-/usr/lib/python2.6/site-packages/rsa/pkcs1.pytverifys  cCs¬|tjotd|ƒ‚nt|}|ƒ}t|dƒoQt|idƒo>ddkl}x8|i|dƒD]}|i|ƒqzWn|i|ƒ|iƒS(s4Returns the message digest. :param message: the signed message. Can be an 8-bit string or a file-like object. If ``message`` has a ``read()`` method, it is assumed to be a file-like object. :param method_name: the hash method, must be a key of :py:const:`HASH_METHODS`. sInvalid hash method: %streadt__call__i(tvarblocki( t HASH_METHODSR/thasattrRFR RHtyield_fixedblockstupdatetdigest(RRBtmethodthasherRHR+((s-/usr/lib/python2.6/site-packages/rsa/pkcs1.pyR8@s   # cCs?x,tiƒD]\}}||jo|Sq Wtdƒ‚dS(s³Finds the hash method. :param clearsig: full padded ASN1 and hash. :return: the used hash method. :raise VerificationFailed: when the hash method cannot be found sVerification failedN(R7titemsR (RAthashnameR;((s-/usr/lib/python2.6/site-packages/rsa/pkcs1.pyR>_s    R,R6R<REt__main__s'Running doctests 1000x or until failureièidis%i timess Doctests done($RthashlibRt rsa._compatRtrsaRRRR7tmd5tsha1tsha256tsha384tsha512RIt ExceptionRR R RRR,R6R<RER8R>t__all__Rtdoctesttrangetcountttestmodtfailuresttests(((s-/usr/lib/python2.6/site-packages/rsa/pkcs1.pytsP            . " E & "