<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def finish(self):
 """ Finalizes processing. If some data are kept in the internal state, they would be processed and returned. """

        if self.cipher_finalized:
            raise CipherError("Cipher operation is already completed")
        outbuf = create_string_buffer(self.block_size)
        self.cipher_finalized = True
        outlen = c_int(0)
        result = libcrypto.EVP_CipherFinal_ex(self.ctx, outbuf, byref(outlen))
        if result == 0:
            self._clean_ctx()
            raise CipherError("Unable to finalize cipher")
        if outlen.value > 0:
            return outbuf.raw[:int(outlen.value)]
        else:
            return b""