diff options
author | Eric Biggers <ebiggers@google.com> | 2019-07-20 02:09:18 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-07-27 07:08:38 -0400 |
commit | 8dfa20fcfbeb245642dfe3a43f8a3735d9aed42a (patch) | |
tree | 887e9ffb1793ff6f754ab839a528a170177f219d /crypto/ghash-generic.c | |
parent | 065cf577135a4977931c7a1e1edf442bfd9773dd (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>
Diffstat (limited to 'crypto/ghash-generic.c')
-rw-r--r-- | crypto/ghash-generic.c | 31 |
1 files changed, 28 insertions, 3 deletions
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); | |||
156 | module_exit(ghash_mod_exit); | 181 | module_exit(ghash_mod_exit); |
157 | 182 | ||
158 | MODULE_LICENSE("GPL"); | 183 | MODULE_LICENSE("GPL"); |
159 | MODULE_DESCRIPTION("GHASH Message Digest Algorithm"); | 184 | MODULE_DESCRIPTION("GHASH hash function"); |
160 | MODULE_ALIAS_CRYPTO("ghash"); | 185 | MODULE_ALIAS_CRYPTO("ghash"); |
161 | MODULE_ALIAS_CRYPTO("ghash-generic"); | 186 | MODULE_ALIAS_CRYPTO("ghash-generic"); |