Skip to content

Commit 4b50414

Browse files
author
Christophe Oosterlynck
committed
RadioGatun: added testvectors
tests for radiogatun[32] and radiogatun[64] from http://radiogatun.noekeon.org/
1 parent 8a1ac3d commit 4b50414

File tree

4 files changed

+87
-12
lines changed

4 files changed

+87
-12
lines changed
Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,53 @@
1-
from pyradiogatun import new
1+
from pyradiogatun import RadioGatunType
22

33
__all__ = ['new']
44

5-
#def new(wldata=""):
6-
# """Return a new RadioGatun hash object
7-
#
8-
# wl = wordlength (in bits) of the RadioGatun hash method
9-
# between 1 and 64 (default = 64)
10-
# arg = if present, the method call update(arg) is made
11-
# """
12-
# return pyradiogatun.new(data)
5+
def new(wl=64,arg=None):
6+
"""Return a new RadioGatun hash object
137
8+
wl = wordlength (in bits) of the RadioGatun hash method
9+
between 1 and 64 (default = 64)
10+
arg = if present, the method call update(arg) is made
11+
12+
EXAMPLES: (testvectors from: http://radiogatun.noekeon.org/)
13+
==========
14+
>>> import python_RadioGatun
15+
16+
radiogatun[64]
17+
---------------
18+
>>> hasher = python_RadioGatun.new()
19+
>>> hasher.update('1234567890123456')
20+
>>> hasher.hexdigest()
21+
'caaec14b5b4a7960d6854709770e3071d635d60224f58aa385867e549ef4cc42'
22+
23+
>>> hasher = python_RadioGatun.new()
24+
>>> hasher.update('Santa Barbara, California')
25+
>>> hasher.hexdigest()
26+
'0d08daf2354fa95aaa5b6a50f514384ecdd35940252e0631002e600e13cd285f'
27+
28+
radiogatun[32]
29+
---------------
30+
>>> hasher = python_RadioGatun.new(32)
31+
>>> hasher.update('1234567890123456')
32+
>>> hasher.hexdigest()
33+
'59612324f3f42d3096e69125d2733b86143ae668ae9ed561ad785e0eac8dba25'
34+
35+
>>> hasher = python_RadioGatun.new(32)
36+
>>> hasher.update('Santa Barbara, California')
37+
>>> hasher.hexdigest()
38+
'041666388ef9655d48996a66dada1193d6646012a7b25a24fb10e6075cf0fc54'
39+
"""
40+
41+
crypto = RadioGatunType(wl)
42+
if arg:
43+
crypto.update(arg)
44+
45+
return crypto
46+
47+
def _test():
48+
import doctest
49+
doctest.testmod()
50+
51+
if __name__ == "__main__":
52+
print "DOCTEST running... no messages = all good"
53+
_test()

0 commit comments

Comments
 (0)