#NEWLINE# def validate_otp( hsm , from_key ) : #NEWLINE# #INDENT# "\n    Try to validate an OTP from a YubiKey using the internal database\n    on the YubiHSM.\n\n    `from_key' is the modhex encoded string emitted when you press the\n    button on your YubiKey.\n\n    Will only return on succesfull validation. All failures will result\n    in an L{pyhsm.exception.YHSM_CommandFailed}.\n\n    @param hsm: The YHSM instance\n    @param from_key: The OTP from a YubiKey (in modhex)\n    @type hsm: L{pyhsm.YHSM}\n    @type from_key: string\n\n    @returns: validation response, if successful\n    @rtype: L{YHSM_ValidationResult}\n\n    @see: L{pyhsm.db_cmd.YHSM_Cmd_DB_Validate_OTP.parse_result}\n    " #NEWLINE# ( public_id , otp ) = split_id_otp ( from_key ) #NEWLINE# return hsm . db_validate_yubikey_otp ( modhex_decode ( public_id ) . decode ( 'hex' ) , modhex_decode ( otp ) . decode ( 'hex' ) )