From: Mark Wooding Date: Wed, 6 Sep 2017 20:07:55 +0000 (+0100) Subject: mon/tripemon.in (cryptolayout): Use formatting functions for details. X-Git-Tag: 1.5.0~131 X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/commitdiff_plain/fd0e15eecc328bd31e17c93a0fafa65aca6e2bb5 mon/tripemon.in (cryptolayout): Use formatting functions for details. This fixes two bugs. * Firstly, key, block, tag, and hash sizes are no longer wrong by a factor of 8 (because they're described as being in bits, but are actually shown in bytes since Python format strings can't do arithmetic). * And, secondly, new bulk crypto transforms don't always report things like `cipher-blksz' or `mac-keysz', so there's additional logic for coping with these situations. Also, report the bulk transform, because it's probably useful. The first of these bugs didn't affect the CryptoInfo window, which calculates everything properly, but the second does, and this commit doesn't change that. --- diff --git a/mon/tripemon.in b/mon/tripemon.in index 360d44d4..c6607607 100644 --- a/mon/tripemon.in +++ b/mon/tripemon.in @@ -1268,10 +1268,22 @@ cryptolayout = \ '%(kx-group)s ' '(%(kx-group-order-bits)s-bit order, ' '%(kx-group-elt-bits)s-bit elements)'), - ('Cipher', - '%(cipher)s (%(cipher-keysz)s-bit key, %(cipher-blksz)s-bit block)'), - ('Mac', '%(mac)s (%(mac-keysz)s-bit key, %(mac-tagsz)s-bit tag)'), - ('Hash', '%(hash)s (%(hash-sz)s-bit output)')] + ('Bulk crypto transform', + '%(bulk-transform)s (%(bulk-overhead)s byte overhead)'), + ('Data encryption', lambda d: '%s (%s; %s)' % ( + d['cipher'], + '%d-bit key' % (8*int(d['cipher-keysz'])), + d.get('cipher-blksz', '0') == '0' + and 'stream cipher' + or '%d-bit block' % (8*int(d['cipher-blksz'])))), + ('Message authentication', lambda d: '%s (%s; %s)' % ( + d['mac'], + d.get('mac-keysz') is None + and 'one-time MAC' + or '%d-bit key' % (8*int(d['mac-keysz'])), + '%d-bit tag' % (8*int(d['mac-tagsz'])))), + ('Hash', lambda d: '%s (%d-bit output)' % + (d['hash'], 8*int(d['hash-sz'])))] statslayout = \ [('Start time', '%(start-time)s'),