Viewing File: /usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pyo
ó
ö
5Xc @ s“ d Z d d l Z d d l Z d d l m Z d „ Z d „ Z d j ƒ Z d d „ Z d d „ Z
d d
„ Z d „ Z e
d k r e ƒ n d S(
sL passlib.crypto._blowfish._gen_files - meta script that generates unrolled.pyiÿÿÿÿN( t irangec s# d j ‡ f d † t | ƒ Dƒ ƒ S( Ns , c 3 s | ] } ˆ t | ƒ Vq d S( N( t str( t .0t x( t name( sG /usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pys <genexpr> s ( t joinR ( R t count( ( R sG /usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pyt varlist s c s, | j d ƒ } d j ‡ f d † | Dƒ ƒ S( s ident block of texts
c 3 s% | ] } | r ˆ | n d Vq d S( t N( ( R t line( t padding( sG /usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pys <genexpr> s ( t splitR ( t blockR
t lines( ( R
sG /usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pyt indent_block s s ((((S0[l >> 24] + S1[(l >> 16) & 0xff]) ^ S2[(l >> 8) & 0xff]) +
S3[l & 0xff]) & 0xffffffff)
i c C s` xY t d d d ƒ D]E } | | d d | d | d d | d d t d
t j d d ƒ ƒq Wd S(
Ni i i sÐ # 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
t it i1i t i2t leftt rightt lt r( R t BFSTRt replace( t writet indentR ( ( sG /usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pyt render_encipher s c C s3 | | d ƒ t | | d ƒ | | d d ƒ d S( 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
i s$
return r ^ p17, l
( R ( R R ( ( sG /usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pyt write_encipher_function, s
c C s | | d ƒ x+ t d ƒ D] } | | d d d | ƒq W| | d d ƒ t | | d ƒ | | d d ƒ xm t d d d ƒ D]Y } | | d d d | d
| d ƒt | | d ƒ | | d d d | d
| d ƒq W| | d d ƒ t | | d
ƒ | | d
d ƒ d S( 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
#=============================================================
i i s9 p%(i)d = P[%(i)d] ^ key_words[%(i)d]
R sT
#=============================================================
# update P
#=============================================================
#------------------------------------------------
# update P[0] and P[1]
#------------------------------------------------
l, r = p0, 0
s-
p0, p1 = l, r = r ^ p17, l
i sÉ #------------------------------------------------
# update P[%(i)d] and P[%(i1)d]
#------------------------------------------------
l ^= p0
R s= 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
i sU
box[j], box[j+1] = l, r = r ^ p17, l
j += 2
( R R ( R R R ( ( sG /usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pyt write_expand_function@ s*
c s} t j j t j j t ƒ d ƒ } t | d ƒ ‰ ‡ f d † } | d d ƒ t | d d ƒt | d d ƒ| d d ƒ d S( Ns unrolled.pyt wc sw | j d t ƒ } | r% | | ;} n | sF t j | j d ƒ ƒ } n | rf t | d | d ƒ } n ˆ j | ƒ d S( Nt literalt i ( t popt Falset textwrapt dedentt rstripR R ( R t msgt kwdsR ( t fh( sG /usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pyR ™ s
i sJ """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):
R i s] #=================================================================
# eoc
#=================================================================
#=================================================================
# eof
#=================================================================
( t ost pathR t dirnamet __file__t fileR R ( t targetR ( ( R' sG /usr/lib/python2.7/site-packages/passlib/crypto/_blowfish/_gen_files.pyt main• s !
t __main__( t __doc__R( R"