Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3588948pxb; Mon, 24 Jan 2022 12:57:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1/YsAGUOLLrBoz+Dur8E0uPGi9oQWBUEoDbPDbY37+uvPGnsE5uOsce6xBtifPRZ/vVj7 X-Received: by 2002:a17:902:c944:b0:14b:4a68:8ce2 with SMTP id i4-20020a170902c94400b0014b4a688ce2mr7038738pla.87.1643057860953; Mon, 24 Jan 2022 12:57:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643057860; cv=none; d=google.com; s=arc-20160816; b=LVmN30i8H27EosqI3rlr+lszImTm877a2GN9f3Y/zARoAhisNpUBuOuaF0hFb9KZmL G1ozMjBz9g3/UhB1zstZZpk/JdGBIaGnSvDz+M3J1D3Nh3vhG4xlBT5H8UyJxgLpFRKF U3j9JqEIjijptWhJ/qFW4OMkx85uSe5gunSJM221+m+X3tY9vXISw06yFDVt5VM1SV9I 81cQSRGCJnEtKV+6ypnjZh/Kr+iJJXeG/PPJ9w5fyDVaU5lWObbcabUfcOq8NDodSFeY Iy7t/atA1YS474L88lRRsK20bU2z2gMxF6Pbt35zxxEKiDL9Yq6Ck3M7r8fcz4sXQ3V/ 2J/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NDzTuIXswePulRZq2GZVDVi/wWvmpIMYWwQnKlt+LW4=; b=b0CEh9pZY5fSubCuBRvHZ4pPATTbYpqdxLFiOm2go2RW8NcvZWm4+31PYq4vdE5lhu uj6pETQG4Ei5KVMMHUR5rz3z1XED1lxknLuH7agp2/8S1/qGw6jyOn+n5yAxTBr7f3SE kdg30Ggrsxc4MIDdLiPomIQf9hEToJxlA/Ainj0V7/WXatYzLSWonxKOCoDX5/GI8N54 ui7I4r2gPAm8UnwThrkWCvzO3IaOeKdReilqTdScSIUx29D988Nw8VA42BHw6kHfFk4A lzpK3UJ9XwZ+LvDS2fofJdM/jZT+fq4bsSh3MTqZrdOujOX8DEw3CAK8OKOWI8j8sy4y iDSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OLKJokWw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n6si13619248pgp.485.2022.01.24.12.57.24; Mon, 24 Jan 2022 12:57:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OLKJokWw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355112AbiAXUSE (ORCPT + 99 others); Mon, 24 Jan 2022 15:18:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359865AbiAXUBJ (ORCPT ); Mon, 24 Jan 2022 15:01:09 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7264EC055A93; Mon, 24 Jan 2022 11:28:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2FDBFB811F9; Mon, 24 Jan 2022 19:28:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5ED6DC36AE3; Mon, 24 Jan 2022 19:28:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052506; bh=FWCm5xysMWqZECp81pwlwVFvC6oJtYvAhrTXIKd5FAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OLKJokWwxdNrY2IYVCAa/piluTBHpyz/kTsryj91JUt/SOuogvPL78OwZra1L6mcX +fRM8FgXo7l+oOoWGAeS2gUnf5qkvKoyW0LWxgjbdb89BpzQQulrU/K5qil5baSTY5 Wc3flPrkzDu5xffQsuOp4rfQrx9/lrYMdNENKLJQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Toromanoff , Herbert Xu , Sasha Levin Subject: [PATCH 5.4 081/320] crypto: stm32/cryp - fix lrw chaining mode Date: Mon, 24 Jan 2022 19:41:05 +0100 Message-Id: <20220124183956.496146394@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicolas Toromanoff [ Upstream commit fa97dc2d48b476ea98199d808d3248d285987e99 ] 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 Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/stm32/stm32-cryp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/stm32/stm32-cryp.c b/drivers/crypto/stm32/stm32-cryp.c index c41e66211c5b4..69c2468f1053d 100644 --- a/drivers/crypto/stm32/stm32-cryp.c +++ b/drivers/crypto/stm32/stm32-cryp.c @@ -639,7 +639,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) { -- 2.34.1