]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
crypto: ghash - add comment and improve help text
authorEric Biggers <ebiggers@google.com>
Sat, 20 Jul 2019 06:09:18 +0000 (23:09 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 27 Jul 2019 11:08:38 +0000 (21:08 +1000)
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>
arch/arm/crypto/ghash-ce-glue.c
arch/s390/crypto/ghash_s390.c
arch/x86/crypto/ghash-clmulni-intel_glue.c
crypto/Kconfig
crypto/ghash-generic.c
drivers/crypto/Kconfig
include/crypto/ghash.h

index bb906b5f1eb3689330fe05af8390d7457390b3d2..c691077679a63140941afc8d3f308db28503936a 100644 (file)
@@ -18,7 +18,7 @@
 #include <linux/crypto.h>
 #include <linux/module.h>
 
-MODULE_DESCRIPTION("GHASH secure hash using ARMv8 Crypto Extensions");
+MODULE_DESCRIPTION("GHASH hash function using ARMv8 Crypto Extensions");
 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
 MODULE_LICENSE("GPL v2");
 MODULE_ALIAS_CRYPTO("ghash");
index eeeb6a7737a4ae41634ccb55578e23537288937c..a3e7400e031cab530d53a50509be157b1de53c0f 100644 (file)
@@ -153,4 +153,4 @@ module_exit(ghash_mod_exit);
 MODULE_ALIAS_CRYPTO("ghash");
 
 MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("GHASH Message Digest Algorithm, s390 implementation");
+MODULE_DESCRIPTION("GHASH hash function, s390 implementation");
index ac76fe88ac4fdf7a1b1bcff5780bc2d52faddd8b..04d72a5a8ce9815ffca1db870b4110fe2a4c4166 100644 (file)
@@ -357,6 +357,5 @@ module_init(ghash_pclmulqdqni_mod_init);
 module_exit(ghash_pclmulqdqni_mod_exit);
 
 MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("GHASH Message Digest Algorithm, "
-                  "accelerated by PCLMULQDQ-NI");
+MODULE_DESCRIPTION("GHASH hash function, accelerated by PCLMULQDQ-NI");
 MODULE_ALIAS_CRYPTO("ghash");
index 2e7f08ba0675201943ed8bfda9d372e83c3d13d8..455a3354e2914f1a369db27b87344327fe13af84 100644 (file)
@@ -647,11 +647,12 @@ config CRYPTO_VPMSUM_TESTER
          Unless you are testing these algorithms, you don't need this.
 
 config CRYPTO_GHASH
-       tristate "GHASH digest algorithm"
+       tristate "GHASH hash function"
        select CRYPTO_GF128MUL
        select CRYPTO_HASH
        help
-         GHASH is message digest algorithm for GCM (Galois/Counter Mode).
+         GHASH is the hash function used in GCM (Galois/Counter Mode).
+         It is not a general-purpose cryptographic hash function.
 
 config CRYPTO_POLY1305
        tristate "Poly1305 authenticator algorithm"
@@ -976,12 +977,12 @@ config CRYPTO_WP512
          <http://www.larc.usp.br/~pbarreto/WhirlpoolPage.html>
 
 config CRYPTO_GHASH_CLMUL_NI_INTEL
-       tristate "GHASH digest algorithm (CLMUL-NI accelerated)"
+       tristate "GHASH hash function (CLMUL-NI accelerated)"
        depends on X86 && 64BIT
        select CRYPTO_CRYPTD
        help
-         GHASH is message digest algorithm for GCM (Galois/Counter Mode).
-         The implementation is accelerated by CLMUL-NI of Intel.
+         This is the x86_64 CLMUL-NI accelerated implementation of
+         GHASH, the hash function used in GCM (Galois/Counter mode).
 
 comment "Ciphers"
 
index dad9e1f91a783f66f6cfcaf9521de45c6f57ba32..5027b3461c921eb90fddbbf1401b529452a63c4b 100644 (file)
@@ -1,12 +1,37 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * GHASH: digest algorithm for GCM (Galois/Counter Mode).
+ * GHASH: hash function for GCM (Galois/Counter Mode).
  *
  * Copyright (c) 2007 Nokia Siemens Networks - Mikko Herranen <mh1@iki.fi>
  * Copyright (c) 2009 Intel Corp.
  *   Author: Huang Ying <ying.huang@intel.com>
+ */
+
+/*
+ * GHASH is a keyed hash function used in GCM authentication tag generation.
+ *
+ * The original GCM paper [1] presents GHASH as a function GHASH(H, A, C) which
+ * takes a 16-byte hash key H, additional authenticated data A, and a ciphertext
+ * C.  It formats A and C into a single byte string X, interprets X as a
+ * polynomial over GF(2^128), and evaluates this polynomial at the point H.
+ *
+ * However, the NIST standard for GCM [2] presents GHASH as GHASH(H, X) where X
+ * is the already-formatted byte string containing both A and C.
+ *
+ * "ghash" in the Linux crypto API uses the 'X' (pre-formatted) convention,
+ * since the API supports only a single data stream per hash.  Thus, the
+ * formatting of 'A' and 'C' is done in the "gcm" template, not in "ghash".
+ *
+ * The reason "ghash" is separate from "gcm" is to allow "gcm" to use an
+ * accelerated "ghash" when a standalone accelerated "gcm(aes)" is unavailable.
+ * It is generally inappropriate to use "ghash" for other purposes, since it is
+ * an "ε-almost-XOR-universal hash function", not a cryptographic hash function.
+ * It can only be used securely in crypto modes specially designed to use it.
  *
- * The algorithm implementation is copied from gcm.c.
+ * [1] The Galois/Counter Mode of Operation (GCM)
+ *     (http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.694.695&rep=rep1&type=pdf)
+ * [2] Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC
+ *     (https://csrc.nist.gov/publications/detail/sp/800-38d/final)
  */
 
 #include <crypto/algapi.h>
@@ -156,6 +181,6 @@ subsys_initcall(ghash_mod_init);
 module_exit(ghash_mod_exit);
 
 MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("GHASH Message Digest Algorithm");
+MODULE_DESCRIPTION("GHASH hash function");
 MODULE_ALIAS_CRYPTO("ghash");
 MODULE_ALIAS_CRYPTO("ghash-generic");
index 69d1bbd5d9bfcd24e1bc6be536cb9c8c12c5702c..b8c50871f11b2ad5459be0af45c93865bc77a1dd 100644 (file)
@@ -189,12 +189,12 @@ config S390_PRNG
          It is available as of z9.
 
 config CRYPTO_GHASH_S390
-       tristate "GHASH digest algorithm"
+       tristate "GHASH hash function"
        depends on S390
        select CRYPTO_HASH
        help
-         This is the s390 hardware accelerated implementation of the
-         GHASH message digest algorithm for GCM (Galois/Counter Mode).
+         This is the s390 hardware accelerated implementation of GHASH,
+         the hash function used in GCM (Galois/Counter mode).
 
          It is available as of z196.
 
index 9136301062a5cada1a7418db9274c7198c9227b9..f832c9f2aca3036afabba2d91e910164188f2ce3 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Common values for GHASH algorithms
+ * Common values for the GHASH hash function
  */
 
 #ifndef __CRYPTO_GHASH_H__