Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4976308ybi; Tue, 28 May 2019 05:43:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzJRhz0yxoKIpYWR7nyFZWqK2LPgAJg89C8wcvNxy5egIOI2nfjqyG4M4eApWAMyvi6qgY X-Received: by 2002:a63:130d:: with SMTP id i13mr131126287pgl.396.1559047419947; Tue, 28 May 2019 05:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559047419; cv=none; d=google.com; s=arc-20160816; b=RjGNyRwfOR/7PCFEKAfEfyxyqc3B7tWg5dN1i1zGo31ilceyV4HtNa6rSLBZZ4kbFc pDR2E0KwlvVZupoNBNv8Uy1EdzCdFw2atLG1mW7B0js2L3ZqwZKOA1MynS0/OxduE89P r98zX3AuzYKPDy+/DAWyj3ikBElpWEVc7dRpBYsLnQvPyaDqrRDrbEarTwG2Si73YBeB xVQEf6wE8jwOPOjwf74PRx7xYA/YIdWKTdJyj+blE6SYmpNTtMs7YuFFezpZt+U0u71j SGQOBr0sMmsiEtvJsLkKDPlfx8f5rbLMv+nOe/pgcwxtcGkkoBWOHX8fw1p6kdhHqazb nJiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=ucsJU2RQj5Jr+B5f+dPr47NtIreJR1DFJaQ5vCUwD8U=; b=C+g6t/ayHXSNh51FMfUGDBsamAjNS/6FrCuCq6ibjh1/5slpy0lUjeM8uH6Rz2Oidk KjvB+amf2KvhkSSUUxMeN6pieVWV+XPP3Vm/6QDspa1r5D7ELCCmoY63iYiB9tdUsPn2 A7sHrgBv4b8B+ohs58MTDKHShGsXYEPWtZW+p54ivSGUFmuJqmpYo7hXxY3JKIB6vvxi gC51ifuybbjvWPcmaT4GO/N+Ok60Ih1EU/0n5/8k5EBMY1yfLR54auFzvd2AWV8SRMCy BQcpu89//0ECTeG8qsHtJOoNLHf5FKF1tRZmz5wbg77qJzJMOARdFEB0+ph9jlGg7cIn L/wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UKtCdcbp; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s16si20969189plr.292.2019.05.28.05.43.20; Tue, 28 May 2019 05:43:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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=@google.com header.s=20161025 header.b=UKtCdcbp; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727400AbfE1Mmo (ORCPT + 99 others); Tue, 28 May 2019 08:42:44 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:46421 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727390AbfE1Mmo (ORCPT ); Tue, 28 May 2019 08:42:44 -0400 Received: by mail-qk1-f202.google.com with SMTP id 18so17593047qkl.13 for ; Tue, 28 May 2019 05:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=ucsJU2RQj5Jr+B5f+dPr47NtIreJR1DFJaQ5vCUwD8U=; b=UKtCdcbpzS06owZhQOx3kelGMFAA43Dv8TGAW1GJJBg2Qw2pibkdYVtufrqXn0GzV/ jD8tBphl8MIuhIr91GDdtnY6OQ/H9p0Ojt2FrTUPCsARHBa1+ouRuSz2CXxTjazydbI7 kZbZ5TAvfKX/6/YKjNV8v33g/3DnHzrqVjuRmNBSF8Jcj+h4qLxwyyHdkNg14KpFUMC2 SnbkTixSImnlboEzEfJtw6/rWFvvXVUL3D/CSMMigfmZ3n6vjESMc4Lxi4ea5T2Eyfgp n59g38UdoLV5CknSgXHwL8Ccpn/C4yNj/BVWWuuxM0u313sXalM7es0c9VGoyL4c3Int xPfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=ucsJU2RQj5Jr+B5f+dPr47NtIreJR1DFJaQ5vCUwD8U=; b=h9I5PsIc5hTEvizMAu0qFVbPRHhWKTb90TWzt1hzwmt/YQRoKJBNm0rcCHIvPiU4jh NsgVIDSJrMdVK7ufkJmn00Q7HxUSro6+uyiZPslSz2XejL7sNYV2TuPUwCdb84fWPHdE rA+ILWV8AyR+2g9U8zYpa7wrOSJ9zZheUGmswOEatNeW6urqe22ajCulp67VTVJDtYSp g2c/B3oCrszPjo5eqOqZrD3GftkkJ573H87lDi9Ic263AgSt33B98X+ZtF9S8NQfDgbf jYIY09Pw1EB8lRfTrzv8N2Zomnndv4hIk0U1j9p+Nj6e6M1hcDSDv1k5yBzc8JbFrCC4 ni1Q== X-Gm-Message-State: APjAAAXV7fwkn+jF7k5GDIaeNpm5OBYDUZkTRdbQAI8v/3DbVTbjl5ZR QSBV8/27n9saJzX+UbeRUPlA06FBnDOk15eD5m2o3IWDm5wYQ2JkDVBNI24Fv6LSYgqHm1w6ou7 xdmX2LvEiNI55W2Y200tdLLikT3kYnzCGjNFzwq+ZjCUp1PBmJJOdoLk0liDHtxMzdLKfbNH5 X-Received: by 2002:a37:9481:: with SMTP id w123mr90890881qkd.319.1559047363388; Tue, 28 May 2019 05:42:43 -0700 (PDT) Date: Tue, 28 May 2019 13:41:52 +0100 Message-Id: <20190528124152.191773-1-lenaptr@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.22.0.rc1.257.g3120a18244-goog Subject: [PATCH] arm64 sha1-ce finup: correct digest for empty data From: Elena Petrova To: linux-crypto@vger.kernel.org Cc: Elena Petrova , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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 --- arch/arm64/crypto/sha1-ce-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/crypto/sha1-ce-glue.c b/arch/arm64/crypto/sha1-ce-glue.c index eaa7a8258f1c..0652f5f07ed1 100644 --- a/arch/arm64/crypto/sha1-ce-glue.c +++ b/arch/arm64/crypto/sha1-ce-glue.c @@ -55,7 +55,7 @@ static int sha1_ce_finup(struct shash_desc *desc, const u8 *data, 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); -- 2.22.0.rc1.257.g3120a18244-goog