Skip to content

Commit ffac5d7

Browse files
author
Christophe Oosterlynck
committed
RadioGatun: "count" is int instead of list
1 parent 16a238f commit ffac5d7

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/CryptoPlus/Hash/pyradiogatun.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def Mill(a,wl):
107107
return A
108108

109109
class RadioGatunType:
110-
"An implementation of the MD5 hash function in pure Python."
110+
"An implementation of the RadioGatun hash function in pure Python."
111111

112112
def __init__(self,wl):
113113
"""Initialisation.
@@ -125,7 +125,7 @@ def __init__(self,wl):
125125

126126
# Initial message length in bits(!).
127127
self.length = 0L
128-
self.count = [0, 0]
128+
self.count = 0
129129

130130
# Initial empty message as a sequence of bytes (8 bit characters).
131131
self.input = ""
@@ -137,12 +137,14 @@ def __init__(self,wl):
137137

138138
def init(self):
139139
"""Initialize the message-digest and set all fields to zero.
140+
141+
Can be used to reinitialize the hash object
140142
"""
141143

142144
self.S = stateInit()
143145

144146
self.length = 0L
145-
self.count = [0, 0]
147+
self.count = 0
146148
self.input = ""
147149

148150
def _transform(self, inp):
@@ -179,10 +181,10 @@ def update(self, inBuf):
179181
leninBuf = long(len(inBuf))
180182

181183
# Compute number of bytes mod 64.
182-
index = (self.count[0] >> 3) % self.blocklength
184+
index = (self.count >> 3) % self.blocklength
183185

184186
# Update number of bits.
185-
self.count[0] = self.count[0] + (leninBuf << 3)
187+
self.count = self.count + (leninBuf << 3)
186188

187189
partLen = self.blocklength - index
188190

@@ -220,14 +222,14 @@ def digest(self, length=256):
220222

221223
S = self.S
222224
inp = "" + self.input
223-
count = [] + self.count
225+
count = self.count
224226

225-
index = (self.count[0] >> 3) % self.blocklength
227+
index = (self.count >> 3) % self.blocklength
226228

227229
if index < self.blocklength:
228230
padLen = self.blocklength - index
229231
else:
230-
padLen = 2*self.blocklength - index
232+
padLen = 2*self.blocklength - index
231233

232234
#provide padding chars encoded as little endian
233235
padding = ['\001'] + ['\000'] * (padLen - 1)

0 commit comments

Comments
 (0)