|
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. |
| 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 | 37 | #include <crypto/algapi.h> |
@@ -156,6 +181,6 @@ subsys_initcall(ghash_mod_init); |
156 | 181 | module_exit(ghash_mod_exit); |
157 | 182 |
|
158 | 183 | MODULE_LICENSE("GPL"); |
159 | | -MODULE_DESCRIPTION("GHASH Message Digest Algorithm"); |
| 184 | +MODULE_DESCRIPTION("GHASH hash function"); |
160 | 185 | MODULE_ALIAS_CRYPTO("ghash"); |
161 | 186 | MODULE_ALIAS_CRYPTO("ghash-generic"); |
0 commit comments