-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchal28.py
executable file
·35 lines (27 loc) · 989 Bytes
/
chal28.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
# chal28.py - Implement SHA-1 keyed MAC
#
# Copyright (C) 2015 Andrew J. Zimolzak <[email protected]>,
# and licensed under GNU GPL version 3. Full notice is found in
# the file 'LICENSE' in the same directory as this file.
from cryptopals import warn, secret_prefix_mac, unknown_key as k_true
m_true = 'Vanilla'
m_tamper = ['vanilla', 'Vanilla ', 'Vanilla\x00', 'Vanille']
lost_key = ['YELLOW SUBMARINE',
'abcdefghijklmnop',
'1234567890123456',
' ',
'_______--_______',
'\x00' * 16]
authentic = secret_prefix_mac(m_true, k_true)
print "Message\t\t\t", authentic
#### tests, if any ####
for m in m_tamper:
mac = secret_prefix_mac(m, k_true)
print "Tampered message\t", mac
assert mac != authentic
for l in lost_key:
mac = secret_prefix_mac(m_true, l)
print "Lost key\t\t", mac
assert mac != authentic
warn("Passed assertions:", __file__)