crypto: stm32/cryp - fix lrw chaining mode
authorNicolas Toromanoff <nicolas.toromanoff@foss.st.com>
Tue, 30 Nov 2021 07:54:59 +0000 (08:54 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 11 Dec 2021 05:48:06 +0000 (16:48 +1100)
This fixes the lrw autotest if lrw uses the CRYP as the AES block cipher
provider (as ecb(aes)). At end of request, CRYP should not update the IV
in case of ECB chaining mode. Indeed the ECB chaining mode never uses
the IV, but the software LRW chaining mode uses the IV field as
a counter and due to the (unexpected) update done by CRYP while the AES
block process, the counter get a wrong value when the IV overflow.

Fixes: 5f49f18d27cd ("crypto: stm32/cryp - update to return iv_out")
Signed-off-by: Nicolas Toromanoff <nicolas.toromanoff@foss.st.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/stm32/stm32-cryp.c

index 3f71d927843cd58845cbc8d38cd4fd9c05ee8c2e..d3aa0afbe365be4e0637f38d684206c5e50704f7 100644 (file)
@@ -644,7 +644,7 @@ static void stm32_cryp_finish_req(struct stm32_cryp *cryp, int err)
                /* Phase 4 : output tag */
                err = stm32_cryp_read_auth_tag(cryp);
 
-       if (!err && (!(is_gcm(cryp) || is_ccm(cryp))))
+       if (!err && (!(is_gcm(cryp) || is_ccm(cryp) || is_ecb(cryp))))
                stm32_cryp_get_iv(cryp);
 
        if (cryp->sgs_copied) {