Commit 5fb78dba authored by Harsh Jain's avatar Harsh Jain Committed by Herbert Xu

crypto: chelsio - Update IV before sending request to HW

CBC Decryption requires Last Block as IV. In case src/dst buffer
are same last block will be replaced by plain text. This patch copies
the Last Block before sending request to HW.
Signed-off-by: default avatarHarsh Jain <harsh@chelsio.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 1d693cf6
...@@ -854,6 +854,13 @@ static struct sk_buff *create_cipher_wr(struct cipher_wr_param *wrparam) ...@@ -854,6 +854,13 @@ static struct sk_buff *create_cipher_wr(struct cipher_wr_param *wrparam)
transhdr_len, temp, transhdr_len, temp,
ablkctx->ciph_mode == CHCR_SCMD_CIPHER_MODE_AES_CBC); ablkctx->ciph_mode == CHCR_SCMD_CIPHER_MODE_AES_CBC);
reqctx->skb = skb; reqctx->skb = skb;
if (reqctx->op && (ablkctx->ciph_mode ==
CHCR_SCMD_CIPHER_MODE_AES_CBC))
sg_pcopy_to_buffer(wrparam->req->src,
sg_nents(wrparam->req->src), wrparam->req->info, 16,
reqctx->processed + wrparam->bytes - AES_BLOCK_SIZE);
return skb; return skb;
err: err:
return ERR_PTR(error); return ERR_PTR(error);
...@@ -1077,9 +1084,8 @@ static int chcr_update_cipher_iv(struct ablkcipher_request *req, ...@@ -1077,9 +1084,8 @@ static int chcr_update_cipher_iv(struct ablkcipher_request *req,
ret = chcr_update_tweak(req, iv, 0); ret = chcr_update_tweak(req, iv, 0);
else if (subtype == CRYPTO_ALG_SUB_TYPE_CBC) { else if (subtype == CRYPTO_ALG_SUB_TYPE_CBC) {
if (reqctx->op) if (reqctx->op)
sg_pcopy_to_buffer(req->src, sg_nents(req->src), iv, /*Updated before sending last WR*/
16, memcpy(iv, req->info, AES_BLOCK_SIZE);
reqctx->processed - AES_BLOCK_SIZE);
else else
memcpy(iv, &fw6_pld->data[2], AES_BLOCK_SIZE); memcpy(iv, &fw6_pld->data[2], AES_BLOCK_SIZE);
} }
...@@ -1107,11 +1113,8 @@ static int chcr_final_cipher_iv(struct ablkcipher_request *req, ...@@ -1107,11 +1113,8 @@ static int chcr_final_cipher_iv(struct ablkcipher_request *req,
else if (subtype == CRYPTO_ALG_SUB_TYPE_XTS) else if (subtype == CRYPTO_ALG_SUB_TYPE_XTS)
ret = chcr_update_tweak(req, iv, 1); ret = chcr_update_tweak(req, iv, 1);
else if (subtype == CRYPTO_ALG_SUB_TYPE_CBC) { else if (subtype == CRYPTO_ALG_SUB_TYPE_CBC) {
if (reqctx->op) /*Already updated for Decrypt*/
sg_pcopy_to_buffer(req->src, sg_nents(req->src), iv, if (!reqctx->op)
16,
reqctx->processed - AES_BLOCK_SIZE);
else
memcpy(iv, &fw6_pld->data[2], AES_BLOCK_SIZE); memcpy(iv, &fw6_pld->data[2], AES_BLOCK_SIZE);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment