MAC family

GHASH

The GF(2^128) polynomial hash at the core of AES-GCM and GMAC

research 1 variant NIST SP 800-38D

Overview

GHASH is a universal hash function defined in NIST SP 800-38D as the authentication component of GCM and GMAC. On its own it is not a MAC; it must be combined with a secret, one-time mask to give a secure tag.

GHASH treats its input as a sequence of 128-bit blocks X1, …, Xn and computes the polynomial X1·H^n ⊕ X2·H^(n-1) ⊕ … ⊕ Xn·H in the field GF(2^128), where H is a secret hash key. Evaluation uses Horner's rule, one field multiplication per block. Modern CPUs implement this multiplication with carry-less multiply instructions such as PCLMULQDQ or PMULL.

GHASH is an ε-almost-XOR-universal hash: for two distinct messages of bounded length, the probability that their hashes differ by any particular value is small. NextSSL exposes GHASH as a research primitive for building and testing GCM-family constructions. POLYVAL, used in AES-GCM-SIV, is a closely related function with a different bit ordering.

History

2004–2007
  1. GHASH published by David McGrew, John Viega

  2. Specified in NIST SP 800-38D

Security notes

GHASH alone is linear in its input and provides no authentication. Leaking H, or reusing a GCM nonce, enables forgeries. Use AES-GCM or GMAC rather than raw GHASH.

Typical uses

Building and testing GCM and GMACStudying universal hashing

Variants in NextSSL

1
AlgorithmTierSizes (bytes)StandardsAPI
Ghash
ghash
research key 16 · tag 16 · block 16 NIST SP 800-38D (GHASH) root

Frequently asked questions

Which GHASH variants does NextSSL include?

NextSSL registers 1 GHASH variant: ghash.