# Path: petlib/bindings.py
#     _FFI = ffi
#     _C = lib
#     _C = None
#     _FFI = None
#     _OPENSSL_VERSION = get_openssl_version(_C)
#     _OPENSSL_VERSION = OpenSSLVersion.V1_1
#     POINT_CONVERSION_COMPRESSED = 2,
#     POINT_CONVERSION_UNCOMPRESSED = 4,
#     POINT_CONVERSION_HYBRID = 6
#     G = EcGroup()
# class Const:
# class InitCiphers(object):
# def version():
# def get_errors():
#     def __init__(self):
#     def __del__(self):
# def test_double_load():
# def test_version():
# def test_errors():
# def test_locks():
# def test_multithread():
#     def worker():


from .bindings import _FFI, _C, _OPENSSL_VERSION, OpenSSLVersion
from binascii import hexlify
import pytest
class Hmac(object):
    """Initialize the HMAC by name with a key.

    Args:
        name: the name of the hash function to be used.
        key: the cryptographic symmetric key of the HMAC.

    Returns:
        An HMAC instance, ready to accept data to MAC.

    Example:

        >>> h = Hmac(b"sha512", b"Jefe")
        >>> h.update(b"what do ya want ")
        >>> h.update(b"for nothing?")
        >>> d = h.digest()
        >>> len(d)
        64
        >>> hexlify(d)[:10] == b"164b7a7bfc"
        True

    """

    def __init__(self, name, key):
        self.mac_ctx = None
        md = _C.EVP_get_digestbyname(name)
        if md == _FFI.NULL:
            raise Exception("HMAC Error loading function %s" % name)

        self.outsize = _C.EVP_MD_size(md)

# Path: petlib/bindings.py
#     _FFI = ffi
#     _C = lib
#     _C = None
#     _FFI = None
#     _OPENSSL_VERSION = get_openssl_version(_C)
#     _OPENSSL_VERSION = OpenSSLVersion.V1_1
#     POINT_CONVERSION_COMPRESSED = 2,
#     POINT_CONVERSION_UNCOMPRESSED = 4,
#     POINT_CONVERSION_HYBRID = 6
#     G = EcGroup()
# class Const:
# class InitCiphers(object):
# def version():
# def get_errors():
#     def __init__(self):
#     def __del__(self):
# def test_double_load():
# def test_version():
# def test_errors():
# def test_locks():
# def test_multithread():
#     def worker():


# Path: petlib/hmac.py
from .bindings import _FFI, _C, _OPENSSL_VERSION, OpenSSLVersion
from binascii import hexlify
import pytest

class Hmac(object):
    """Initialize the HMAC by name with a key.

    Args:
        name: the name of the hash function to be used.
        key: the cryptographic symmetric key of the HMAC.

    Returns:
        An HMAC instance, ready to accept data to MAC.

    Example:

        >>> h = Hmac(b"sha512", b"Jefe")
        >>> h.update(b"what do ya want ")
        >>> h.update(b"for nothing?")
        >>> d = h.digest()
        >>> len(d)
        64
        >>> hexlify(d)[:10] == b"164b7a7bfc"
        True

    """

    def __init__(self, name, key):
        self.mac_ctx = None
        md = _C.EVP_get_digestbyname(name)
        if md == _FFI.NULL:
            raise Exception("HMAC Error loading function %s" % name)

        self.outsize = _C.EVP_MD_size(md)

        if _OPENSSL_VERSION == OpenSSLVersion.V1_0: