5Xc@sdZddlZddlZddlmZdZdZdjZddZ dd Z dd Z d Z e d kre ndS( sLpasslib.crypto._blowfish._gen_files - meta script that generates unrolled.pyiN(tirangecs#djfdt|DS(Ns, c3s|]}t|VqdS(N(tstr(t.0tx(tname(sG/usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pys s(tjoinR(Rtcount((RsG/usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pytvarlistscs,|jd}djfd|DS(sident block of texts c3s%|]}|r|ndVqdS(tN((Rtline(tpadding(sG/usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pys s(tsplitR(tblockR tlines((R sG/usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pyt indent_blocks s ((((S0[l >> 24] + S1[(l >> 16) & 0xff]) ^ S2[(l >> 8) & 0xff]) + S3[l & 0xff]) & 0xffffffff) icCs`xYtdddD]E}||dd|d|dd|dd td tjd d qWdS( Niiis # Feistel substitution on left word (round %(i)d) r ^= %(left)s ^ p%(i1)d # Feistel substitution on right word (round %(i1)d) l ^= %(right)s ^ p%(i2)d titi1iti2tlefttrighttltr(RtBFSTRtreplace(twritetindentR((sG/usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pytrender_encipher s cCs3||dt||d||dddS(Ns2 def encipher(self, l, r): """blowfish encipher a single 64-bit block encoded as two 32-bit ints""" (p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17) = self.P S0, S1, S2, S3 = self.S l ^= p0 is$ return r ^ p17, l (R(RR((sG/usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pytwrite_encipher_function,s   c Cs||dx+tdD]}||ddd|qW||ddt||d||ddxmtdddD]Y}||dd d|d |dt||d||dd d|d |dqW||dd t||d ||d ddS(Ns def expand(self, key_words): """unrolled version of blowfish key expansion""" ##assert len(key_words) >= 18, "size of key_words must be >= 18" P, S = self.P, self.S S0, S1, S2, S3 = S #============================================================= # integrate key #============================================================= iis9 p%(i)d = P[%(i)d] ^ key_words[%(i)d] RsT #============================================================= # update P #============================================================= #------------------------------------------------ # update P[0] and P[1] #------------------------------------------------ l, r = p0, 0 s- p0, p1 = l, r = r ^ p17, l is #------------------------------------------------ # update P[%(i)d] and P[%(i1)d] #------------------------------------------------ l ^= p0 Rs= p%(i)d, p%(i1)d = l, r = r ^ p17, l s #------------------------------------------------ # save changes to original P array #------------------------------------------------ P[:] = (p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17) #============================================================= # update S #============================================================= for box in S: j = 0 while j < 256: l ^= p0 isU box[j], box[j+1] = l, r = r ^ p17, l j += 2 (RR(RRR((sG/usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pytwrite_expand_function@s*        cs}tjjtjjtd}t|dfd}|ddt|ddt|dd|dddS( Ns unrolled.pytwcsw|jdt}|r%||;}n|sFtj|jd}n|rft|d|d}nj|dS(Ntliteralt i(tpoptFalsettextwraptdedenttrstripRR(RtmsgtkwdsR(tfh(sG/usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pyRs isJ """passlib.crypto._blowfish.unrolled - unrolled loop implementation of bcrypt, autogenerated by _gen_files.py currently this override the encipher() and expand() methods with optimized versions, and leaves the other base.py methods alone. """ #================================================================= # imports #================================================================= # pkg from passlib.crypto._blowfish.base import BlowfishEngine as _BlowfishEngine # local __all__ = [ "BlowfishEngine", ] #================================================================= # #================================================================= class BlowfishEngine(_BlowfishEngine): Ris] #================================================================= # eoc #================================================================= #================================================================= # eof #================================================================= (tostpathRtdirnamet__file__tfileRR(ttargetR((R'sG/usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pytmains! t__main__(t__doc__R(R"tpasslib.utils.compatRRRtstripRRRRR.t__name__(((sG/usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pyts      U 2