From 2086a68c53cb99e158f617289a2b6d36f4efe20a Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Mon, 13 Nov 2023 15:34:21 +0100 Subject: [PATCH] Key id not needed on keygen. It also returns the fresh new generated key id. Signed-off-by: Pol Henarejos --- tools/pico-hsm-tool.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/pico-hsm-tool.py b/tools/pico-hsm-tool.py index 56c5f75..0be2e36 100644 --- a/tools/pico-hsm-tool.py +++ b/tools/pico-hsm-tool.py @@ -117,7 +117,7 @@ def parse_args(): parser_cipher.add_argument('--file-out', help='File to write the result.') parser_cipher.add_argument('--aad', help='Specifies the authentication data (it can be a string or hex string. Combine with --hex if necesary).') parser_cipher.add_argument('--hex', help='Parses the AAD parameter as a hex string (for binary data).', action='store_true') - parser_cipher.add_argument('-k', '--key', help='The private key index', metavar='KEY_ID', required=True) + parser_cipher.add_argument('-k', '--key', help='The private key index', metavar='KEY_ID', required=all(['keygen' not in s for s in sys.argv])) parser_cipher.add_argument('-s', '--key-size', default=32, help='Size of the key in bytes.') parser_x25519 = argparse.ArgumentParser(add_help=False) @@ -363,6 +363,8 @@ def secure(picohsm, args): def cipher(picohsm, args): if (args.subcommand == 'keygen'): ret = picohsm.key_generation(KeyType.AES, param=args.key_size * 8) + print('Key generated successfully.') + print(f'Key ID: {ret}') else: if (args.file_in): fin = open(args.file_in, 'rb')