Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Eric Biggers and committed by
Herbert Xu
8dfa20fc 065cf577

+41 -16
+1 -1
arch/arm/crypto/ghash-ce-glue.c
··· 18 18 #include <linux/crypto.h> 19 19 #include <linux/module.h> 20 20 21 - MODULE_DESCRIPTION("GHASH secure hash using ARMv8 Crypto Extensions"); 21 + MODULE_DESCRIPTION("GHASH hash function using ARMv8 Crypto Extensions"); 22 22 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>"); 23 23 MODULE_LICENSE("GPL v2"); 24 24 MODULE_ALIAS_CRYPTO("ghash");
+1 -1
arch/s390/crypto/ghash_s390.c
··· 153 153 MODULE_ALIAS_CRYPTO("ghash"); 154 154 155 155 MODULE_LICENSE("GPL"); 156 - MODULE_DESCRIPTION("GHASH Message Digest Algorithm, s390 implementation"); 156 + MODULE_DESCRIPTION("GHASH hash function, s390 implementation");
+1 -2
arch/x86/crypto/ghash-clmulni-intel_glue.c
··· 357 357 module_exit(ghash_pclmulqdqni_mod_exit); 358 358 359 359 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"); 362 361 MODULE_ALIAS_CRYPTO("ghash");
+6 -5
crypto/Kconfig
··· 647 647 Unless you are testing these algorithms, you don't need this. 648 648 649 649 config CRYPTO_GHASH 650 - tristate "GHASH digest algorithm" 650 + tristate "GHASH hash function" 651 651 select CRYPTO_GF128MUL 652 652 select CRYPTO_HASH 653 653 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. 655 656 656 657 config CRYPTO_POLY1305 657 658 tristate "Poly1305 authenticator algorithm" ··· 977 976 <http://www.larc.usp.br/~pbarreto/WhirlpoolPage.html> 978 977 979 978 config CRYPTO_GHASH_CLMUL_NI_INTEL 980 - tristate "GHASH digest algorithm (CLMUL-NI accelerated)" 979 + tristate "GHASH hash function (CLMUL-NI accelerated)" 981 980 depends on X86 && 64BIT 982 981 select CRYPTO_CRYPTD 983 982 help 984 - GHASH is message digest algorithm for GCM (Galois/Counter Mode). 985 - The implementation is accelerated by CLMUL-NI of Intel. 983 + This is the x86_64 CLMUL-NI accelerated implementation of 984 + GHASH, the hash function used in GCM (Galois/Counter mode). 986 985 987 986 comment "Ciphers" 988 987
+28 -3
crypto/ghash-generic.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 /* 3 - * GHASH: digest algorithm for GCM (Galois/Counter Mode). 3 + * GHASH: hash function for GCM (Galois/Counter Mode). 4 4 * 5 5 * Copyright (c) 2007 Nokia Siemens Networks - Mikko Herranen <mh1@iki.fi> 6 6 * Copyright (c) 2009 Intel Corp. 7 7 * Author: Huang Ying <ying.huang@intel.com> 8 + */ 9 + 10 + /* 11 + * GHASH is a keyed hash function used in GCM authentication tag generation. 8 12 * 9 - * The algorithm implementation is copied from gcm.c. 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. 30 + * 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) 10 35 */ 11 36 12 37 #include <crypto/algapi.h> ··· 181 156 module_exit(ghash_mod_exit); 182 157 183 158 MODULE_LICENSE("GPL"); 184 - MODULE_DESCRIPTION("GHASH Message Digest Algorithm"); 159 + MODULE_DESCRIPTION("GHASH hash function"); 185 160 MODULE_ALIAS_CRYPTO("ghash"); 186 161 MODULE_ALIAS_CRYPTO("ghash-generic");
+3 -3
drivers/crypto/Kconfig
··· 189 189 It is available as of z9. 190 190 191 191 config CRYPTO_GHASH_S390 192 - tristate "GHASH digest algorithm" 192 + tristate "GHASH hash function" 193 193 depends on S390 194 194 select CRYPTO_HASH 195 195 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). 198 198 199 199 It is available as of z196. 200 200
+1 -1
include/crypto/ghash.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 - * Common values for GHASH algorithms 3 + * Common values for the GHASH hash function 4 4 */ 5 5 6 6 #ifndef __CRYPTO_GHASH_H__