mgf hmac
'''.split()
-print '/* algorithms.h [generated] */'
-print
+print('/* algorithms.h [generated] */')
+print('')
for i in prps:
- print '#include <catacomb/%s.h>' % i.replace('/', '-')
+ print('#include <catacomb/%s.h>' % i.replace('/', '-'))
for j in pmodes:
- print '#include <catacomb/%s-%s.h>' % (i.replace('/', '-'), j)
+ print('#include <catacomb/%s-%s.h>' % (i.replace('/', '-'), j))
for i in streamciphers:
- print '#include <catacomb/%s.h>' % i.replace('/', '-')
-print
+ print('#include <catacomb/%s.h>' % i.replace('/', '-'))
+print('')
for i in hashes:
- print '#include <catacomb/%s.h>' % i.replace('/', '-')
+ print('#include <catacomb/%s.h>' % i.replace('/', '-'))
for j in hmodes:
- print '#include <catacomb/%s-%s.h>' % (i.replace('/', '-'), j)
-print
+ print('#include <catacomb/%s-%s.h>' % (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):
else:
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('')
def moan(msg):
"""Issue a warning message MSG."""
- print >>stderr, '%s: %s' % (prog, msg)
+ stderr.write('%s: %s\n' % (prog, msg))
def die(msg):
"""Report MSG as a fatal error, and exit."""
def cmd_find(av):
if len(av) != 1: return 1
with PW(file) as pw:
- try: print pw[av[0]]
+ try: print(pw[av[0]])
except KeyError: die("Password `%s' not found" % _excval().args[0])
def cmd_store(av):
if len(av) >= 1: pat = av[0]
else: pat = None
for k in pw:
- if pat is None or fnmatch(k, pat): print k
+ if pat is None or fnmatch(k, pat): print(k)
def cmd_topixie(av):
if len(av) > 2: return 1
### Command-line handling and dispatch.
def version():
- print '%s 1.0.0' % prog
- print 'Backend types: %s' % \
- ' '.join([c.NAME for c in StorageBackend.classes()])
+ print('%s 1.0.0' % prog)
+ print('Backend types: %s' %
+ ' '.join([c.NAME for c in StorageBackend.classes()]))
def usage(fp):
- print >>fp, 'Usage: %s COMMAND [ARGS...]' % prog
+ fp.write('Usage: %s COMMAND [ARGS...]\n' % prog)
def help():
version()
- print
+ print('')
usage(stdout)
- print '''
+ print('''
Maintains passwords or other short secrets securely.
Options:
-f, --file=FILE Where to find the password-safe file.
Commands provided:
-'''
+''')
for c in sorted(commands):
- print '%s %s' % (c, commands[c][1])
+ print('%s %s' % (c, commands[c][1]))
## Choose a default database file.
if 'PWSAFE' in environ:
c = 'find'
try:
if commands[c][0](argv):
- print >>stderr, 'Usage: %s %s %s' % (prog, c, commands[c][1])
+ stderr.write('Usage: %s %s %s\n' % (prog, c, commands[c][1]))
exit(1)
except DecryptError:
die("decryption failure")