Program a challenge-response credential.

    If KEY is not given, an interactive prompt will ask for it.
497491
def chalresp(ctx, slot, key, totp, touch, force, generate):
    
    controller = ctx.obj['controller']

    if key:
        if generate:
            ctx.fail('Invalid options: --generate conflicts with KEY argument.')
        elif totp:
            key = parse_b32_key(key)
        else:
            key = parse_key(key)
    else:
        if force and not generate:
            ctx.fail('No secret key given. Please remove the --force flag, '
                     'set the KEY argument or set the --generate flag.')
        elif totp:
            while True:
                key = click.prompt('Enter a secret key (base32)', err=True)
                try:
                    key = parse_b32_key(key)
                    break
                except Exception as e:
                    click.echo(e)
        else:
            if generate:
                key = os.urandom(20)
                click.echo('Using a randomly generated key: {}'.format(
                    b2a_hex(key).decode('ascii')))
            else:
                key = click.prompt('Enter a secret key', err=True)
                key = parse_key(key)

    cred_type = 'TOTP' if totp else 'challenge-response'
    force or click.confirm('Program a {} credential in slot {}?'
                           .format(cred_type, slot), abort=True, err=True)
    try:
        controller.program_chalresp(slot, key, touch)
    except YkpersError as e:
        _failed_to_write_msg(ctx, e)
528242
def _challenge_response(self, challenge, mode, slot, variable, may_block):
        
         # Check length and pad challenge if appropriate
        if mode == 'HMAC':
            if len(challenge) > yubikey_defs.SHA1_MAX_BLOCK_SIZE:
                raise yubico_exception.InputError('Mode HMAC challenge too big (%i/%i)' \
                                                      % (yubikey_defs.SHA1_MAX_BLOCK_SIZE, len(challenge)))
            if len(challenge) < yubikey_defs.SHA1_MAX_BLOCK_SIZE:
                pad_with = b'\0'
                if variable and challenge[-1:] == pad_with:
                    pad_with = b'\xff'
                challenge = challenge.ljust(yubikey_defs.SHA1_MAX_BLOCK_SIZE, pad_with)
            response_len = yubikey_defs.SHA1_DIGEST_SIZE
        elif mode == 'OTP':
            if len(challenge) != yubikey_defs.UID_SIZE:
                raise yubico_exception.InputError('Mode OTP challenge must be %i bytes (got %i)' \
                                                      % (yubikey_defs.UID_SIZE, len(challenge)))
            challenge = challenge.ljust(yubikey_defs.SHA1_MAX_BLOCK_SIZE, b'\0')
            response_len = 16
        else:
            raise yubico_exception.InputError('Invalid mode supplied (%s, valid values are HMAC and OTP)' \
                                                  % (mode))

        try:
            command = _CMD_CHALLENGE[mode][slot]
        except:
            raise yubico_exception.InputError('Invalid slot specified (%s)' % (slot))

        frame = yubikey_frame.YubiKeyFrame(command=command, payload=challenge)
        self._device._write(frame)
        response = self._device._read_response(may_block=may_block)
        if not yubico_util.validate_crc16(response[:response_len + 2]):
            raise YubiKeyUSBHIDError("Read from device failed CRC check")
        return response[:response_len]
126816
function prompForPassword(done) {
  inquirer.prompt([
    {
      type: 'password',
      message: 'Enter the password',
      name: 'password',
      validate(input) {
        return input.length > 0;
      }
    }
  ], answers => {
    done(answers.password);
  });
}
1272077
def send_tan(self, challenge: NeedTANResponse, tan: str):
        

        with self._get_dialog() as dialog:
            tan_seg = self._get_tan_segment(challenge.command_seg, '2', challenge.tan_request)
            self._pending_tan = tan

            response = dialog.send(tan_seg)

            resume_func = getattr(self, challenge.resume_method)
            return resume_func(challenge.command_seg, response)
1251973
def prompt_user(prompt):
    """"""
    # raw_input returns the empty string for "enter"
    yes = set(['yes', 'y'])
    no = set(['no','n'])

    try:
        print(prompt)
        choice = input().lower()
        # would like to test for exception here, but not sure if we can do that without importing IPython
    except:
        print('Stdin is not implemented.')
        print('You need to set')
        print('overide_manual_authorize=True')
        print('to proceed with the download. Please set that variable and continue.')
        raise


    if choice in yes:
        return True
    elif choice in no:
        return False
    else:
        print(("Your response was a " + choice))
        print("Please respond with 'yes', 'y' or 'no', 'n'")
516774
function Prompt( question, rl, answers ) {

  // Setup instance defaults property
  _.assign( this, {
    height : 0,
    status : "pending"
  });

  // Set defaults prompt options
  this.opt = _.defaults( _.clone(question), {
    validate: function() { return true; },
    filter: function( val ) { return val; },
    when: function() { return true; }
  });

  // Check to make sure prompt requirements are there
  if (!this.opt.message) {
    this.throwParamError("message");
  }
  if (!this.opt.name) {
    this.throwParamError("name");
  }

  // Normalize choices
  if ( _.isArray(this.opt.choices) ) {
    this.opt.choices = new Choices( this.opt.choices, answers );
  }

  this.rl = rl;

  return this;
}
1338006
def challenge():
  """"""
  enums = dict(
    ACTIVE="active",
    UPCOMING="upcoming",
    HIRING="hiring",
    ALL="all",
    SHORT="short",
  )

  return type('Enum', (), enums)
654231
def interact(title, description, prompt, binary, options):
    """"""
    args = [binary]
    p = subprocess.Popen(args=args,
                         stdin=subprocess.PIPE,
                         stdout=subprocess.PIPE,
                         env=os.environ)
    p.args = args  # TODO: remove after Python 2 deprecation.
    expect(p, [b'OK'])

    title = util.assuan_serialize(title.encode('ascii'))
    write(p, b'SETTITLE ' + title + b'\n')
    expect(p, [b'OK'])

    if description:
        description = util.assuan_serialize(description.encode('ascii'))
        write(p, b'SETDESC ' + description + b'\n')
        expect(p, [b'OK'])

    if prompt:
        prompt = util.assuan_serialize(prompt.encode('ascii'))
        write(p, b'SETPROMPT ' + prompt + b'\n')
        expect(p, [b'OK'])

    log.debug('setting %d options', len(options))
    for opt in options:
        write(p, b'OPTION ' + opt + b'\n')
        expect(p, [b'OK', b'ERR'])

    write(p, b'GETPIN\n')
    pin = expect(p, [b'OK', b'D '], confidential=True)

    p.communicate()  # close stdin and wait for the process to exit
    exit_code = p.wait()
    if exit_code:
        raise subprocess.CalledProcessError(exit_code, binary)

    return pin.decode('ascii').strip()
587235
def prompt(*args, **kwargs):
    """"""
    try:
        return click.prompt(*args, **kwargs)
    except click.Abort:
        return False
228863
def send(self, command):
        ""
        if self.secure_rcon == self.RCON_NOSECURE:
            self.sock.send(rcon_nosecure_packet(self.password, command))
        elif self.secure_rcon == self.RCON_SECURE_TIME:
            self.sock.send(rcon_secure_time_packet(self.password, command))
        elif self.secure_rcon == self.RCON_SECURE_CHALLENGE:
            challenge = self.getchallenge()
            self.sock.send(rcon_secure_challenge_packet(self.password,
                                                        challenge, command))
        else:
            raise ValueError("Bad value of secure_rcon")
1155319
function(){
		console.log("Unknown Response");

		if (_pathConfirmationCounter < 3){
			console.log("Please enter a 'Y' or an 'N' when answering.\n");
			_pathConfirmationCounter++;
			confirmDestination();
		} else {
			console.log("Unable to install at this time due to too many unknown responses.\n");
			_prompt.close();
		}
	}
125998
def a_unexpected_prompt(ctx):
    """"""
    prompt = ctx.ctrl.match.group(0)
    ctx.msg = "Received the jump host prompt: '{}'".format(prompt)
    ctx.device.connected = False
    ctx.finished = True
    raise ConnectionError("Unable to connect to the device.", ctx.ctrl.hostname)
447316
private void startHandleChallenges(JSONObject jsonChallenges, Response response) {
        ArrayList<String> challenges = getRealmsFromJson(jsonChallenges);

        MCAAuthorizationManager authManager = (MCAAuthorizationManager) BMSClient.getInstance().getAuthorizationManager();

        if (isAuthorizationRequired(response)) {
            setExpectedAnswers(challenges);
        }

        for (String realm : challenges) {
            ChallengeHandler handler = authManager.getChallengeHandler(realm);
            if (handler != null) {
                JSONObject challenge = jsonChallenges.optJSONObject(realm);
                handler.handleChallenge(this, challenge, context);
            } else {
                throw new RuntimeException("Challenge handler for realm is not found: " + realm);
            }
        }
    }
1214801
function promptAsync(prompts) {
  return new Promise(function(resolve, reject) {
    parent.prompt.call(parent, prompts, function(answers) {
      resolve(answers)
    });
  });
}
602078
def prompt_stdin(prompt):
    """"""
    # raw_input returns the empty string for "enter"
    yes = set(['yes', 'y'])
    no = set(['no','n'])

    try:
        print(prompt)
        if sys.version_info>=(3,0):
            choice = input().lower()
        else:
            choice = raw_input().lower()
        # would like to test for which exceptions here
    except:
        print('Stdin is not implemented.')
        print('You need to set')
        print('overide_manual_authorize=True')
        print('to proceed with the download. Please set that variable and continue.')
        raise


    if choice in yes:
        return True
    elif choice in no:
        return False
    else:
        print("Your response was a " + choice)
        print("Please respond with 'yes', 'y' or 'no', 'n'")
1359130
def sign_ssh_challenge(self, blob, identity):
        """"""
        msg = _parse_ssh_blob(blob)
        log.debug('%s: user %r via %r (%r)',
                  msg['conn'], msg['user'], msg['auth'], msg['key_type'])
        log.debug('nonce: %r', msg['nonce'])
        fp = msg['public_key']['fingerprint']
        log.debug('fingerprint: %s', fp)
        log.debug('hidden challenge size: %d bytes', len(blob))

        log.info('please confirm user "%s" login to "%s" using %s...',
                 msg['user'].decode('ascii'), identity.to_string(),
                 self.device)

        with self.device:
            return self.device.sign(blob=blob, identity=identity)
538229
async function challengeCreateFn(authz, challenge, keyAuthorization) {
    /* Do something here */
    log(JSON.stringify(authz));
    log(JSON.stringify(challenge));
    log(keyAuthorization);
}