Commit 3cd54a4c authored by Eric Biggers's avatar Eric Biggers Committed by Herbert Xu

crypto: aead - improve documentation for scatterlist layout

Properly document the scatterlist layout for AEAD ciphers.
Reported-by: default avatarGilad Ben-Yossef <gilad@benyossef.com>
Cc: Stephan Mueller <smueller@chronox.de>
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 8ff357a9
...@@ -43,27 +43,33 @@ ...@@ -43,27 +43,33 @@
* *
* Memory Structure: * Memory Structure:
* *
* To support the needs of the most prominent user of AEAD ciphers, namely * The source scatterlist must contain the concatenation of
* IPSEC, the AEAD ciphers have a special memory layout the caller must adhere * associated data || plaintext or ciphertext.
* to. *
* * The destination scatterlist has the same layout, except that the plaintext
* The scatter list pointing to the input data must contain: * (resp. ciphertext) will grow (resp. shrink) by the authentication tag size
* * during encryption (resp. decryption).
* * for RFC4106 ciphers, the concatenation of *
* associated authentication data || IV || plaintext or ciphertext. Note, the * In-place encryption/decryption is enabled by using the same scatterlist
* same IV (buffer) is also set with the aead_request_set_crypt call. Note, * pointer for both the source and destination.
* the API call of aead_request_set_ad must provide the length of the AAD and *
* the IV. The API call of aead_request_set_crypt only points to the size of * Even in the out-of-place case, space must be reserved in the destination for
* the input plaintext or ciphertext. * the associated data, even though it won't be written to. This makes the
* * in-place and out-of-place cases more consistent. It is permissible for the
* * for "normal" AEAD ciphers, the concatenation of * "destination" associated data to alias the "source" associated data.
* associated authentication data || plaintext or ciphertext. *
* * As with the other scatterlist crypto APIs, zero-length scatterlist elements
* It is important to note that if multiple scatter gather list entries form * are not allowed in the used part of the scatterlist. Thus, if there is no
* the input data mentioned above, the first entry must not point to a NULL * associated data, the first element must point to the plaintext/ciphertext.
* buffer. If there is any potential where the AAD buffer can be NULL, the *
* calling code must contain a precaution to ensure that this does not result * To meet the needs of IPsec, a special quirk applies to rfc4106, rfc4309,
* in the first scatter gather list entry pointing to a NULL buffer. * rfc4543, and rfc7539esp ciphers. For these ciphers, the final 'ivsize' bytes
* of the associated data buffer must contain a second copy of the IV. This is
* in addition to the copy passed to aead_request_set_crypt(). These two IV
* copies must not differ; different implementations of the same algorithm may
* behave differently in that case. Note that the algorithm might not actually
* treat the IV as associated data; nevertheless the length passed to
* aead_request_set_ad() must include it.
*/ */
struct crypto_aead; struct crypto_aead;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment