GHASH, the keyed hash of GCM #
[BS23], Section 9.7, defines GHASH by (9.18): for a key k and blocks
z = (z[0], …, z[v - 1]) of the field GF(2^128),
GHASH(k, z) := z[0] · k ^ v + z[1] · k ^ (v - 1) + ⋯ + z[v - 1] · k. Here ghash k z is this
evaluation over any field, and ghashBits e is the same function on w-bit blocks for a field
with an additive bit encoding e : F ≃+ BitString w. GCM hashes, on line (∗) of Section 9.7, the
associated data d and the ciphertext c, each padded with zeros to whole 128-bit blocks, followed
by one block holding their two lengths: gcmHashInput d c.
The book requires GHASH to be a DUF, and says that the length block maintains "the XOR-DUF
property". An ε-XOR-DUF ([BS23], Remark 7.3) is an ε-DUF whose digests are bit
strings, with XOR as the difference operator. Here it is Cslib.Probability.IsDeltaUniversalHash
with digests in BitString n, where subtraction is XOR; there is no separate predicate.
Differences from the book:
- Domain. The book defines GHASH over
(𝒳, 𝒳^{≤ℓ}, 𝒳). On that domain (9.18) is not even universal: a leading zero block does not change the hash (ghash_cons_zero), so[]and[0]collide under every key (not_isUniversalHash_ghash). The XOR-DUF property is proved for every family whose last block determines the number of blocks (isDeltaUniversalHash_ghash), which GCM's length block provides. - Bound. The book gives no
εfor GHASH; Remark 7.4 gives(ℓ + 1) / 2 ^ nforH_xpoly, which has the extra leading termk ^ (v + 1). Hereε = ℓ / 2 ^ 128, withℓbounding the number of blocks hashed, the length block included. - Field. GHASH on 128-bit strings is
ghashBits efor the field with modulusX^128 + X^7 + X^2 + X + 1and the standard's bit encodinge. Neither is constructed here, so the theorems are stated for every field with an additive bit encoding. - Length fields. The book's length fields count bytes. Here they count bits: padding gives the
bit strings
[false]and[false, false]the same block. The book fixes no bit order; here the first 64 bits hold the length ofdand the last 64 that ofc, each most significant bit first, and bitjof blockiis bit128 i + jof the padded field. Each length must be below2 ^ 64bits, which the book's boundℓ = 2 ^ 32 - 1on the number of blocks implies. - Key. The key is uniform; in GCM it is
E(k, 0^128)for a block cipherE.
Main definitions #
Cslib.Crypto.ghash: (9.18) over a field.Cslib.Crypto.ghashBits: (9.18) onw-bit blocks through an additive bit encoding.Cslib.Crypto.gcmHashInput: the input of line (∗): both fields padded with zeros, then the blockgcmLengthBlockof their bit lengths.
Main results #
Cslib.Crypto.ghash_eq_sum: (9.18) as printed.Cslib.Crypto.isDeltaUniversalHash_ghash: GHASH isℓ / |F|-difference universal on every injective family of inputs of at mostℓblocks whose last block determines the number of blocks;Cslib.Crypto.isDeltaUniversalHash_ghashBitsis theℓ / 2 ^ w-XOR-DUF on bit strings.Cslib.Crypto.not_isUniversalHash_ghash: without such a condition GHASH is not universal.Cslib.Crypto.isDeltaUniversalHash_ghashBits_gcmHashInput: GHASH on the input of line (∗) is anℓ / 2 ^ 128-XOR-DUF when both fields are shorter than2 ^ 64bits.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, v0.6, Section 9.7, printed pp. 381–382; Remarks 7.3 and 7.4, printed p. 269.
GHASH over a field #
GHASH is ℓ / |F|-difference universal on every injective family of inputs of at most ℓ
blocks in which inputs with the same last block have the same number of blocks; the empty input
counts as ending in the block 0.
GHASH on bit strings #
GHASH on bit strings is an ℓ / 2 ^ w-XOR-DUF for a uniform w-bit key, on every
injective family of inputs of at most ℓ blocks in which inputs with the same last block have the
same number of blocks.
The input of line (∗) #
The block length(d) ‖ length(c) of line (∗): the 64-bit numbers a and b, each most
significant bit first.
GHASH with GCM's padding and length block is an ℓ / 2 ^ 128-XOR-DUF. Let d x and c x
be the associated data and the ciphertext of the input x, which together determine x, each
shorter than 2 ^ 64 bits, with at most ℓ blocks hashed, the length block included. The field
F is any field with an additive encoding e as 128-bit strings.