def input_validate_nonce(nonce, name='<STR_LIT>', pad = False):
if type(nonce) is not str:<EOL><INDENT>raise pyhsm.exception.YHSM_WrongInputType(name, str, type(nonce))<EOL><DEDENT>if len(nonce) > pyhsm.defines.YSM_AEAD_NONCE_SIZE:<EOL><INDENT>raise pyhsm.exception.YHSM_InputTooLong(<EOL>name, pyhsm.defines.YSM_AEAD_NONCE_SIZE, len(nonce))<EOL><DEDENT>if pad:<EOL><INDENT>return nonce.ljust(pyhsm.defines.YSM_AEAD_NONCE_SIZE, chr(<NUM_LIT>))<EOL><DEDENT>else:<EOL><INDENT>return nonce<EOL><DEDENT>
Input validation for nonces.