提交 de1a00ac 编写于 作者: H Harsh Jain 提交者: Herbert Xu

crypto: chelsio - Use x8_ble gf multiplication to calculate IV.

gf128mul_x8_ble() will reduce gf Multiplication iteration by 8.
Signed-off-by: NHarsh Jain <harsh@chelsio.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
上级 acfc5878
...@@ -889,9 +889,11 @@ static int chcr_update_tweak(struct ablkcipher_request *req, u8 *iv) ...@@ -889,9 +889,11 @@ static int chcr_update_tweak(struct ablkcipher_request *req, u8 *iv)
int ret, i; int ret, i;
u8 *key; u8 *key;
unsigned int keylen; unsigned int keylen;
int round = reqctx->last_req_len / AES_BLOCK_SIZE;
int round8 = round / 8;
cipher = ablkctx->aes_generic; cipher = ablkctx->aes_generic;
memcpy(iv, req->info, AES_BLOCK_SIZE); memcpy(iv, reqctx->iv, AES_BLOCK_SIZE);
keylen = ablkctx->enckey_len / 2; keylen = ablkctx->enckey_len / 2;
key = ablkctx->key + keylen; key = ablkctx->key + keylen;
...@@ -900,7 +902,10 @@ static int chcr_update_tweak(struct ablkcipher_request *req, u8 *iv) ...@@ -900,7 +902,10 @@ static int chcr_update_tweak(struct ablkcipher_request *req, u8 *iv)
goto out; goto out;
crypto_cipher_encrypt_one(cipher, iv, iv); crypto_cipher_encrypt_one(cipher, iv, iv);
for (i = 0; i < (reqctx->processed / AES_BLOCK_SIZE); i++) for (i = 0; i < round8; i++)
gf128mul_x8_ble((le128 *)iv, (le128 *)iv);
for (i = 0; i < (round % 8); i++)
gf128mul_x_ble((le128 *)iv, (le128 *)iv); gf128mul_x_ble((le128 *)iv, (le128 *)iv);
crypto_cipher_decrypt_one(cipher, iv, iv); crypto_cipher_decrypt_one(cipher, iv, iv);
...@@ -1041,6 +1046,7 @@ static int chcr_handle_cipher_resp(struct ablkcipher_request *req, ...@@ -1041,6 +1046,7 @@ static int chcr_handle_cipher_resp(struct ablkcipher_request *req,
CRYPTO_ALG_SUB_TYPE_CTR) CRYPTO_ALG_SUB_TYPE_CTR)
bytes = adjust_ctr_overflow(reqctx->iv, bytes); bytes = adjust_ctr_overflow(reqctx->iv, bytes);
reqctx->processed += bytes; reqctx->processed += bytes;
reqctx->last_req_len = bytes;
wrparam.qid = u_ctx->lldi.rxq_ids[ctx->rx_qidx]; wrparam.qid = u_ctx->lldi.rxq_ids[ctx->rx_qidx];
wrparam.req = req; wrparam.req = req;
wrparam.bytes = bytes; wrparam.bytes = bytes;
...@@ -1133,6 +1139,7 @@ static int process_cipher(struct ablkcipher_request *req, ...@@ -1133,6 +1139,7 @@ static int process_cipher(struct ablkcipher_request *req,
goto error; goto error;
} }
reqctx->processed = bytes; reqctx->processed = bytes;
reqctx->last_req_len = bytes;
reqctx->dst = reqctx->dstsg; reqctx->dst = reqctx->dstsg;
reqctx->op = op_type; reqctx->op = op_type;
wrparam.qid = qid; wrparam.qid = qid;
......
...@@ -247,6 +247,7 @@ struct chcr_blkcipher_req_ctx { ...@@ -247,6 +247,7 @@ struct chcr_blkcipher_req_ctx {
struct scatterlist *dst; struct scatterlist *dst;
struct scatterlist *newdstsg; struct scatterlist *newdstsg;
unsigned int processed; unsigned int processed;
unsigned int last_req_len;
unsigned int op; unsigned int op;
short int dst_nents; short int dst_nents;
u8 iv[CHCR_MAX_CRYPTO_IV_LEN]; u8 iv[CHCR_MAX_CRYPTO_IV_LEN];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册