Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3288835pxu; Mon, 19 Oct 2020 08:32:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAi22N3R0LtIsi0pXF+kjbZf7MEttXSPi7chVEUk9LtMIgYnPCG3mJpvq3Y037x/AKA56x X-Received: by 2002:a17:906:3e4b:: with SMTP id t11mr434470eji.420.1603121537888; Mon, 19 Oct 2020 08:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603121537; cv=none; d=google.com; s=arc-20160816; b=Zx6G9AoXD3bk4kqoF6q/kdlmYKwxGh9+xjMZ89DYD2SR8bMznLNN6DoCtRSba7e5pw IU0NIi+fwf3xh4IU07Cbu+96YgYGBG8Jtx37xCWYlXejh4js7orvMbOf9807w7o5XJLD ruwp8NnmwFmnd0imbw9ZjEXf24mJWFz0i66+QyY9P6AuY5x7tet6YdEzOlJQoUuI/lM1 lDd23pdxtirlzpQ0x+sikEW7MLpO2VFweTDfv/vZxI/2DnZYy1jOoi9bJDyAekAYREEp 9dvPiC0meicdeZk4NCV6ZVb17XyvTR9SaBRDYfKhVrZLQ/Ti7jE/l/LZcE699kgu7/9b km+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9+fYvZA6OGxCjC49pxceAMWASEc8BRotkYG4ADhk4ho=; b=xgATsy/bgVIVJ5it44Lg2kIOGtguyWvIaitMZ/XJIk6Ubx13RtFuy7SzLBVSPEuehe EL6bhzjWMof4R+/K4Lbfh5gCNE24fUicQEV2+/Kv0/zbWujMpM/ewRMm6pWc55AWwalH /Qt3bo/qq1sWxEuy9qB30FH9MDKS4r3lTIFvE2df48WkJapb2hCDBjuHMTw0XQj/Bcd+ qvJtsObQnuK/tcqm+cP4Q5aRpByUGleBj14WMNSY/B1/5SDnFWvI5EWQ5Jw53X2Cfc69 H3eGBxwmZYdXe5R5vClPY5ISISur17Abj8q/RXIRy5lHauxvbdW8EV9Z4Pg6D8jUR8s7 y89g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si281373eju.63.2020.10.19.08.31.54; Mon, 19 Oct 2020 08:32:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729845AbgJSPag (ORCPT + 99 others); Mon, 19 Oct 2020 11:30:36 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:38765 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730131AbgJSPaV (ORCPT ); Mon, 19 Oct 2020 11:30:21 -0400 Received: by mail-io1-f67.google.com with SMTP id y20so73345iod.5; Mon, 19 Oct 2020 08:30:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9+fYvZA6OGxCjC49pxceAMWASEc8BRotkYG4ADhk4ho=; b=l+lESt79cpyZlrJfXkkh2R9ewcV+FlL9Azk95xc9VlxJkwB2ZFSXOcbVrJddCCnXHQ BvMwdlorKquMRX5nrvxhTUtOd7IRwaNU3hhqUDxGWbJ/BTI3cRQUD06kg1+IYQcnS8e9 RO9TXTWTFqMig3/KWN0BGJkti/5en9MUPsIkQ3BvBymybRiNtX0c/7ddJm3CyRXGLvNm W5XJ7sW1hctBSIzs76stTPzxiF61m2JYCG+PwusyRcBRz0aKqPNcUo3rNB1TuMRGQF2/ 3QyVlXxZhLYf77pj780AbYWmMnGbV2s0O5wU8rtWm2cLqMC/+Y2/ylDyTu5y6mopJqxA X7uQ== X-Gm-Message-State: AOAM531fcfO1+B6k+olOvOepqwDvHO3Tt7lZWHgdx2RC0Ih9mBvQrV01 3arH43jheZ2TY9ivdDv5dOT5DBfUOIsQjg== X-Received: by 2002:a02:b80f:: with SMTP id o15mr366335jam.103.1603121420664; Mon, 19 Oct 2020 08:30:20 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id m86sm20898ilb.44.2020.10.19.08.30.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 08:30:20 -0700 (PDT) From: Arvind Sankar To: Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/5] crypto: lib/sha256 - Don't clear temporary variables Date: Mon, 19 Oct 2020 11:30:13 -0400 Message-Id: <20201019153016.2698303-3-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201019153016.2698303-1-nivedita@alum.mit.edu> References: <20201019153016.2698303-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The assignments to clear a through h and t1/t2 are optimized out by the compiler because they are unused after the assignments. These variables shouldn't be very sensitive: t1/t2 can be calculated from a through h, so they don't reveal any additional information. Knowing a through h is equivalent to knowing one 64-byte block's SHA256 hash (with non-standard initial value) which, assuming SHA256 is secure, doesn't reveal any information about the input. Signed-off-by: Arvind Sankar --- lib/crypto/sha256.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/crypto/sha256.c b/lib/crypto/sha256.c index d43bc39ab05e..099cd11f83c1 100644 --- a/lib/crypto/sha256.c +++ b/lib/crypto/sha256.c @@ -202,7 +202,6 @@ static void sha256_transform(u32 *state, const u8 *input) state[4] += e; state[5] += f; state[6] += g; state[7] += h; /* clear any sensitive info... */ - a = b = c = d = e = f = g = h = t1 = t2 = 0; memzero_explicit(W, 64 * sizeof(u32)); } -- 2.26.2