Skip to content

Commit c444b8d

Browse files
ambarusherbertx
authored andcommitted
crypto: kpp - assume key is already set in maxsize
As of now, crypto_kpp_maxsize() can not be reached without successfully setting the key for the transformation. kpp algorithm implementations check if the key was set and then return the output buffer size required for the given key. Change the return type to unsigned int and always assume that this function is called after a successful setkey of the transformation. kpp algorithm implementations will remove the check if key is not NULL and directly return the max size. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent ee34e26 commit c444b8d

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎include/crypto/kpp.h‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct kpp_alg {
7979
int (*generate_public_key)(struct kpp_request *req);
8080
int (*compute_shared_secret)(struct kpp_request *req);
8181

82-
int (*max_size)(struct crypto_kpp *tfm);
82+
unsigned int (*max_size)(struct crypto_kpp *tfm);
8383

8484
int (*init)(struct crypto_kpp *tfm);
8585
void (*exit)(struct crypto_kpp *tfm);
@@ -323,13 +323,14 @@ static inline int crypto_kpp_compute_shared_secret(struct kpp_request *req)
323323
/**
324324
* crypto_kpp_maxsize() - Get len for output buffer
325325
*
326-
* Function returns the output buffer size required
326+
* Function returns the output buffer size required for a given key.
327+
* Function assumes that the key is already set in the transformation. If this
328+
* function is called without a setkey or with a failed setkey, you will end up
329+
* in a NULL dereference.
327330
*
328331
* @tfm: KPP tfm handle allocated with crypto_alloc_kpp()
329-
*
330-
* Return: minimum len for output buffer or error code if key hasn't been set
331332
*/
332-
static inline int crypto_kpp_maxsize(struct crypto_kpp *tfm)
333+
static inline unsigned int crypto_kpp_maxsize(struct crypto_kpp *tfm)
333334
{
334335
struct kpp_alg *alg = crypto_kpp_alg(tfm);
335336

0 commit comments

Comments
 (0)