]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
crypto: marvell/cesa - add flag to determine algorithm endianness
authorRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 18 Oct 2015 16:23:40 +0000 (17:23 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 20 Oct 2015 14:10:51 +0000 (22:10 +0800)
Rather than determining whether we're using a MD5 hash by looking at
the digest size, switch to a cleaner solution using a per-request flag
initialised by the method type.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/marvell/cesa.h
drivers/crypto/marvell/hash.c

index 5a1fabdd67788f1f61742f00b4ec6a941d5c318c..e5f70ab4580d758b0c2c387b2ecfa15624108ad5 100644 (file)
@@ -612,6 +612,7 @@ struct mv_cesa_ahash_req {
        u64 len;
        int src_nents;
        bool last_req;
+       bool algo_le;
        u32 state[8];
 };
 
index 78941266e01f6c10375bc7afbd1f834c860890f1..f86594fb12baf9a7e78299f6c4ab4ddb90011eef 100644 (file)
@@ -351,7 +351,7 @@ static int mv_cesa_ahash_process(struct crypto_async_request *req, u32 status)
                 * Hardware's MD5 digest is in little endian format, but
                 * SHA in big endian format
                 */
-               if (digsize == MD5_DIGEST_SIZE) {
+               if (creq->algo_le) {
                        __le32 *result = (void *)ahashreq->result;
 
                        for (i = 0; i < digsize / 4; i++)
@@ -407,7 +407,7 @@ static const struct mv_cesa_req_ops mv_cesa_ahash_req_ops = {
 };
 
 static int mv_cesa_ahash_init(struct ahash_request *req,
-                             struct mv_cesa_op_ctx *tmpl)
+                             struct mv_cesa_op_ctx *tmpl, bool algo_le)
 {
        struct mv_cesa_ahash_req *creq = ahash_request_ctx(req);
 
@@ -421,6 +421,7 @@ static int mv_cesa_ahash_init(struct ahash_request *req,
        mv_cesa_set_mac_op_frag_len(tmpl, 0);
        creq->op_tmpl = *tmpl;
        creq->len = 0;
+       creq->algo_le = algo_le;
 
        return 0;
 }
@@ -863,7 +864,7 @@ static int mv_cesa_md5_init(struct ahash_request *req)
 
        mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_MD5);
 
-       mv_cesa_ahash_init(req, &tmpl);
+       mv_cesa_ahash_init(req, &tmpl, true);
 
        return 0;
 }
@@ -926,7 +927,7 @@ static int mv_cesa_sha1_init(struct ahash_request *req)
 
        mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_SHA1);
 
-       mv_cesa_ahash_init(req, &tmpl);
+       mv_cesa_ahash_init(req, &tmpl, false);
 
        return 0;
 }
@@ -989,7 +990,7 @@ static int mv_cesa_sha256_init(struct ahash_request *req)
 
        mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_SHA256);
 
-       mv_cesa_ahash_init(req, &tmpl);
+       mv_cesa_ahash_init(req, &tmpl, false);
 
        return 0;
 }
@@ -1220,7 +1221,7 @@ static int mv_cesa_ahmac_md5_init(struct ahash_request *req)
        mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_HMAC_MD5);
        memcpy(tmpl.ctx.hash.iv, ctx->iv, sizeof(ctx->iv));
 
-       mv_cesa_ahash_init(req, &tmpl);
+       mv_cesa_ahash_init(req, &tmpl, true);
 
        return 0;
 }
@@ -1290,7 +1291,7 @@ static int mv_cesa_ahmac_sha1_init(struct ahash_request *req)
        mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_HMAC_SHA1);
        memcpy(tmpl.ctx.hash.iv, ctx->iv, sizeof(ctx->iv));
 
-       mv_cesa_ahash_init(req, &tmpl);
+       mv_cesa_ahash_init(req, &tmpl, false);
 
        return 0;
 }
@@ -1380,7 +1381,7 @@ static int mv_cesa_ahmac_sha256_init(struct ahash_request *req)
        mv_cesa_set_op_cfg(&tmpl, CESA_SA_DESC_CFG_MACM_HMAC_SHA256);
        memcpy(tmpl.ctx.hash.iv, ctx->iv, sizeof(ctx->iv));
 
-       mv_cesa_ahash_init(req, &tmpl);
+       mv_cesa_ahash_init(req, &tmpl, false);
 
        return 0;
 }