Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10425566ybi; Wed, 24 Jul 2019 23:00:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSsNF1Gtwge3O61j8/799ovt0Z4s+OdwqJM9z32+yXt8j/RRHDreIexuPBFu03KeQaU8ek X-Received: by 2002:a63:2a08:: with SMTP id q8mr52680802pgq.415.1564034438227; Wed, 24 Jul 2019 23:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034438; cv=none; d=google.com; s=arc-20160816; b=Z7V0zMntvqlHhL5iZoiPqXwBY7AtV6xyftDU+sjQLfHclpwnVMJwyk5qTO2xy1Ocwn mlTMpHcssT+RGDjegMwOil1ACDxXkjgM+SEQcr8KqAQ8VwLWJm2wkf0XzyB8T4PYPkgU Cl5N46aCfa1iKa/o12b+ApPXoni6Y+yleAuyHjQgZ4NtPEIhn7medoCFJumCt8QpJFJq 9sxvhzPPJdFoTq+yt1Wam6YEzEA3gQ1Qubh9UcaK1Ask7+bRHfuAJ89N9n2E4HYx5I+T g+41MJtXmk3XxvSsJfhIDnNO3xwhYC97Aej9A4o3NINy5RqFsBkHivpnZ3zPJYSNP52m U5VQ== 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=pdJ5KUgTa5sNCSmu8jFIuB9TxXbNcfLVY3kX970jhTs=; b=0d4f8rc5sVLVikJP5LqQplwuea7sUhwSIeDFh4IsYkQIWtxHeaUE/r/S59sgQwHGVn tner4IjXwe2kNdsCmfbxzi8+7ud19ZbRKEKUc8CHPJbCVtkX+69ozNT/QH97AbAniQwa siaGKGoxK1iJbw/HeCDs3KHhWySjXy7NLlQaaDxqDdvDQyjGDRWPPN5mOV5sEI8xiGXq UvaUxxBZhuKN3AVk4FWhft1ukds463eEZYTKWtMrkki7TZ1iefSEzfmoDPydut+3UWyD GOTYklIfKhDC6PrbeqNZC97Yfq2eAzAuBw24ro/QJT60z33X9ypE2rMbfYxPDdl0Kow0 tHng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="P8/OwJQG"; 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 b32si3843097pla.277.2019.07.24.23.00.23; Wed, 24 Jul 2019 23:00:38 -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="P8/OwJQG"; 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 S2391256AbfGYFoZ (ORCPT + 99 others); Thu, 25 Jul 2019 01:44:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:59408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391230AbfGYFoT (ORCPT ); Thu, 25 Jul 2019 01:44:19 -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 085A122BF5; Thu, 25 Jul 2019 05:44:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033458; bh=YeaONwwOYtzz3Ca9+yCTMwQL28bim9Ud+LLFomi6VwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P8/OwJQGkYmo+EL+OtoO7i+6O9Eq985kWgCsg5tOf9yYof6so7lFdtrZUFJA798fO j24Wk1M8Q0E30b7fMxzsyz38z9uTEG+L2+qLrUKOlaEgbrHmHBeOTxGhk2R0COb/RO lrjSKATaMgfPqH3+7AhzeCh6V7XmIdbOB8vJq0pE= 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 175/271] crypto: arm64/sha2-ce - correct digest for empty data in finup Date: Wed, 24 Jul 2019 21:20:44 +0200 Message-Id: <20190724191710.171073562@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 6bd934de1e393466b319d29c4427598fda096c57 upstream. The sha256-ce finup implementation for ARM64 produces wrong digest for empty input (len=0). Expected: the actual digest, result: initial value of SHA internal state. The error is in sha256_ce_finup: for empty data `finalize` will be 1, so the code is relying on sha2_ce_transform to make the final round. However, in sha256_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: 03802f6a80b3a ("crypto: arm64/sha2-ce - move SHA-224/256 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/sha2-ce-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/arm64/crypto/sha2-ce-glue.c +++ b/arch/arm64/crypto/sha2-ce-glue.c @@ -59,7 +59,7 @@ static int sha256_ce_finup(struct shash_ unsigned int len, u8 *out) { struct sha256_ce_state *sctx = shash_desc_ctx(desc); - bool finalize = !sctx->sst.count && !(len % SHA256_BLOCK_SIZE); + bool finalize = !sctx->sst.count && !(len % SHA256_BLOCK_SIZE) && len; if (!may_use_simd()) { if (len)