#NEWLINE# def validate_yubikey_with_aead( hsm , from_key , aead , key_handle ) : #NEWLINE# #INDENT# "\n    Try to validate an OTP from a YubiKey using the AEAD that can decrypt this YubiKey's\n    internal secret, using the key_handle for the AEAD.\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    @param aead: AEAD containing the cryptographic key and permission flags\n    @param key_handle: The key handle that can decrypt the AEAD\n    @type hsm: L{pyhsm.YHSM}\n    @type from_key: string\n    @type aead: L{YHSM_GeneratedAEAD} or string\n    @type key_handle: integer or string\n\n    @returns: validation response\n    @rtype: L{YHSM_ValidationResult}\n\n    @see: L{pyhsm.validate_cmd.YHSM_Cmd_AEAD_Validate_OTP.parse_result}\n    " #NEWLINE# from_key = pyhsm . util . input_validate_str ( from_key , 'from_key' , max_len = 48 ) #NEWLINE# nonce = aead . nonce #NEWLINE# aead = pyhsm . util . input_validate_aead ( from_key ) #NEWLINE# key_handle = pyhsm . util . input_validate_key_handle ( key_handle ) #NEWLINE# ( public_id , otp ) = split_id_otp ( from_key ) #NEWLINE# public_id = modhex_decode ( public_id ) #NEWLINE# otp = modhex_decode ( otp ) #NEWLINE# if ( not nonce ) : #NEWLINE# #INDENT# nonce = public_id . decode ( 'hex' ) #NEWLINE# #UNINDENT# return hsm . validate_aead_otp ( nonce , otp . decode ( 'hex' ) , key_handle , aead )