Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10425531ybi; Wed, 24 Jul 2019 23:00:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKM1tB/fjQ3znQY+qj7MdexbM/58vS/I7N4vYJUsKfSLAGfQ+CzX0mUU3eZ2fPKzHdBfrQ X-Received: by 2002:aa7:8804:: with SMTP id c4mr14830655pfo.65.1564034436152; Wed, 24 Jul 2019 23:00:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034436; cv=none; d=google.com; s=arc-20160816; b=tiDOvnyhBRy0Lb5ni+UqDM03rv8BeE/HEI/cWeOdjTWmiJMyNYK7/oeq0Hfts4VyD5 ZIfvLBnMRv6d/eUOSMuvnGsjwvICWoU/PxcMUB96FLVe6NmZlvoPmbwEJDur2G7DiZ4e dkJauoOJH74UAXYXhFd+73SUXkJ6JsutkAPP5nLAvGDrDn6NWjB8y6IZWtnJTLWINaZR TGtEDwTS8lAmyiHHQGNM65X2XSfudmv6eiWOJPdTZaS/bmz+1hqmL5SejNGLKl053Pg9 gBj5n9oAPCpJm6mzNlD6hzqXFHcuMmwZS55mTv6y7+ANsyMJs7TRedChLCxgHs+9jC/1 FiEA== 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=ywsssSLHxr8a+v256ivEIxxktuuA2/DUj1uYiPrqsE5XZgRWQLxw6EbXU5+/e2pZt/ 6wAEW7yyjKGKtrBpABKJpZ3agee1mhrgUA70rg7YYZHPQY+K+cz4E4AYGPVYfAcql9g3 gqjQFQGXDXW34t0kQRT5jFtzkWk/Pw/1zGnkWjWOfdkX41YCAl4p6lY17dTD3+dmynSj 4HSyzUSxDfFWddWivBoj+Y57SVY8Nmf9Na1UBzSD5tgDWiB9FKWt/tiEGvwVvIiF1vur MPTba/CdHgqfG68IdFLtPMXDzsR/SKdYHDJGK/m+lG/+KkNKVYTDyYHVIgsjGk3qgxys q6FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ysH16oFQ; 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 p5si20549483pfp.64.2019.07.24.23.00.21; Wed, 24 Jul 2019 23:00:36 -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=ysH16oFQ; 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 S2391239AbfGYFoV (ORCPT + 99 others); Thu, 25 Jul 2019 01:44:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:59348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391211AbfGYFoQ (ORCPT ); Thu, 25 Jul 2019 01:44:16 -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 4F45422C7C; Thu, 25 Jul 2019 05:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033455; bh=UAT+q+C9fLF2gVA8Wem4B9ofZ2A4vYpfQrcX8dNgek8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ysH16oFQbV+tSK00d66Fp1ilm2bIgStQo3cxghWmdhuC9PViq9QjGhWS8PBccni8W rSpYDYjesmQKJPM6lqeUWAX5wYcy3Yyf6psYqA+sKOUgMx6QnLc5vXT+Kr1JiG1Ha4 +bktepOEbRD9Bue/sqB1hEBq3SBugtjSD9y+KiCY= 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.19 174/271] crypto: arm64/sha1-ce - correct digest for empty data in finup Date: Wed, 24 Jul 2019 21:20:43 +0200 Message-Id: <20190724191710.091478547@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@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);