def gen_keys(hsm, args):
if args.verbose:<EOL><INDENT>print("<STR_LIT>" % (args.count))<EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT>" % (args.count))<EOL><DEDENT>for int_id in range(args.start_id, args.start_id + args.count):<EOL><INDENT>public_id = ("<STR_LIT>" % int_id).rjust(args.public_id_chars, '<STR_LIT:0>')<EOL>padded_id = pyhsm.yubikey.modhex_encode(public_id)<EOL>if args.verbose:<EOL><INDENT>print("<STR_LIT>" % (padded_id))<EOL><DEDENT>num_bytes = len(pyhsm.aead_cmd.YHSM_YubiKeySecret('<STR_LIT:a>' * <NUM_LIT:16>, '<STR_LIT:b>' * <NUM_LIT:6>).pack())<EOL>hsm.load_random(num_bytes)<EOL>for kh in list(args.key_handles.keys()):<EOL><INDENT>if args.random_nonce:<EOL><INDENT>nonce = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>nonce = public_id.decode('<STR_LIT>')<EOL><DEDENT>aead = hsm.generate_aead(nonce, kh)<EOL>filename = output_filename(args.output_dir, args.key_handles[kh], padded_id)<EOL>if args.verbose:<EOL><INDENT>print("<STR_LIT>" %(args.key_handles[kh], len(aead.data), shorten_aead(aead), filename))<EOL><DEDENT>aead.save(filename)<EOL><DEDENT>if args.verbose:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT><DEDENT>print("<STR_LIT>")<EOL>
The main key generating loop.