Skip to content

Commit 8dfa20f

Browse files
ebiggersherbertx
authored andcommitted
crypto: ghash - add comment and improve help text
To help avoid confusion, add a comment to ghash-generic.c which explains the convention that the kernel's implementation of GHASH uses. Also update the Kconfig help text and module descriptions to call GHASH a "hash function" rather than a "message digest", since the latter normally means a real cryptographic hash function, which GHASH is not. Cc: Pascal Van Leeuwen <pvanleeuwen@verimatrix.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Acked-by: Pascal Van Leeuwen <pvanleeuwen@verimatrix.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 065cf57 commit 8dfa20f

7 files changed

Lines changed: 41 additions & 16 deletions

File tree

‎arch/arm/crypto/ghash-ce-glue.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <linux/crypto.h>
1919
#include <linux/module.h>
2020

21-
MODULE_DESCRIPTION("GHASH secure hash using ARMv8 Crypto Extensions");
21+
MODULE_DESCRIPTION("GHASH hash function using ARMv8 Crypto Extensions");
2222
MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
2323
MODULE_LICENSE("GPL v2");
2424
MODULE_ALIAS_CRYPTO("ghash");

‎arch/s390/crypto/ghash_s390.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,4 @@ module_exit(ghash_mod_exit);
153153
MODULE_ALIAS_CRYPTO("ghash");
154154

155155
MODULE_LICENSE("GPL");
156-
MODULE_DESCRIPTION("GHASH Message Digest Algorithm, s390 implementation");
156+
MODULE_DESCRIPTION("GHASH hash function, s390 implementation");

‎arch/x86/crypto/ghash-clmulni-intel_glue.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,5 @@ module_init(ghash_pclmulqdqni_mod_init);
357357
module_exit(ghash_pclmulqdqni_mod_exit);
358358

359359
MODULE_LICENSE("GPL");
360-
MODULE_DESCRIPTION("GHASH Message Digest Algorithm, "
361-
"accelerated by PCLMULQDQ-NI");
360+
MODULE_DESCRIPTION("GHASH hash function, accelerated by PCLMULQDQ-NI");
362361
MODULE_ALIAS_CRYPTO("ghash");

‎crypto/Kconfig‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -647,11 +647,12 @@ config CRYPTO_VPMSUM_TESTER
647647
Unless you are testing these algorithms, you don't need this.
648648

649649
config CRYPTO_GHASH
650-
tristate "GHASH digest algorithm"
650+
tristate "GHASH hash function"
651651
select CRYPTO_GF128MUL
652652
select CRYPTO_HASH
653653
help
654-
GHASH is message digest algorithm for GCM (Galois/Counter Mode).
654+
GHASH is the hash function used in GCM (Galois/Counter Mode).
655+
It is not a general-purpose cryptographic hash function.
655656

656657
config CRYPTO_POLY1305
657658
tristate "Poly1305 authenticator algorithm"
@@ -976,12 +977,12 @@ config CRYPTO_WP512
976977
<http://www.larc.usp.br/~pbarreto/WhirlpoolPage.html>
977978

978979
config CRYPTO_GHASH_CLMUL_NI_INTEL
979-
tristate "GHASH digest algorithm (CLMUL-NI accelerated)"
980+
tristate "GHASH hash function (CLMUL-NI accelerated)"
980981
depends on X86 && 64BIT
981982
select CRYPTO_CRYPTD
982983
help
983-
GHASH is message digest algorithm for GCM (Galois/Counter Mode).
984-
The implementation is accelerated by CLMUL-NI of Intel.
984+
This is the x86_64 CLMUL-NI accelerated implementation of
985+
GHASH, the hash function used in GCM (Galois/Counter mode).
985986

986987
comment "Ciphers"
987988

‎crypto/ghash-generic.c‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,37 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
3-
* GHASH: digest algorithm for GCM (Galois/Counter Mode).
3+
* GHASH: hash function for GCM (Galois/Counter Mode).
44
*
55
* Copyright (c) 2007 Nokia Siemens Networks - Mikko Herranen <mh1@iki.fi>
66
* Copyright (c) 2009 Intel Corp.
77
* Author: Huang Ying <ying.huang@intel.com>
8+
*/
9+
10+
/*
11+
* GHASH is a keyed hash function used in GCM authentication tag generation.
12+
*
13+
* The original GCM paper [1] presents GHASH as a function GHASH(H, A, C) which
14+
* takes a 16-byte hash key H, additional authenticated data A, and a ciphertext
15+
* C. It formats A and C into a single byte string X, interprets X as a
16+
* polynomial over GF(2^128), and evaluates this polynomial at the point H.
17+
*
18+
* However, the NIST standard for GCM [2] presents GHASH as GHASH(H, X) where X
19+
* is the already-formatted byte string containing both A and C.
20+
*
21+
* "ghash" in the Linux crypto API uses the 'X' (pre-formatted) convention,
22+
* since the API supports only a single data stream per hash. Thus, the
23+
* formatting of 'A' and 'C' is done in the "gcm" template, not in "ghash".
24+
*
25+
* The reason "ghash" is separate from "gcm" is to allow "gcm" to use an
26+
* accelerated "ghash" when a standalone accelerated "gcm(aes)" is unavailable.
27+
* It is generally inappropriate to use "ghash" for other purposes, since it is
28+
* an "ε-almost-XOR-universal hash function", not a cryptographic hash function.
29+
* It can only be used securely in crypto modes specially designed to use it.
830
*
9-
* The algorithm implementation is copied from gcm.c.
31+
* [1] The Galois/Counter Mode of Operation (GCM)
32+
* (http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.694.695&rep=rep1&type=pdf)
33+
* [2] Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC
34+
* (https://csrc.nist.gov/publications/detail/sp/800-38d/final)
1035
*/
1136

1237
#include <crypto/algapi.h>
@@ -156,6 +181,6 @@ subsys_initcall(ghash_mod_init);
156181
module_exit(ghash_mod_exit);
157182

158183
MODULE_LICENSE("GPL");
159-
MODULE_DESCRIPTION("GHASH Message Digest Algorithm");
184+
MODULE_DESCRIPTION("GHASH hash function");
160185
MODULE_ALIAS_CRYPTO("ghash");
161186
MODULE_ALIAS_CRYPTO("ghash-generic");

‎drivers/crypto/Kconfig‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,12 @@ config S390_PRNG
189189
It is available as of z9.
190190

191191
config CRYPTO_GHASH_S390
192-
tristate "GHASH digest algorithm"
192+
tristate "GHASH hash function"
193193
depends on S390
194194
select CRYPTO_HASH
195195
help
196-
This is the s390 hardware accelerated implementation of the
197-
GHASH message digest algorithm for GCM (Galois/Counter Mode).
196+
This is the s390 hardware accelerated implementation of GHASH,
197+
the hash function used in GCM (Galois/Counter mode).
198198

199199
It is available as of z196.
200200

‎include/crypto/ghash.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
/*
3-
* Common values for GHASH algorithms
3+
* Common values for the GHASH hash function
44
*/
55

66
#ifndef __CRYPTO_GHASH_H__

0 commit comments

Comments
 (0)