docs: def import_keys(hsm, args):
      """
      The main stdin iteration loop.
      """
      res = True
  
      # ykksm 1
      #123456,ftftftcccc,534543524554,fcacd309a20ce1809c2db257f0e8d6ea,000000000000,,,
  
      for line in sys.stdin:
          if line[0] == '#':
              continue
  
          l = line.split(',')
          modhex_id = l[1]
          uid = l[2].decode('hex')
          key = l[3].decode('hex')
  
          if modhex_id and uid and key:
              public_id = pyhsm.yubikey.modhex_decode(modhex_id)
              padded_id = modhex_id.rjust(args.public_id_chars, 'c')
  
          if int(public_id, 16) == 0:
              print "WARNING: Skipping import of key with public ID: %s" % (padded_id)
              print "This public ID is unsupported by the YubiHSM.\n"
              continue
  
          if args.verbose:
              print "  %s" % (padded_id)
  
          secret = pyhsm.aead_cmd.YHSM_YubiKeySecret(key, uid)
          hsm.load_secret(secret)
  
          for kh in args.key_handles.keys():
              if(args.random_nonce):
                  nonce = ""
              else:
                  nonce = public_id.decode('hex')
              aead = hsm.generate_aead(nonce, kh)
  
              if args.internal_db:
                  if not store_in_internal_db(
                          args, hsm, modhex_id, public_id, kh, aead):
                      res = False
                  continue
  
              filename = output_filename(
                  args.output_dir, args.key_handles[kh], padded_id)
  
              if args.verbose:
                  print "    %4s, %i bytes (%s) -> %s" % \
                      (args.key_handles[kh], len(aead.data), shorten_aead(aead), filename)
  
              aead.save(filename)
  
          if args.verbose:
              print ""
  
      if res:
          print "\nDone\n"
      else:
          print "\nDone (one or more entries rejected)"
      return res