Skip to Content
oxcrypto

HMAC

Authenticate messages with HMAC.

from oxcrypto.mac.hmac import HMAC

tag = HMAC.SHA256.mac(b"key", b"message")

HMAC (RFC 2104, FIPS 198-1) uses named hash variants such as HMAC.SHA512 and HMAC.STREEBOG512. Keys of any length are accepted; generate_key() returns one hash block. Tags have the hash's output length.

HMAC over MD2, MD4, MD5 and SHA-1 exists for interoperability with legacy protocols.