'Helper to implement :py:meth:`get_finished` and
:py:meth:`get_peer_finished`.
:param function: Either :py:data:`SSL_get_finished`: or
:py:data:`SSL_get_peer_finished`.
:return: :py:data:`None` if the desired message has not yet been
received, otherwise the contents of the message.
:rtype: :py:class:`bytes` or :py:class:`NoneType`'

def _get_finished_message(self, function):

    empty = _ffi.new('char[]', 0)
    size = function(self._ssl, empty, 0)
    if (size == 0):
        return None
    buf = _ffi.new('char[]', size)
    function(self._ssl, buf, size)
    return _ffi.buffer(buf, size)[:]
