def __init__(self, stick, key_handle, data, flags = None, final = True, to_buffer = False):
        data = pyhsm.util.input_validate_str(data, 'data', max_len = pyhsm.defines.YSM_MAX_PKT_SIZE - 6)
        self.key_handle = pyhsm.util.input_validate_key_handle(key_handle)

        if flags != None:
            flags = pyhsm.util.input_validate_int(flags, 'flags', max_value=0xff)
        else:
            flags = pyhsm.defines.YSM_HMAC_SHA1_RESET
            if final:
                flags |= pyhsm.defines.YSM_HMAC_SHA1_FINAL
            if to_buffer:
                flags |= pyhsm.defines.YSM_HMAC_SHA1_TO_BUFFER

        self.final = final
        self.flags = flags
        packed = _raw_pack(self.key_handle, self.flags, data)
        YHSM_Cmd.__init__(self, stick, pyhsm.defines.YSM_HMAC_SHA1_GENERATE, packed)
dataset/ETHPy150Open Yubico/python-pyhsm/pyhsm/hmac_cmd.py/YHSM_Cmd_HMAC_SHA1_Write.__init__/original