mirror of https://gitee.com/openkylin/linux.git
crypto: atmel-{aes,tdes} - Do not save IV for ECB mode
ECB mode does not use IV. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
75eca7a7f2
commit
c65d123742
|
@ -515,6 +515,9 @@ static void atmel_aes_set_iv_as_last_ciphertext_block(struct atmel_aes_dev *dd)
|
||||||
|
|
||||||
static inline int atmel_aes_complete(struct atmel_aes_dev *dd, int err)
|
static inline int atmel_aes_complete(struct atmel_aes_dev *dd, int err)
|
||||||
{
|
{
|
||||||
|
struct skcipher_request *req = skcipher_request_cast(dd->areq);
|
||||||
|
struct atmel_aes_reqctx *rctx = skcipher_request_ctx(req);
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC)
|
#if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC)
|
||||||
if (dd->ctx->is_aead)
|
if (dd->ctx->is_aead)
|
||||||
atmel_aes_authenc_complete(dd, err);
|
atmel_aes_authenc_complete(dd, err);
|
||||||
|
@ -523,7 +526,8 @@ static inline int atmel_aes_complete(struct atmel_aes_dev *dd, int err)
|
||||||
clk_disable(dd->iclk);
|
clk_disable(dd->iclk);
|
||||||
dd->flags &= ~AES_FLAGS_BUSY;
|
dd->flags &= ~AES_FLAGS_BUSY;
|
||||||
|
|
||||||
if (!dd->ctx->is_aead)
|
if (!dd->ctx->is_aead &&
|
||||||
|
(rctx->mode & AES_FLAGS_OPMODE_MASK) != AES_FLAGS_ECB)
|
||||||
atmel_aes_set_iv_as_last_ciphertext_block(dd);
|
atmel_aes_set_iv_as_last_ciphertext_block(dd);
|
||||||
|
|
||||||
if (dd->is_async)
|
if (dd->is_async)
|
||||||
|
@ -1130,7 +1134,8 @@ static int atmel_aes_crypt(struct skcipher_request *req, unsigned long mode)
|
||||||
rctx = skcipher_request_ctx(req);
|
rctx = skcipher_request_ctx(req);
|
||||||
rctx->mode = mode;
|
rctx->mode = mode;
|
||||||
|
|
||||||
if (!(mode & AES_FLAGS_ENCRYPT) && (req->src == req->dst)) {
|
if ((mode & AES_FLAGS_OPMODE_MASK) != AES_FLAGS_ECB &&
|
||||||
|
!(mode & AES_FLAGS_ENCRYPT) && req->src == req->dst) {
|
||||||
unsigned int ivsize = crypto_skcipher_ivsize(skcipher);
|
unsigned int ivsize = crypto_skcipher_ivsize(skcipher);
|
||||||
|
|
||||||
if (req->cryptlen >= ivsize)
|
if (req->cryptlen >= ivsize)
|
||||||
|
|
|
@ -593,12 +593,14 @@ atmel_tdes_set_iv_as_last_ciphertext_block(struct atmel_tdes_dev *dd)
|
||||||
static void atmel_tdes_finish_req(struct atmel_tdes_dev *dd, int err)
|
static void atmel_tdes_finish_req(struct atmel_tdes_dev *dd, int err)
|
||||||
{
|
{
|
||||||
struct skcipher_request *req = dd->req;
|
struct skcipher_request *req = dd->req;
|
||||||
|
struct atmel_tdes_reqctx *rctx = skcipher_request_ctx(req);
|
||||||
|
|
||||||
clk_disable_unprepare(dd->iclk);
|
clk_disable_unprepare(dd->iclk);
|
||||||
|
|
||||||
dd->flags &= ~TDES_FLAGS_BUSY;
|
dd->flags &= ~TDES_FLAGS_BUSY;
|
||||||
|
|
||||||
atmel_tdes_set_iv_as_last_ciphertext_block(dd);
|
if ((rctx->mode & TDES_FLAGS_OPMODE_MASK) != TDES_FLAGS_ECB)
|
||||||
|
atmel_tdes_set_iv_as_last_ciphertext_block(dd);
|
||||||
|
|
||||||
req->base.complete(&req->base, err);
|
req->base.complete(&req->base, err);
|
||||||
}
|
}
|
||||||
|
@ -728,7 +730,8 @@ static int atmel_tdes_crypt(struct skcipher_request *req, unsigned long mode)
|
||||||
|
|
||||||
rctx->mode = mode;
|
rctx->mode = mode;
|
||||||
|
|
||||||
if (!(mode & TDES_FLAGS_ENCRYPT) && req->src == req->dst) {
|
if ((mode & TDES_FLAGS_OPMODE_MASK) != TDES_FLAGS_ECB &&
|
||||||
|
!(mode & TDES_FLAGS_ENCRYPT) && req->src == req->dst) {
|
||||||
unsigned int ivsize = crypto_skcipher_ivsize(skcipher);
|
unsigned int ivsize = crypto_skcipher_ivsize(skcipher);
|
||||||
|
|
||||||
if (req->cryptlen >= ivsize)
|
if (req->cryptlen >= ivsize)
|
||||||
|
|
Loading…
Reference in New Issue