crypto: caam - check zero-length input
authorIuliana Prodan <iuliana.prodan@nxp.com>
Wed, 31 Jul 2019 13:08:08 +0000 (16:08 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 9 Aug 2019 05:11:48 +0000 (15:11 +1000)
Check zero-length input, for skcipher algorithm, to solve the extra
tests. This is a valid operation, therefore the API will return no error.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
Reviewed-by: Horia Geanta <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caamalg.c
drivers/crypto/caam/caamalg_qi.c
drivers/crypto/caam/caamalg_qi2.c

index f832491..21e30de 100644 (file)
@@ -1884,6 +1884,9 @@ static int skcipher_encrypt(struct skcipher_request *req)
        u32 *desc;
        int ret = 0;
 
+       if (!req->cryptlen)
+               return 0;
+
        /* allocate extended descriptor */
        edesc = skcipher_edesc_alloc(req, DESC_JOB_IO_LEN * CAAM_CMD_SZ);
        if (IS_ERR(edesc))
@@ -1918,6 +1921,9 @@ static int skcipher_decrypt(struct skcipher_request *req)
        u32 *desc;
        int ret = 0;
 
+       if (!req->cryptlen)
+               return 0;
+
        /* allocate extended descriptor */
        edesc = skcipher_edesc_alloc(req, DESC_JOB_IO_LEN * CAAM_CMD_SZ);
        if (IS_ERR(edesc))
index 2158020..e63b2f7 100644 (file)
@@ -1445,6 +1445,9 @@ static inline int skcipher_crypt(struct skcipher_request *req, bool encrypt)
        struct caam_ctx *ctx = crypto_skcipher_ctx(skcipher);
        int ret;
 
+       if (!req->cryptlen)
+               return 0;
+
        if (unlikely(caam_congested))
                return -EAGAIN;
 
index 7350142..63a86b6 100644 (file)
@@ -1499,6 +1499,9 @@ static int skcipher_encrypt(struct skcipher_request *req)
        struct caam_request *caam_req = skcipher_request_ctx(req);
        int ret;
 
+       if (!req->cryptlen)
+               return 0;
+
        /* allocate extended descriptor */
        edesc = skcipher_edesc_alloc(req);
        if (IS_ERR(edesc))
@@ -1527,6 +1530,8 @@ static int skcipher_decrypt(struct skcipher_request *req)
        struct caam_request *caam_req = skcipher_request_ctx(req);
        int ret;
 
+       if (!req->cryptlen)
+               return 0;
        /* allocate extended descriptor */
        edesc = skcipher_edesc_alloc(req);
        if (IS_ERR(edesc))