[botan-devel] Patch for botan.py

Uri Blumenthal uri at mit.edu
Tue Apr 14 13:59:16 EDT 2015


This is a relatively minor patch to src/python/botan.py. I needed it, and hopefully it would be useful to others as well.

--- src/python/botan.py.~1~ 2015-03-29 22:14:22.000000000 -0400
+++ src/python/botan.py 2015-04-14 11:11:26.000000000 -0400
@@ -517,7 +517,7 @@
     print "md5", h.final().encode('hex')

     gcm = cipher('AES-128/GCM')
-    print gcm.default_nonce_length(), gcm.update_granularity()
+    print("AES-128/GCM: default nonce=%d update_size=%d" % (gcm.default_nonce_length(), gcm.update_granularity()))
     gcm_dec = cipher('AES-128/GCM', encrypt=False)

     iv = r.get(12)
@@ -535,6 +535,25 @@
     print "gcm pt", pt.encode('hex'), len(pt)
     print "gcm de", dec.encode('hex'), len(dec)

+    ocb = cipher('AES-128/OCB')
+    print("AES-128/OCB: default nonce=%d update_size=%d" % (ocb.default_nonce_length(), ocb.update_granularity()))
+    ocb_dec = cipher('AES-128/OCB', encrypt=False)
+
+    iv = r.get(12)
+    key = r.get(16)
+    pt = r.get(21)
+    ocb.set_key(key)
+    ocb.start(iv)
+    assert len(ocb.update('')) == 0
+    ct = ocb.finish(pt)
+    print "ocb ct", ct.encode('hex')
+
+    ocb_dec.set_key(key)
+    ocb_dec.start(iv)
+    dec = ocb_dec.finish(ct)
+    print "ocb pt", pt.encode('hex'), len(pt)
+    print "ocb de", dec.encode('hex'), len(dec)
+
     rsapriv = private_key('rsa', 1536, r)

     dec = pk_op_decrypt(rsapriv, "EME1(SHA-256)")


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.randombit.net/pipermail/botan-devel/attachments/20150414/59fecef1/attachment.html>


More information about the botan-devel mailing list