aboutsummaryrefslogtreecommitdiffstats
path: root/src/python/botan.py
diff options
context:
space:
mode:
authorlloyd <[email protected]>2015-03-01 16:47:44 +0000
committerlloyd <[email protected]>2015-03-01 16:47:44 +0000
commit38cc1747b615081539893aa6c8bc02e6e1960d25 (patch)
treec504fc297905f434a5c1dd5a359412b5e8d4bf1b /src/python/botan.py
parenta9aebb6c08eb7d78a62283c33ece17b73e7c2f8c (diff)
Fix decrypt in FFI/Python. Github issue 53
Diffstat (limited to 'src/python/botan.py')
-rwxr-xr-xsrc/python/botan.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/python/botan.py b/src/python/botan.py
index 919a426b7..129aeaebb 100755
--- a/src/python/botan.py
+++ b/src/python/botan.py
@@ -517,11 +517,22 @@ def test():
print "md5", h.final().encode('hex')
gcm = cipher('AES-128/GCM')
- gcm.set_key('00000000000000000000000000000000'.decode('hex'))
- gcm.start('000000000000000000000000'.decode('hex'))
- gcm.update('')
- gcm.update('')
- print 'gcm', gcm.finish('00000000000000000000000000000000'.decode('hex')).encode('hex')
+ gcm_dec = cipher('AES-128/GCM', encrypt=False)
+
+ iv = r.get(12)
+ key = r.get(16)
+ pt = r.get(21)
+ gcm.set_key(key)
+ gcm.start(iv)
+ assert len(gcm.update('')) == 0
+ ct = gcm.finish(pt)
+ print "gcm ct", ct.encode('hex')
+
+ gcm_dec.set_key(key)
+ gcm_dec.start(iv)
+ dec = gcm_dec.finish(ct)
+ print "gcm pt", pt.encode('hex'), len(pt)
+ print "gcm de", dec.encode('hex'), len(dec)
rsapriv = private_key('rsa', 1536, r)