crypto: skcipher - Make use of internal state

This patch adds code to the skcipher/lskcipher API to make use
of the internal state if present.  In particular, the skcipher
lskcipher wrapper will allocate a buffer for the IV/state and
feed that to the underlying lskcipher algorithm.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Herbert Xu
2023-11-28 14:33:19 +08:00
parent 0ae4dcc1eb
commit 662ea18d08
3 changed files with 139 additions and 8 deletions

View File

@@ -746,6 +746,39 @@ int crypto_skcipher_encrypt(struct skcipher_request *req);
*/
int crypto_skcipher_decrypt(struct skcipher_request *req);
/**
* crypto_skcipher_export() - export partial state
* @req: reference to the skcipher_request handle that holds all information
* needed to perform the operation
* @out: output buffer of sufficient size that can hold the state
*
* Export partial state of the transformation. This function dumps the
* entire state of the ongoing transformation into a provided block of
* data so it can be @import 'ed back later on. This is useful in case
* you want to save partial result of the transformation after
* processing certain amount of data and reload this partial result
* multiple times later on for multiple re-use. No data processing
* happens at this point.
*
* Return: 0 if the cipher operation was successful; < 0 if an error occurred
*/
int crypto_skcipher_export(struct skcipher_request *req, void *out);
/**
* crypto_skcipher_import() - import partial state
* @req: reference to the skcipher_request handle that holds all information
* needed to perform the operation
* @in: buffer holding the state
*
* Import partial state of the transformation. This function loads the
* entire state of the ongoing transformation from a provided block of
* data so the transformation can continue from this point onward. No
* data processing happens at this point.
*
* Return: 0 if the cipher operation was successful; < 0 if an error occurred
*/
int crypto_skcipher_import(struct skcipher_request *req, const void *in);
/**
* crypto_lskcipher_encrypt() - encrypt plaintext
* @tfm: lskcipher handle