Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10185409ybi; Wed, 24 Jul 2019 17:54:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQER8UWcOlBMA9fCQzrbA3NJAlVGHSz+oZUEvy1UwVzhbyrLG97+d39D8sLNJ5ijttaePG X-Received: by 2002:a63:550e:: with SMTP id j14mr354594pgb.302.1564016094185; Wed, 24 Jul 2019 17:54:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564016094; cv=none; d=google.com; s=arc-20160816; b=PAeaIiPsfWVt3WVO5StEROad2eXZ9ijeoeEa+/a2B/62TzH3JjUZSxlM6kB5zbq4Qe 4h3kX59pXc+w42UjvsCt2fIx0ksiQecE6amISI6OCV+CoZMbt/OLWD/bTFtSt/vU32a3 wblpLX7foJWftnkhRf2Z9DkKSY+iBrrGKF4STfH0tWgt0BG0ATjmyMSeP43ac26vDr7a nG6rVTwUputyrZPoRYsnU/hzrIl9jfT504TyyWkN5OdiLjUr/E5zh+cqhJtn4VR4X5pI n5hZrhOFWA1QYwa1M4mlX50W/9RO3BE9EXzQ9Ab2kS/wq30sP0XAb0nGv9YvEaK+v683 y5LA== 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=hOv2FmQghAcIgfMa2z7QHXIGz1rUEMtPL41f5Hd5GLw=; b=PzXvamR5kcRSZEydOHFeE0hc9jFMYQWAgtUyU8L9IROnbpOeVUxZ2VY42FgcC4AwT/ u9casic4dBJaOR4kGpOfnaEzOffOpkdOhOHJb1hiuy4f9zoUWR0YdHO8N2CjaxPlil5n 9I63EQQ5y0joPIUNI+lzfG4JNAnjEelnsj0qtduJo6j3XHbU5tgfXuLkFRXYsH+ro0r3 ttftmwRvnh2e4tnDFSbn6KS2XJhFCh8OM0lVahKm+VtQTQpiPzhyrM1TdRrpeE+bPFEW FFYgzVy5tmeEPe9hDiOUsIpOdpztyV/PXN1KPvoPUZL0hHTlcNH5/3uY0wxMfHsq11yP G8tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Au4+PvuN; 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 d38si14480014pla.287.2019.07.24.17.54.37; Wed, 24 Jul 2019 17:54:54 -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=Au4+PvuN; 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 S2389236AbfGXTfi (ORCPT + 99 others); Wed, 24 Jul 2019 15:35:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:60788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389214AbfGXTfc (ORCPT ); Wed, 24 Jul 2019 15:35:32 -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 D2A6521951; Wed, 24 Jul 2019 19:35:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996931; bh=xCREz+NpzjDnCt8otChgXXHGTnuByINlKgm7R4l8T1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Au4+PvuNDrvsv237GAeY/3vOptIk64P7OfJXf3KdixFNOsPBUSPlgbZ/o68j7AOkp llx4k7yIMYqwmyUxtKbUJ9vrUKq8b2qFScXvzpoTi7FBP5hWl4c2hjgLQPni6ua0Gv aXXoKOD9qhV+C9xGZxk7miSvXd1iETEeeptq8ffg= 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 5.2 266/413] crypto: arm64/sha1-ce - correct digest for empty data in finup Date: Wed, 24 Jul 2019 21:19:17 +0200 Message-Id: <20190724191755.221716601@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 @@ -52,7 +52,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 (!crypto_simd_usable()) return crypto_sha1_finup(desc, data, len, out);