summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2019-07-20 02:09:18 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2019-07-27 07:08:38 -0400
commit8dfa20fcfbeb245642dfe3a43f8a3735d9aed42a (patch)
tree887e9ffb1793ff6f754ab839a528a170177f219d
parent065cf577135a4977931c7a1e1edf442bfd9773dd (diff)
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>
-rw-r--r--arch/arm/crypto/ghash-ce-glue.c2
-rw-r--r--arch/s390/crypto/ghash_s390.c2
-rw-r--r--arch/x86/crypto/ghash-clmulni-intel_glue.c3
-rw-r--r--crypto/Kconfig11
-rw-r--r--crypto/ghash-generic.c31
-rw-r--r--drivers/crypto/Kconfig6
-rw-r--r--include/crypto/ghash.h2
7 files changed, 41 insertions, 16 deletions
diff --git a/arch/arm/crypto/ghash-ce-glue.c b/arch/arm/crypto/ghash-ce-glue.c
index bb906b5f1eb3..c691077679a6 100644
--- a/arch/arm/crypto/ghash-ce-glue.c
+++ b/arch/arm/crypto/ghash-ce-glue.c
@@ -18,7 +18,7 @@
18#include <linux/crypto.h> 18#include <linux/crypto.h>
19#include <linux/module.h> 19#include <linux/module.h>
20 20
21MODULE_DESCRIPTION("GHASH secure hash using ARMv8 Crypto Extensions"); 21MODULE_DESCRIPTION("GHASH hash function using ARMv8 Crypto Extensions");
22MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>"); 22MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
23MODULE_LICENSE("GPL v2"); 23MODULE_LICENSE("GPL v2");
24MODULE_ALIAS_CRYPTO("ghash"); 24MODULE_ALIAS_CRYPTO("ghash");
diff --git a/arch/s390/crypto/ghash_s390.c b/arch/s390/crypto/ghash_s390.c
index eeeb6a7737a4..a3e7400e031c 100644
--- a/arch/s390/crypto/ghash_s390.c
+++ b/arch/s390/crypto/ghash_s390.c
@@ -153,4 +153,4 @@ module_exit(ghash_mod_exit);
153MODULE_ALIAS_CRYPTO("ghash"); 153MODULE_ALIAS_CRYPTO("ghash");
154 154
155MODULE_LICENSE("GPL"); 155MODULE_LICENSE("GPL");
156MODULE_DESCRIPTION("GHASH Message Digest Algorithm, s390 implementation"); 156MODULE_DESCRIPTION("GHASH hash function, s390 implementation");
diff --git a/arch/x86/crypto/ghash-clmulni-intel_glue.c b/arch/x86/crypto/ghash-clmulni-intel_glue.c
index ac76fe88ac4f..04d72a5a8ce9 100644
--- a/arch/x86/crypto/ghash-clmulni-intel_glue.c
+++ b/arch/x86/crypto/ghash-clmulni-intel_glue.c
@@ -357,6 +357,5 @@ module_init(ghash_pclmulqdqni_mod_init);
357module_exit(ghash_pclmulqdqni_mod_exit); 357module_exit(ghash_pclmulqdqni_mod_exit);
358 358
359MODULE_LICENSE("GPL"); 359MODULE_LICENSE("GPL");
360MODULE_DESCRIPTION("GHASH Message Digest Algorithm, " 360MODULE_DESCRIPTION("GHASH hash function, accelerated by PCLMULQDQ-NI");
361 "accelerated by PCLMULQDQ-NI");
362MODULE_ALIAS_CRYPTO("ghash"); 361MODULE_ALIAS_CRYPTO("ghash");
diff --git a/crypto/Kconfig b/crypto/Kconfig
index 2e7f08ba0675..455a3354e291 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -647,11 +647,12 @@ config CRYPTO_VPMSUM_TESTER
647 Unless you are testing these algorithms, you don't need this. 647 Unless you are testing these algorithms, you don't need this.
648 648
649config CRYPTO_GHASH 649config CRYPTO_GHASH
650 tristate "GHASH digest algorithm" 650 tristate "GHASH hash function"
651 select CRYPTO_GF128MUL 651 select CRYPTO_GF128MUL
652 select CRYPTO_HASH 652 select CRYPTO_HASH
653 help 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
656config CRYPTO_POLY1305 657config CRYPTO_POLY1305
657 tristate "Poly1305 authenticator algorithm" 658 tristate "Poly1305 authenticator algorithm"
@@ -976,12 +977,12 @@ config CRYPTO_WP512
976 <http://www.larc.usp.br/~pbarreto/WhirlpoolPage.html> 977 <http://www.larc.usp.br/~pbarreto/WhirlpoolPage.html>
977 978
978config CRYPTO_GHASH_CLMUL_NI_INTEL 979config CRYPTO_GHASH_CLMUL_NI_INTEL
979 tristate "GHASH digest algorithm (CLMUL-NI accelerated)" 980 tristate "GHASH hash function (CLMUL-NI accelerated)"
980 depends on X86 && 64BIT 981 depends on X86 && 64BIT
981 select CRYPTO_CRYPTD 982 select CRYPTO_CRYPTD
982 help 983 help
983 GHASH is message digest algorithm for GCM (Galois/Counter Mode). 984 This is the x86_64 CLMUL-NI accelerated implementation of
984 The implementation is accelerated by CLMUL-NI of Intel. 985 GHASH, the hash function used in GCM (Galois/Counter mode).
985 986
986comment "Ciphers" 987comment "Ciphers"
987 988
diff --git a/crypto/ghash-generic.c b/crypto/ghash-generic.c
index dad9e1f91a78..5027b3461c92 100644
--- a/crypto/ghash-generic.c
+++ b/crypto/ghash-generic.c
@@ -1,12 +1,37 @@
1// SPDX-License-Identifier: GPL-2.0-only 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 * Copyright (c) 2007 Nokia Siemens Networks - Mikko Herranen <mh1@iki.fi> 5 * Copyright (c) 2007 Nokia Siemens Networks - Mikko Herranen <mh1@iki.fi>
6 * Copyright (c) 2009 Intel Corp. 6 * Copyright (c) 2009 Intel Corp.
7 * Author: Huang Ying <ying.huang@intel.com> 7 * 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.
8 * 30 *
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)
10 */ 35 */
11 36
12#include <crypto/algapi.h> 37#include <crypto/algapi.h>
@@ -156,6 +181,6 @@ subsys_initcall(ghash_mod_init);
156module_exit(ghash_mod_exit); 181module_exit(ghash_mod_exit);
157 182
158MODULE_LICENSE("GPL"); 183MODULE_LICENSE("GPL");
159MODULE_DESCRIPTION("GHASH Message Digest Algorithm"); 184MODULE_DESCRIPTION("GHASH hash function");
160MODULE_ALIAS_CRYPTO("ghash"); 185MODULE_ALIAS_CRYPTO("ghash");
161MODULE_ALIAS_CRYPTO("ghash-generic"); 186MODULE_ALIAS_CRYPTO("ghash-generic");
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 69d1bbd5d9bf..b8c50871f11b 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -189,12 +189,12 @@ config S390_PRNG
189 It is available as of z9. 189 It is available as of z9.
190 190
191config CRYPTO_GHASH_S390 191config CRYPTO_GHASH_S390
192 tristate "GHASH digest algorithm" 192 tristate "GHASH hash function"
193 depends on S390 193 depends on S390
194 select CRYPTO_HASH 194 select CRYPTO_HASH
195 help 195 help
196 This is the s390 hardware accelerated implementation of the 196 This is the s390 hardware accelerated implementation of GHASH,
197 GHASH message digest algorithm for GCM (Galois/Counter Mode). 197 the hash function used in GCM (Galois/Counter mode).
198 198
199 It is available as of z196. 199 It is available as of z196.
200 200
diff --git a/include/crypto/ghash.h b/include/crypto/ghash.h
index 9136301062a5..f832c9f2aca3 100644
--- a/include/crypto/ghash.h
+++ b/include/crypto/ghash.h
@@ -1,6 +1,6 @@
1/* SPDX-License-Identifier: GPL-2.0 */ 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#ifndef __CRYPTO_GHASH_H__ 6#ifndef __CRYPTO_GHASH_H__