diff test.py @ 13:19d8314d9fe4

update for new data padding scheme
author Matt Johnston <matt@ucc.asn.au>
date Wed, 12 Jun 2013 23:49:19 +0800
parents 3aa92c7f379c
children 735c406b4c57
line wrap: on
line diff
--- a/test.py	Wed Jun 12 23:00:25 2013 +0800
+++ b/test.py	Wed Jun 12 23:49:19 2013 +0800
@@ -1,4 +1,4 @@
-#!./bin/python
+#!/Users/matt/tmp/crypto/bin/python
 
 from Crypto.Cipher import AES
 import hashlib
@@ -17,7 +17,7 @@
 
 
 cli_key = 'yyuuiiooddeeffqqddii'
-enc_key = 'aabbccddeeffgghh'
+enc_key = 'aabbccddeeffgghh\0\0\0\0'
 indata =  '1234567890123456'
 
 print "cli_key %s, hex %s" % (cli_key, hexlify(cli_key))
@@ -26,11 +26,15 @@
 
 print "data    %s, hex %s" % (indata, hexlify(indata))
 
-a = AES.new(enc_key)
+a = AES.new(enc_key[:16])
 enc = a.encrypt(indata)
 
 print "enc     hex %s" % hexlify(enc)
 
-h = hmac.new(cli_key, enc, hashlib.sha1).digest()
-print "hmac hex %s" % hexlify(h)
+h = hmac.new(enc_key, 'D:' + enc, hashlib.sha1).digest()
+print "enc hmac hex %s" % hexlify(h)
 
+h = hmac.new(cli_key, 'H:' + cli_key, hashlib.sha1).digest()
+print "hmac test hex %s" % hexlify(h)
+
+