Mercurial > pihelp
changeset 14:c17f2e4a7a8b
merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 12 Jun 2013 23:49:27 +0800 |
parents | 19d8314d9fe4 (diff) aec45c673a60 (current diff) |
children | 915be6f0ff13 |
files | |
diffstat | 1 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/test.py Wed Jun 12 23:48:49 2013 +0800 +++ b/test.py Wed Jun 12 23:49:27 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) + +