From patchwork Sun Feb 2 19:00:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Wunner X-Patchwork-Id: 861459 Received: from mailout2.hostsharing.net (mailout2.hostsharing.net [83.223.78.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 023A01FDA99; Sun, 2 Feb 2025 19:09:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.223.78.233 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738523383; cv=none; b=tdysff0UNBMwkj2r/FzCCJ4N+RX5W2DuwEnMMr8VCC1hDJi2P4X7H8LQCHaQhkztlmg3PI9HDfzHhWHeqBR+ia29k7DrKpb3uAu+1dTu/tBwBx5hI9wUmb8X8W3Z3hKY/Y6UGYzCWv6YGQJ1zSBHu6pUcCj74bWPYzMss8Cqk+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738523383; c=relaxed/simple; bh=BtAS3rJIBAFX83/EjKyLeFj5BF8z6WvGzA8pzCPQKf4=; h=Message-ID:From:Date:Subject:To:Cc; b=E2v2lNvAOku72nYYGtDETjKS8rR2azqlCTeHyyDyUTPmFwEL6zsjsgyaf40lKKNfKbauOkwL18Lhyl/RGc75FMiE0hMhwHDg2UNGXYFKFXAFpYlhO8QiyDt7xx650gpWxbVwyj1XdsBozEmMjnCw58D/+L9PIXX37n2P5EQ7FJA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de; spf=pass smtp.mailfrom=wunner.de; arc=none smtp.client-ip=83.223.78.233 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wunner.de Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS RSA CA G1" (verified OK)) by mailout2.hostsharing.net (Postfix) with ESMTPS id 5996210189C03; Sun, 2 Feb 2025 20:02:23 +0100 (CET) Received: from localhost (unknown [89.246.108.87]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id 2331F61024FA; Sun, 2 Feb 2025 20:02:23 +0100 (CET) X-Mailbox-Line: From c9d465b449b6ba2e4a59b3480119076ba1138ded Mon Sep 17 00:00:00 2001 Message-ID: From: Lukas Wunner Date: Sun, 2 Feb 2025 20:00:50 +0100 Subject: [PATCH v2 0/4] ecdsa KEYCTL_PKEY_QUERY fixes To: Herbert Xu , "David S. Miller" , Stefan Berger , Vitaly Chikunov Cc: David Howells , Ignat Korchagin , linux-crypto@vger.kernel.org, keyrings@vger.kernel.org Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: For ecdsa, KEYCTL_PKEY_QUERY reports nonsensical values for enc/dec size and (for P521 keys) also the key size. Second attempt at fixing them. Changes v1 -> v2: * New patch [2/4] to introduce DIV_ROUND_UP_POW2(), which avoids integer overflows that may occur with DIV_ROUND_UP() (Herbert) * Amend patch [4/4] to use DIV_ROUND_UP_POW2() (Herbert) * Amend patch [4/4] to use BITS_PER_BYTE for clarity Link to v1: https://lore.kernel.org/r/cover.1735236227.git.lukas@wunner.de Lukas Wunner (4): crypto: sig - Prepare for algorithms with variable signature size crypto: ecdsa - Harden against integer overflows in DIV_ROUND_UP() crypto: ecdsa - Fix enc/dec size reported by KEYCTL_PKEY_QUERY crypto: ecdsa - Fix NIST P521 key size reported by KEYCTL_PKEY_QUERY crypto/asymmetric_keys/public_key.c | 22 +++++++++++----------- crypto/ecc.c | 2 +- crypto/ecdsa-p1363.c | 8 +++++--- crypto/ecdsa-x962.c | 7 ++++--- crypto/ecdsa.c | 2 +- crypto/ecrdsa.c | 2 +- crypto/rsassa-pkcs1.c | 4 ++-- crypto/sig.c | 9 +++++++-- crypto/testmgr.c | 7 ++++--- include/crypto/sig.h | 7 ++++--- include/linux/math.h | 12 ++++++++++++ 11 files changed, 52 insertions(+), 30 deletions(-)