def import_keys(hsm, args):
res = True<EOL>for line in sys.stdin:<EOL><INDENT>if line[<NUM_LIT:0>] == '<STR_LIT:#>':<EOL><INDENT>continue<EOL><DEDENT>l = line.split('<STR_LIT:U+002C>')<EOL>modhex_id = l[<NUM_LIT:1>]<EOL>uid = l[<NUM_LIT:2>].decode('<STR_LIT>')<EOL>key = l[<NUM_LIT:3>].decode('<STR_LIT>')<EOL>if modhex_id and uid and key:<EOL><INDENT>public_id = pyhsm.yubikey.modhex_decode(modhex_id)<EOL>padded_id = modhex_id.rjust(args.public_id_chars, '<STR_LIT:c>')<EOL><DEDENT>if int(public_id, <NUM_LIT:16>) == <NUM_LIT:0>:<EOL><INDENT>print("<STR_LIT>" % (padded_id))<EOL>print("<STR_LIT>")<EOL>continue<EOL><DEDENT>if args.verbose:<EOL><INDENT>print("<STR_LIT>" % (padded_id))<EOL><DEDENT>secret = pyhsm.aead_cmd.YHSM_YubiKeySecret(key, uid)<EOL>hsm.load_secret(secret)<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>if args.internal_db:<EOL><INDENT>if not store_in_internal_db(<EOL>args, hsm, modhex_id, public_id, kh, aead):<EOL><INDENT>res = False<EOL><DEDENT>continue<EOL><DEDENT>filename = output_filename(<EOL>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>if res:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>return res<EOL>
The main stdin iteration loop.