From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CD1330F938 for ; Sat, 11 Jul 2026 11:23:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783769023; cv=none; b=acWtPuzp00syVqdgNF0dT1DcYhC0LFnqSo8BNQobfH3dzfgmPvaq+zUyRM6KYX8Jsh5iTlQPT7ixct38UN2Gbb/78i0INWgAJmJMFTOQegcqL5zqbCxuunQ7Um9t5ch86m0JHs+rVytwAlLz2MHZnX86tz7WVsPmix3Gzg+gCBU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783769023; c=relaxed/simple; bh=OEYqxVTCTI9USysQOmqLS37+FcyNxiCmGACoc0w05Xk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ErriNflXSXTfkpZAegZtmmRCozIx73rvvj4dJYWBRF3r957dYvfw/bTQbhmcyhO56gm1/QDZdT+Ep0i14e1WczQ2veA97LVzWfSQNIholV2D2IQ61P5SY0x1jWTOgmNJyRGyyIbL2+S2YKRVkhleWfKnTw+13ISZsMSi9bh9ff0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com; spf=pass smtp.mailfrom=googlemail.com; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b=GfItbQ2X; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=googlemail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="GfItbQ2X" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-c15ea93028dso187308566b.3 for ; Sat, 11 Jul 2026 04:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20251104; t=1783769019; x=1784373819; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=234jl/SdWrM5VnGn/5as0DaA7W5mFTvl5zh/6Ezco9A=; b=GfItbQ2X7J0gFAiMF8+EgkPDwLa2Oo95gBipecodccqhlxE2TCrWKudrY4hSg0VPNT dW7y/DiKYpCIk+RDvcYdFUYDf9JvQ+BnYnRsmcWhGZiV9Z1oZJSqYh9n/tSSB2lhtwPL b5VSj12KvtE68anfzQg+68uRZXHugeLxYNBqtdS4Pl7VACCpw9/iZ/kUCfHXrpcYv6uf Yi8vNgyEkbi7pXsbbuJkNjYnh3IxFqel1LYoMvMEDgPAPCLDEKArCh7h4D6cXGrPaJ5y +ALN6j0V2mzpZyFYp1C9xtw9ds2jwVkLANwxw/kvslOL+5HHjLC+/eEUCqadoU+Gct0f bKzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783769020; x=1784373820; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=234jl/SdWrM5VnGn/5as0DaA7W5mFTvl5zh/6Ezco9A=; b=Ue3WLvyIpem5bydOxj68jk4Nw9sdiDekPr5LzaEvv1r1XxtrAxqKWWylEqPHg15m5m JRAYIHYBY4ZpCJIogBB5hpxjE09fHktTRRpmbHkDMWwfrp0XOeA8hfDxJyXFd+pdAIym RVICYzrp9BqEuHjXwvgZgrmip3CJeNCJJ7IbicHF29h2H4w/vpCIZr1wn7X2oAN7QbJZ Yci4UMMj6pNAFZC+RFCD03oYo6zEdI89cmF7jdPs1/EEMf74iMukivv9EOs3K64xg49v I05XnR9WyG0jX7PCL2D18c42tspZlAJLoCW9KZBkzpRQ4tOVZdpo9xhqcPPcAzz+PC57 hhSA== X-Forwarded-Encrypted: i=1; AHgh+Rqfw9JyHQkHX4LbE6p9RrEMC3Wvb9EXtedS3VMn1omHUzH2FS80An3pmsK75byyMHYj8UqYr5FSgq2F2WA=@vger.kernel.org X-Gm-Message-State: AOJu0Yw0a5maq60S0k9YgEtrc6R1ZDUA4TPIYh38yaN7YsrvNv5QwS32 GaHNviYSrJCtE47J/npEvn5BAC8Nw7DnKVOk8d58xVon9Ali+hpVGGex X-Gm-Gg: AfdE7cluidV+guQhZvFm50zizE5UJgO2oRhrGM5DXykXyaYfidgNX+P5V/em4Y4th+y g86gbxa4yD/2ZJWBfCjK8lQZVvI++qCzVeCZXWr3QIjqPcDLFg/wP4EutdYjqqVnQrbzxGZUxYt sPww3waY3KKWDUfPSHH+RMB3Ae9GBzJoSUbVYVs7jxS6bCfF9YBw7GZChvlEc38ZmP6QptaiCC4 4LME8XGmn/KM86D/yej1oJ+iSSH1mbqxGXs7Juo9KPorCPuh+vKxUTJQbRX1uNdNkhIL8Xxc/lt IswKLqBDHxRn8LjhnfM5TKpNzqJR1MBIf26A7Z5c/KYRsrL6FUMFU1HfBM40UGQh4/0cDzh/bj8 L6APhc5T/A8zfdRhxBtUyT7c3C2mrmDcCGvXwfPCKcLbNAM9bYxtgrqqj+QZOmx1F7XX7qmtG/C zm1CGRvbV66DgFxBLzy2/u87lN/bMpVbybpxDP9dwb X-Received: by 2002:a17:907:25ce:b0:c15:ce72:9350 with SMTP id a640c23a62f3a-c161ed88b0emr98383966b.41.1783769019411; Sat, 11 Jul 2026 04:23:39 -0700 (PDT) Received: from fudgebox (k10193.upc-k.chello.nl. [62.108.10.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c15ad694736sm728524666b.0.2026.07.11.04.23.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2026 04:23:38 -0700 (PDT) Date: Sat, 11 Jul 2026 13:23:36 +0200 From: David Gall To: Ignat Korchagin Cc: Greg KH , Eric Biggers , Lukas Wunner , Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] crypto: rsassa-pkcs1: use constant-time comparison for digest and signature verification Message-ID: References: <20260710213718.GD1911@quark> <2026071156-masculine-unsold-3567@gregkh> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Sat, Jul 11, 2026 at 09:00:23AM +0100, Ignat Korchagin wrote: > On Sat, Jul 11, 2026 at 6:19 AM Greg KH wrote: > > > > On Fri, Jul 10, 2026 at 05:37:18PM -0400, Eric Biggers wrote: > > > On Fri, Jul 10, 2026 at 07:29:33PM +0200, David C.C.M. Gall wrote: > > > > Replace memcmp() with crypto_memneq() for cryptographic digest and > > > > signature comparisons to prevent timing side-channel attacks. > > > > > > > > crypto/rsassa-pkcs1.c: RSA signature digest verification used memcmp > > > > which can leak valid prefix length via timing analysis, user data > > > > could reach the leaky comparison via the digest argument to verify. > > > > > > > > Assisted-by: gregkh_clanker_t1000 > > > > Signed-off-by: David C.C.M. Gall > > > > > > While we should use crypto_memneq() on MACs, auth tags, and other secret > > > data, I don't think we should let it creep into domains where it is > > > clearly not needed, like public key signature verification. > > > > But isn't this user-controlled data and so a user could use it to figure > > out the key? > > This is signature verification with a public key. So the user knows > the key already. > > > thanks, > > > > greg k-h > > > > Ignat Nevermind, my reasoning on how this method is used was faulty. The crypto_memneq call does not protect against digest forgery, the public key is already available to anyone attempting verification, so an attacker can compute the padding/digest offline without needing the kernel's comparison at all, timing or otherwise. That said, this function already uses crypto_memneq for the hash-prefix check a few lines above. I'd argue for consistency it's worth using it for the digest comparison too. David