summaryrefslogtreecommitdiff
path: root/passlib/utils/_blowfish/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'passlib/utils/_blowfish/base.py')
-rw-r--r--passlib/utils/_blowfish/base.py46
1 files changed, 23 insertions, 23 deletions
diff --git a/passlib/utils/_blowfish/base.py b/passlib/utils/_blowfish/base.py
index e725e7f..65b6da0 100644
--- a/passlib/utils/_blowfish/base.py
+++ b/passlib/utils/_blowfish/base.py
@@ -1,20 +1,20 @@
"""passlib.utils._blowfish.base - unoptimized pure-python blowfish engine"""
-#=========================================================
-#imports
-#=========================================================
-#core
+#=============================================================================
+# imports
+#=============================================================================
+# core
import struct
-#pkg
+# pkg
from passlib.utils.compat import bytes
from passlib.utils import repeat_string
-#local
+# local
__all__ = [
"BlowfishEngine",
]
-#=========================================================
+#=============================================================================
# blowfish constants
-#=========================================================
+#=============================================================================
BLOWFISH_P = BLOWFISH_S = None
def _init_constants():
@@ -304,9 +304,9 @@ def _init_constants():
]
]
-#=========================================================
+#=============================================================================
# engine
-#=========================================================
+#=============================================================================
class BlowfishEngine(object):
def __init__(self):
@@ -315,9 +315,9 @@ class BlowfishEngine(object):
self.P = list(BLOWFISH_P)
self.S = [ list(box) for box in BLOWFISH_S ]
- #=========================================================
+ #===================================================================
# common helpers
- #=========================================================
+ #===================================================================
@staticmethod
def key_to_words(data, size=18):
"""convert data to tuple of <size> 4-byte integers, repeating or
@@ -335,9 +335,9 @@ class BlowfishEngine(object):
# unpack
return struct.unpack(">%dI" % (size,), data)
- #=========================================================
+ #===================================================================
# blowfish routines
- #=========================================================
+ #===================================================================
def encipher(self, l, r):
"loop version of blowfish encipher routine"
P, S = self.P, self.S
@@ -375,9 +375,9 @@ class BlowfishEngine(object):
box[i], box[i+1] = l,r = encipher(l,r)
i += 2
- #=========================================================
+ #===================================================================
# eks-blowfish routines
- #=========================================================
+ #===================================================================
def eks_expand(self, key_words, salt_words):
"perform EKS version of Blowfish keyschedule setup"
# NOTE: this is the same as expand(), except for the addition
@@ -401,7 +401,7 @@ class BlowfishEngine(object):
s += 2
if s == salt_size:
s = 0
- P[i], P[i+1] = l,r = encipher(l,r) #next()
+ P[i], P[i+1] = l,r = encipher(l,r) # next()
i += 2
for box in S:
@@ -412,7 +412,7 @@ class BlowfishEngine(object):
s += 2
if s == salt_size:
s = 0
- box[i], box[i+1] = l,r = encipher(l,r) #next()
+ box[i], box[i+1] = l,r = encipher(l,r) # next()
i += 2
def eks_rounds_expand0(self, key_words, salt_words, rounds):
@@ -433,10 +433,10 @@ class BlowfishEngine(object):
n += 1
return l, r
- #=========================================================
+ #===================================================================
# eoc
- #=========================================================
+ #===================================================================
-#=========================================================
-#eof
-#=========================================================
+#=============================================================================
+# eof
+#=============================================================================