X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/8ebc32d8616aeac9892d20cebfbdc1b531b29d2c..aaf8c7aa5f90b6d58c0ee317e19976972eee39ba:/algorithms.py diff --git a/algorithms.py b/algorithms.py index 5730c45..2444382 100644 --- a/algorithms.py +++ b/algorithms.py @@ -51,59 +51,59 @@ hmodes = ''' mgf hmac '''.split() -print '/* algorithms.h [generated] */' -print +print('/* algorithms.h [generated] */') +print('') for i in prps: - print '#include ' % i.replace('/', '-') + print('#include ' % i.replace('/', '-')) for j in pmodes: - print '#include ' % (i.replace('/', '-'), j) + print('#include ' % (i.replace('/', '-'), j)) for i in streamciphers: - print '#include ' % i.replace('/', '-') -print + print('#include ' % i.replace('/', '-')) +print('') for i in hashes: - print '#include ' % i.replace('/', '-') + print('#include ' % i.replace('/', '-')) for j in hmodes: - print '#include ' % (i.replace('/', '-'), j) -print + print('#include ' % (i.replace('/', '-'), j)) +print('') -print '#define PRPS(_) \\' +print('#define PRPS(_) \\') for i in prps: - print '\t_(%s, %s) \\' % (i.upper(), i) -print '\t/* end */' -print + print('\t_(%s, %s) \\' % (i.upper(), i)) +print('\t/* end */') +print('') -print '#define RNGS(_) \\' +print('#define RNGS(_) \\') for i in (cross(prps, ['ofb', 'counter'])): - print ('\t_("%(prim)s-%(mode)s", %(primid)s_keysz, ' + - '%(primid)s_%(mode)srand, RNG_PLAIN, 0) \\') % \ - {'prim': i[0], 'mode': i[1], - 'primid': i[0].replace('-', '_').replace('/', '_')} + print(('\t_("%(prim)s-%(mode)s", %(primid)s_keysz, ' + + '%(primid)s_%(mode)srand, RNG_PLAIN, 0) \\') % + {'prim': i[0], 'mode': i[1], + 'primid': i[0].replace('-', '_').replace('/', '_')}) for i in (cross(hashes, 'mgf')): - print ('\t_("%(prim)s-%(mode)s", %(primid)s_%(mode)skeysz, ' + - '%(primid)s_%(mode)srand, RNG_PLAIN, 0) \\') % \ - {'prim': i[0], 'mode': i[1], - 'primid': i[0].replace('-', '_').replace('/', '_')} -print '\t_("rc4", rc4_keysz, rc4_rand, 0, 0) \\' -print '\t_("seal", seal_keysz, seal_rand, RNG_SEAL, 0) \\' + print(('\t_("%(prim)s-%(mode)s", %(primid)s_%(mode)skeysz, ' + + '%(primid)s_%(mode)srand, RNG_PLAIN, 0) \\') % + {'prim': i[0], 'mode': i[1], + 'primid': i[0].replace('-', '_').replace('/', '_')}) +print('\t_("rc4", rc4_keysz, rc4_rand, 0, 0) \\') +print('\t_("seal", seal_keysz, seal_rand, RNG_SEAL, 0) \\') for i in latindances: for r in ['salsa20', 'xsalsa20', 'chacha', 'xchacha']: if i.startswith(r): root = r break else: - raise ValueError, 'failed to find root name for %s' % i + raise ValueError('failed to find root name for %s' % i) if i.endswith('-ietf'): root += '_ietf' - print ('\t_("%(name)s", %(root)s_keysz, %(id)s_rand, ' + + print(('\t_("%(name)s", %(root)s_keysz, %(id)s_rand, ' + 'RNG_LATIN, %(ROOT)s_NONCESZ) \\') % \ - {'name': i, 'id': i.replace('/', '').replace('-', '_'), - 'root': root, 'ROOT': root.upper()} + {'name': i, 'id': i.replace('/', '').replace('-', '_'), + 'root': root, 'ROOT': root.upper()}) for i in [128, 256]: - print ('\t_("shake%(w)d", shake%(w)d_keysz, cshake%(w)d_rand, ' + + print(('\t_("shake%(w)d", shake%(w)d_keysz, cshake%(w)d_rand, ' + 'RNG_SHAKE, 0) \\') % \ - {'w': i} - print ('\t_("kmac%(w)d", kmac%(w)d_keysz, kmac%(w)d_rand, ' + + {'w': i}) + print(('\t_("kmac%(w)d", kmac%(w)d_keysz, kmac%(w)d_rand, ' + 'RNG_KMAC, 0) \\') % \ - {'w': i} -print '\t/* end */' -print + {'w': i}) +print('\t/* end */') +print('')