diff mbox series

[v2] crypto: s5p: update iv after AES-CBC op end

Message ID 20190219160232.22084-1-k.konieczny@partner.samsung.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series [v2] crypto: s5p: update iv after AES-CBC op end | expand

Commit Message

Kamil Konieczny Feb. 19, 2019, 4:02 p.m. UTC
Fix bug "s5p-sss crypto driver doesn't set next AES-CBC IV". While at this,
fix also AES-CTR mode. Tested on Odroid U3 with Eric Biggers branch
"iv-out-testing".

Signed-off-by: Kamil Konieczny <k.konieczny@partner.samsung.com>
Reported-by: Eric Biggers <ebiggers@kernel.org>
---
Changes since v1:
 - reworded Subject and commit message
 - changed code according to comments by Krzysztof Kozlowski
 - added Reported-by line
---
 drivers/crypto/s5p-sss.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Krzysztof Kozlowski Feb. 19, 2019, 4:41 p.m. UTC | #1
On Tue, 19 Feb 2019 at 17:02, Kamil Konieczny
<k.konieczny@partner.samsung.com> wrote:
>
> Fix bug "s5p-sss crypto driver doesn't set next AES-CBC IV". While at this,
> fix also AES-CTR mode. Tested on Odroid U3 with Eric Biggers branch
> "iv-out-testing".
>
> Signed-off-by: Kamil Konieczny <k.konieczny@partner.samsung.com>
> Reported-by: Eric Biggers <ebiggers@kernel.org>
> ---
> Changes since v1:
>  - reworded Subject and commit message
>  - changed code according to comments by Krzysztof Kozlowski
>  - added Reported-by line
> ---
>  drivers/crypto/s5p-sss.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>

Best regards,
Krzysztof
Herbert Xu Feb. 28, 2019, 6:30 a.m. UTC | #2
On Tue, Feb 19, 2019 at 05:02:32PM +0100, Kamil Konieczny wrote:
> Fix bug "s5p-sss crypto driver doesn't set next AES-CBC IV". While at this,
> fix also AES-CTR mode. Tested on Odroid U3 with Eric Biggers branch
> "iv-out-testing".
> 
> Signed-off-by: Kamil Konieczny <k.konieczny@partner.samsung.com>
> Reported-by: Eric Biggers <ebiggers@kernel.org>
> ---
> Changes since v1:
>  - reworded Subject and commit message
>  - changed code according to comments by Krzysztof Kozlowski
>  - added Reported-by line
> ---
>  drivers/crypto/s5p-sss.c | 8 ++++++++
>  1 file changed, 8 insertions(+)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
index 0064be0e3941..30b4f1015d8f 100644
--- a/drivers/crypto/s5p-sss.c
+++ b/drivers/crypto/s5p-sss.c
@@ -463,6 +463,9 @@  static void s5p_sg_copy_buf(void *buf, struct scatterlist *sg,
 
 static void s5p_sg_done(struct s5p_aes_dev *dev)
 {
+	struct ablkcipher_request *req = dev->req;
+	struct s5p_aes_reqctx *reqctx = ablkcipher_request_ctx(req);
+
 	if (dev->sg_dst_cpy) {
 		dev_dbg(dev->dev,
 			"Copying %d bytes of output data back to original place\n",
@@ -472,6 +475,11 @@  static void s5p_sg_done(struct s5p_aes_dev *dev)
 	}
 	s5p_free_sg_cpy(dev, &dev->sg_src_cpy);
 	s5p_free_sg_cpy(dev, &dev->sg_dst_cpy);
+	if (reqctx->mode & FLAGS_AES_CBC)
+		memcpy_fromio(req->info, dev->aes_ioaddr + SSS_REG_AES_IV_DATA(0), AES_BLOCK_SIZE);
+
+	else if (reqctx->mode & FLAGS_AES_CTR)
+		memcpy_fromio(req->info, dev->aes_ioaddr + SSS_REG_AES_CNT_DATA(0), AES_BLOCK_SIZE);
 }
 
 /* Calls the completion. Cannot be called with dev->lock hold. */