Skip to Content
oxcrypto

GHASH

Compute the GCM universal hash.

from oxcrypto.universal_hash.ghash import GHASH

hash_key = GHASH.GHASH.generate_key()
output = GHASH.GHASH.mac(hash_key, b"sixteen byte blk")

GHASH (NIST SP 800-38D) takes the 16-byte hash key H and returns 16 bytes. A trailing partial block is zero-padded, so callers building GCM pass AAD and ciphertext padded and followed by the length block. GHASH is not a MAC on its own: its output must be masked with a one-time value, as GCM does.