from _typeshed import ReadableBuffer
from types import ModuleType
from typing import Any, AnyStr, Callable, overload

# TODO more precise type for object of hashlib
_Hash = Any
_DigestMod = str | Callable[[], _Hash] | ModuleType

digest_size: None

def new(key: bytes, msg: ReadableBuffer | None = ..., digestmod: _DigestMod | None = ...) -> HMAC: ...

class HMAC:
    def __init__(self, key: bytes, msg: ReadableBuffer | None = ..., digestmod: _DigestMod = ...) -> None: ...
    def update(self, msg: ReadableBuffer) -> None: ...
    def digest(self) -> bytes: ...
    def hexdigest(self) -> str: ...
    def copy(self) -> HMAC: ...

@overload
def compare_digest(__a: ReadableBuffer, __b: ReadableBuffer) -> bool: ...
@overload
def compare_digest(__a: AnyStr, __b: AnyStr) -> bool: ...
