Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3784718ybi; Mon, 29 Jul 2019 12:34:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjUr3SNqyIe89UFe4p/QNj6d8UYrm/7H2DEaNNAUhLd+wPOaUdTXeXmBx2nKF9PCRW4Y2t X-Received: by 2002:a17:90a:cf0d:: with SMTP id h13mr61560673pju.63.1564428842536; Mon, 29 Jul 2019 12:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564428842; cv=none; d=google.com; s=arc-20160816; b=R0gTpZnjuU7cWowzpFeknZ8GGlVT+IaZaL3Xmj5Eejxo5rYwo47OdLQGWgIZlf4NqK KOt4m1c2tz36xtoWhfSV5F3J4EL6vhixxdo6zLhhkmTExwaXxzWlRe0lpN0ZsWad1r3H 07AdaNlQnoD+xfXol62/sTJpu+51NZoOHzeImme2ky9P7bVl8T5WFlBmgvcmORd1SfMf dP53c0pMlFdvfWcXMDviLxZKE3Sfhd+JO4lYAwSPXjTVZylVDvihXVyxqMOWXrhujEPF 2G4fDimPRxdp2yiulikqTznTLx9niSs6KdGNudM8NIJjqwP88Ht+gexISrUXSA6Y4OQJ YvuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Mhvyv741VvipX07CAF7FeFZO8ghxKFRTYB5QZEKoA10=; b=N5/eaRP+m0g3oIz81XCbpCoY4SNEQHyrMWVaCUhbjjuniBmikH8yTTRqmeh9m3ZFcg d2d7dhtJfO12bOih+6Kpg8xV9n5qgE8AxD0z43yPxdNz5BrQ66ZjkpXSRTyNsEn5/Vok hXFaJwldh4OiUK3U3qY/mM2WeQPKprhaq8xUjNfZHJ7zid4dqf8DGO3+uKsr7US6Nhwk Y8FO6ZgmSRIX/XN34XLobFFQTGeft3X+U/CILmq4Y0J7RnjpWF/xBd4rw4cp65HWwJ1E 8rfSyrZt+5huhHvgm7HRE4wXS0yXWaUeooSlgJTN1/5BTP/djZwro0vkmFHwS9reXse+ gN1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yKWVMgXS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4si26524627pfg.55.2019.07.29.12.33.47; Mon, 29 Jul 2019 12:34:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yKWVMgXS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729069AbfG2T3o (ORCPT + 99 others); Mon, 29 Jul 2019 15:29:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:42370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729018AbfG2T3l (ORCPT ); Mon, 29 Jul 2019 15:29:41 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6EC5D21655; Mon, 29 Jul 2019 19:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428580; bh=UAT+q+C9fLF2gVA8Wem4B9ofZ2A4vYpfQrcX8dNgek8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yKWVMgXSx+hdwgeWAqM2i0GjLj8mGiwulShF3NNlCCtlE22lowCgCv+QGi0hlrKGg Uz4S9WxqX4BNYE+3GHib/rwDlIkTA2XAK1XydncuVIlnwD6S64lkkcGnvVjeuoAV5U Uo8ApmSbXnayKGEOuc0xCXFIo/DYi3Gbi7/PzVRc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Elena Petrova , Ard Biesheuvel , Herbert Xu Subject: [PATCH 4.14 121/293] crypto: arm64/sha1-ce - correct digest for empty data in finup Date: Mon, 29 Jul 2019 21:20:12 +0200 Message-Id: <20190729190833.860212250@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Elena Petrova commit 1d4aaf16defa86d2665ae7db0259d6cb07e2091f upstream. The sha1-ce finup implementation for ARM64 produces wrong digest for empty input (len=0). Expected: da39a3ee..., result: 67452301... (initial value of SHA internal state). The error is in sha1_ce_finup: for empty data `finalize` will be 1, so the code is relying on sha1_ce_transform to make the final round. However, in sha1_base_do_update, the block function will not be called when len == 0. Fix it by setting finalize to 0 if data is empty. Fixes: 07eb54d306f4 ("crypto: arm64/sha1-ce - move SHA-1 ARMv8 implementation to base layer") Cc: stable@vger.kernel.org Signed-off-by: Elena Petrova Reviewed-by: Ard Biesheuvel Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- arch/arm64/crypto/sha1-ce-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/arm64/crypto/sha1-ce-glue.c +++ b/arch/arm64/crypto/sha1-ce-glue.c @@ -54,7 +54,7 @@ static int sha1_ce_finup(struct shash_de unsigned int len, u8 *out) { struct sha1_ce_state *sctx = shash_desc_ctx(desc); - bool finalize = !sctx->sst.count && !(len % SHA1_BLOCK_SIZE); + bool finalize = !sctx->sst.count && !(len % SHA1_BLOCK_SIZE) && len; if (!may_use_simd()) return crypto_sha1_finup(desc, data, len, out);