mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 04:02:20 +00:00
crypto: aead - Add chunk size
This patch adds a chunk size parameter to aead algorithms, just like the chunk size for skcipher algorithms. However, unlike skcipher we do not currently export this to AEAD users. It is only meant to be used by AEAD implementors for now. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
a0129733a3
commit
7a530aa9cf
@ -346,9 +346,13 @@ static int aead_prepare_alg(struct aead_alg *alg)
|
||||
{
|
||||
struct crypto_alg *base = &alg->base;
|
||||
|
||||
if (max(alg->maxauthsize, alg->ivsize) > PAGE_SIZE / 8)
|
||||
if (max3(alg->maxauthsize, alg->ivsize, alg->chunksize) >
|
||||
PAGE_SIZE / 8)
|
||||
return -EINVAL;
|
||||
|
||||
if (!alg->chunksize)
|
||||
alg->chunksize = base->cra_blocksize;
|
||||
|
||||
base->cra_type = &crypto_aead_type;
|
||||
base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
|
||||
base->cra_flags |= CRYPTO_ALG_TYPE_AEAD;
|
||||
|
@ -112,11 +112,12 @@ struct aead_request {
|
||||
* supplied during the decryption operation. This function is also
|
||||
* responsible for checking the authentication tag size for
|
||||
* validity.
|
||||
* @setkey: see struct ablkcipher_alg
|
||||
* @encrypt: see struct ablkcipher_alg
|
||||
* @decrypt: see struct ablkcipher_alg
|
||||
* @geniv: see struct ablkcipher_alg
|
||||
* @ivsize: see struct ablkcipher_alg
|
||||
* @setkey: see struct skcipher_alg
|
||||
* @encrypt: see struct skcipher_alg
|
||||
* @decrypt: see struct skcipher_alg
|
||||
* @geniv: see struct skcipher_alg
|
||||
* @ivsize: see struct skcipher_alg
|
||||
* @chunksize: see struct skcipher_alg
|
||||
* @init: Initialize the cryptographic transformation object. This function
|
||||
* is used to initialize the cryptographic transformation object.
|
||||
* This function is called only once at the instantiation time, right
|
||||
@ -145,6 +146,7 @@ struct aead_alg {
|
||||
|
||||
unsigned int ivsize;
|
||||
unsigned int maxauthsize;
|
||||
unsigned int chunksize;
|
||||
|
||||
struct crypto_alg base;
|
||||
};
|
||||
|
@ -159,6 +159,27 @@ static inline struct aead_request *aead_get_backlog(struct aead_queue *queue)
|
||||
return req ? container_of(req, struct aead_request, base) : NULL;
|
||||
}
|
||||
|
||||
static inline unsigned int crypto_aead_alg_chunksize(struct aead_alg *alg)
|
||||
{
|
||||
return alg->chunksize;
|
||||
}
|
||||
|
||||
/**
|
||||
* crypto_aead_chunksize() - obtain chunk size
|
||||
* @tfm: cipher handle
|
||||
*
|
||||
* The block size is set to one for ciphers such as CCM. However,
|
||||
* you still need to provide incremental updates in multiples of
|
||||
* the underlying block size as the IV does not have sub-block
|
||||
* granularity. This is known in this API as the chunk size.
|
||||
*
|
||||
* Return: chunk size in bytes
|
||||
*/
|
||||
static inline unsigned int crypto_aead_chunksize(struct crypto_aead *tfm)
|
||||
{
|
||||
return crypto_aead_alg_chunksize(crypto_aead_alg(tfm));
|
||||
}
|
||||
|
||||
int crypto_register_aead(struct aead_alg *alg);
|
||||
void crypto_unregister_aead(struct aead_alg *alg);
|
||||
int crypto_register_aeads(struct aead_alg *algs, int count);
|
||||
|
Loading…
Reference in New Issue
Block a user