summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTudor-Dan Ambarus <tudor.ambarus@microchip.com>2017-05-25 03:18:12 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2017-06-10 00:04:29 -0400
commit561f8e2df990a7a2859a98bd208d0f7dc932c3f7 (patch)
treefbc775fe95009d6bd4c99a9e3d83839404b08ccb
parent85ac98cbac1bb63c878486b88bfb6f5bac540e21 (diff)
crypto: akcipher - assume key is already set in maxsize
As of now, crypto_akcipher_maxsize() can not be reached without successfully setting the key for the transformation. akcipher 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. akcipher 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>
-rw-r--r--include/crypto/akcipher.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/include/crypto/akcipher.h b/include/crypto/akcipher.h
index c37cc59e9bf2..b5e11de4d497 100644
--- a/include/crypto/akcipher.h
+++ b/include/crypto/akcipher.h
@@ -98,7 +98,7 @@ struct akcipher_alg {
98 unsigned int keylen); 98 unsigned int keylen);
99 int (*set_priv_key)(struct crypto_akcipher *tfm, const void *key, 99 int (*set_priv_key)(struct crypto_akcipher *tfm, const void *key,
100 unsigned int keylen); 100 unsigned int keylen);
101 int (*max_size)(struct crypto_akcipher *tfm); 101 unsigned int (*max_size)(struct crypto_akcipher *tfm);
102 int (*init)(struct crypto_akcipher *tfm); 102 int (*init)(struct crypto_akcipher *tfm);
103 void (*exit)(struct crypto_akcipher *tfm); 103 void (*exit)(struct crypto_akcipher *tfm);
104 104
@@ -257,13 +257,14 @@ static inline void akcipher_request_set_crypt(struct akcipher_request *req,
257/** 257/**
258 * crypto_akcipher_maxsize() - Get len for output buffer 258 * crypto_akcipher_maxsize() - Get len for output buffer
259 * 259 *
260 * Function returns the dest buffer size required for a given key 260 * Function returns the dest buffer size required for a given key.
261 * Function assumes that the key is already set in the transformation. If this
262 * function is called without a setkey or with a failed setkey, you will end up
263 * in a NULL dereference.
261 * 264 *
262 * @tfm: AKCIPHER tfm handle allocated with crypto_alloc_akcipher() 265 * @tfm: AKCIPHER tfm handle allocated with crypto_alloc_akcipher()
263 *
264 * Return: minimum len for output buffer or error code in key hasn't been set
265 */ 266 */
266static inline int crypto_akcipher_maxsize(struct crypto_akcipher *tfm) 267static inline unsigned int crypto_akcipher_maxsize(struct crypto_akcipher *tfm)
267{ 268{
268 struct akcipher_alg *alg = crypto_akcipher_alg(tfm); 269 struct akcipher_alg *alg = crypto_akcipher_alg(tfm);
269 270