Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10402741ybi; Wed, 24 Jul 2019 22:34:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxdRlyR+CKTsfKQRUJLLms9GFrjJxBMLRohYrfUXLsGwUGZlfwF4YJvC2I0bAP2AxYw8ES X-Received: by 2002:a17:90a:d14b:: with SMTP id t11mr91025592pjw.79.1564032861355; Wed, 24 Jul 2019 22:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564032861; cv=none; d=google.com; s=arc-20160816; b=lTSXWwjXyytw9IXYfuqMBrr+MXPGkj61RKZWaKdFPpfnCt+iFWODjeFhP8ovN8LTAE g5nVzXwJllPC0ucK+Bpbh72DHfAFT30CYbq4kXCjS6Um/ree5I1naG9y50GStojrQi0Y QKOkgYw2qparE/9zv/zf7rysDjclqkCsbxOoZkj0em4eULTylg9ASJ4XcxUp8g4WaTH3 utzaLMt/yti0I0noTVcDi9i+iTNow/ZAWe/wI67pNHqCWG5TY9HXcaLhxPQ6A/ruw/HZ qflg4ayi7zXdJXbz8B1AceriBRQnxKRz6Ri9382Bn19cLQhTZtcPvdQQWMI0k6E2zGu6 XvUA== 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=ZrLBBZBJPvgpeNoEpOewkgcOx/QOV2NikSnhlGRkXV4iIFPECPR+a6+HfkYqt9Qv+T CO03eoYniKsyi6ONVrbDIfGU897HLAALMzzHhHza4GlvVicEgL6yKDhkf/Sk061pjrB7 onpyUiX7OLOV9r7WGkOkT7Ha14VWpAAZNiYmSWDa/MNACXaG6ZbZsbK33hYNE/R0MtET VXHZja3kIAzbf+J3zrVVHW7c5DQigIjQ9u3UHc9otxKtkzU79UB6/3ywXvsamhBpwElK 5Bbxz9vdFMDcyLCVMztgvE8/OdFph38KxQT5XwE2t4CJ8dnTc+ea11JZRV2PDMHWVAHT 3/sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=abWZqxYR; 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 l102si14221889pje.78.2019.07.24.22.33.31; Wed, 24 Jul 2019 22:34:21 -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=abWZqxYR; 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 S2404160AbfGXTyy (ORCPT + 99 others); Wed, 24 Jul 2019 15:54:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:38118 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388446AbfGXTyw (ORCPT ); Wed, 24 Jul 2019 15:54:52 -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 71F23205C9; Wed, 24 Jul 2019 19:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998091; bh=UAT+q+C9fLF2gVA8Wem4B9ofZ2A4vYpfQrcX8dNgek8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=abWZqxYRO6d1Fdf2FZXR1PNMQlScWebdsEEzM6KrwOyFCSSYcfU59w2g1zFUtL4wQ rEv5gCCIrEuBEBVAvrVRkyoJknEfyrvvqgZDIW+ED5bcZtIsUkTAOSojgdI89OiafL hn86l/f6Q7nS4NPebFCf27yze9iV0ZFfAhyzvl5A= 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.1 242/371] crypto: arm64/sha1-ce - correct digest for empty data in finup Date: Wed, 24 Jul 2019 21:19:54 +0200 Message-Id: <20190724191742.881734594@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@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);