/opt/alt/python27/lib64/python2.7/site-packages/Crypto/Protocol
NameSizeModeActions
AllOrNothing.py118970644editdlrm
AllOrNothing.pyc81840644editdlrm
AllOrNothing.pyo81370644editdlrm
Chaffing.py102450644editdlrm
Chaffing.pyc86530644editdlrm
Chaffing.pyo86000644editdlrm
KDF.py50710644editdlrm
KDF.pyc47170644editdlrm
KDF.pyo47170644editdlrm
__init__.py15730644editdlrm
__init__.pyc7960644editdlrm
__init__.pyo7960644editdlrm
Edit: /opt/alt/python27/lib64/python2.7/site-packages/Crypto/Protocol/AllOrNothing.pyo (8137B)
Ñò Â/¾Oc@sldZdZddkZddkZddklZlZddkTd„Zdd!d„ƒYZ e d joûddkZddk Z ddk Z d Z d Zd Zdd „Zy,e i eiddddgƒ\ZZWn%e ij oZedeƒnXeoeddƒnx]eD]U\ZZed"joed ƒq"ed#jo eZq"ed$jo dZq"q"WededddgƒZe eƒZdGHeGHdGHeieeƒƒZdGHxYee e!eƒƒeƒD]<\Z"Z#de"Geoee#ƒGHqèe i$e#ƒd GHqèWe eƒZ%e%i&eƒZ'e'eeƒjo dGHqhd GHndS(%sãThis file implements all-or-nothing package transformations. An all-or-nothing package transformation is one in which some text is transformed into message blocks, such that all blocks must be obtained before the reverse transformation can be applied. Thus, if any blocks are corrupted or lost, the original message cannot be reproduced. An all-or-nothing package transformation is not encryption, although a block cipher algorithm is used. The encryption key is randomly generated and is extractable from the message blocks. This class implements the All-Or-Nothing package transformation algorithm described in: Ronald L. Rivest. "All-Or-Nothing Encryption and The Package Transform" http://theory.lcs.mit.edu/~rivest/fusion.pdf s$Id$iÿÿÿÿN(t bytes_to_longt long_to_bytes(t*cCs/d}y||7}Wntj odSXdS(Nii(t TypeError(txttest((sO/opt/alt/python27/lib64/python2.7/site-packages/Crypto/Protocol/AllOrNothing.pytisInt4s t AllOrNothingcBsMeZdZddd„ZedƒZd„Zd„Zd„Z d„Z RS(sVClass implementing the All-or-Nothing package transform. Methods for subclassing: _inventkey(key_size): Returns a randomly generated key. Subclasses can use this to implement better random key generating algorithms. The default algorithm is probably not very cryptographically secure. cCsY||_||_||_|i|_t|iƒ p|idjo d|_ndS(sDAllOrNothing(ciphermodule, mode=None, IV=None) ciphermodule is a module implementing the cipher algorithm to use. It must provide the PEP272 interface. Note that the encryption key is randomly generated automatically when needed. Optional arguments mode and IV are passed directly through to the ciphermodule.new() method; they are the feedback mode and initialization vector to use. All three arguments must be the same for the object used to create the digest, and to undigest'ify the message blocks. iiN(t_AllOrNothing__ciphermodulet_AllOrNothing__modet_AllOrNothing__IVtkey_sizet_AllOrNothing__key_sizeR(tselft ciphermoduletmodetIV((sO/opt/alt/python27/lib64/python2.7/site-packages/Crypto/Protocol/AllOrNothing.pyt__init__Hs     !iicCs |i|iƒ}|i|i}|i|ƒ}|i|ƒ}|ii}|t|ƒ|}|tdƒ|}tt|ƒ|ƒd}g} g} xªt d|dƒD]•} | d|} | |} || | !}|i t | |ƒƒ}t |ƒt |ƒA}| i |ƒ|i t || A|ƒƒ}| i t |ƒƒq­W| d} |i t | |ƒƒ}|t |ƒA}| i |ƒ|i t || A|ƒƒ}| i t |ƒƒt |ƒtti| ƒA}| i |ƒg}| D]} |t | |iiƒqè~S(s"digest(text:string) : [string] Perform the All-or-Nothing package transform on the given string. Output is a list of message blocks describing the transformed text, where each block is a string of bit length equal to the ciphermodule's block_size. t ii(t _inventkeyR t_AllOrNothing__K0digitt_AllOrNothing__newcipherRt block_sizetlentbtdivmodtrangetencryptRRtappendtreducetoperatortxor(R ttexttkeytK0tmcipherthcipherRtpadbyteststblocksthashestitstarttendtmit cipherblocktmtickithit mtick_stickt_[1]((sO/opt/alt/python27/lib64/python2.7/site-packages/Crypto/Protocol/AllOrNothing.pytdigest_s:        c Cst|ƒdjo td‚ntt|ƒ}|i|i}|i|ƒ}|ii}g}xZt dt|ƒƒD]C}||d|A}|i t ||ƒƒ}|i t|ƒƒqvW|dt ti|ƒA} |it | |iƒƒ} g} xZt dt|ƒƒD]C}| i t ||ƒƒ} ||dt| ƒA} | i | ƒqWt| dƒ}tdƒitt | d ƒƒ}|| S(s5undigest(blocks : [string]) : string Perform the reverse package transformation on a list of message blocks. Note that the ciphermodule used for both transformations must be the same. blocks is a list of strings of bit length equal to the ciphermodule's block_size. isList must be at least length 2.iiÿÿÿÿt(Rt ValueErrortmapRRR RRRRRRRRRRtintRtjoin(R R'R"R$RR(R)R.R/R!R#tpartsR-R,R%R ((sO/opt/alt/python27/lib64/python2.7/site-packages/Crypto/Protocol/AllOrNothing.pytundigest±s.   "cCs#ddkl}|iƒi|ƒS(Niÿÿÿÿ(tRandom(tCryptoR:tnewtread(R R R:((sO/opt/alt/python27/lib64/python2.7/site-packages/Crypto/Protocol/AllOrNothing.pyRçscCsx|idjo!|idjo|ii|ƒS|idjo|ii||iƒS|ii||i|iƒSdS(N(R tNoneR RR<(R R!((sO/opt/alt/python27/lib64/python2.7/site-packages/Crypto/Protocol/AllOrNothing.pyt __newcipherìs  N( t__name__t __module__t__doc__R>RtbchrRR2R9RR(((sO/opt/alt/python27/lib64/python2.7/site-packages/Crypto/Protocol/AllOrNothing.pyR<s   R 6 t__main__sDTest module usage: %(program)s [-c cipher] [-l] [-h] Where: --cipher module -c module Cipher module to use. Default: %(ciphermodule)s --aslong -l Print the encoded message blocks as long integers instead of base64 encoded strings --help -h Print this help message tAESicCs?|o |GHnthtidd6td6GHti|ƒdS(NitprogramR(tusagemsgtsystargvRtexit(tcodetmsg((sO/opt/alt/python27/lib64/python2.7/site-packages/Crypto/Protocol/AllOrNothing.pytusages   isc:lscipher=taslongsToo many argumentss-hs--helps-cs--ciphers-ls--aslongsCrypto.Cipher.R<sOriginal text: ==========s ==========smessage blocks:s %3ds They match!s They differ!((s-hs--help(s-cs--cipher(s-ls--aslong((RBt __revision__RRHtCrypto.Util.numberRRtCrypto.Util.py3compatRRR@tgetopttbase64RGRRNR>RMRItoptstargsterrorRLtopttargt __import__tmoduleRR2Rt msgblockstzipRRR)tblkt encodestringtyR9R (((sO/opt/alt/python27/lib64/python2.7/site-packages/Crypto/Protocol/AllOrNothing.pyt+s`    º