Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1454838lqt; Wed, 20 Mar 2024 04:49:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWSprs+CND7BwBiJ4nD9JmDGr7MHqFY3/lVGPGF5s5EJOkkV9GM36DijtD5k3jTzZZ+6hiMFGazUlpM5an9GRrait5RHNfrS7KfwmgR3A== X-Google-Smtp-Source: AGHT+IEgDGTBqS9mZXL5ExnEf3hzPob8DYQmRZjM4mYdhHT88CdSsejvclnsvDLJvwmYyyHuiZLv X-Received: by 2002:a05:620a:11a3:b0:789:e72b:1250 with SMTP id c3-20020a05620a11a300b00789e72b1250mr17944278qkk.59.1710935391649; Wed, 20 Mar 2024 04:49:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710935391; cv=pass; d=google.com; s=arc-20160816; b=XE0yZIEjvIgkbvEtSkCThp5Z/yDyB8ojORGD9dIPeGAtxiYjtOaamuYLya9pgl6ywV YkEb3KBozfbIhhqfCsUuiBVUn95KCCRMDGTF70ZEZRk4d5vbQxKu1bUnwxSDvfpi+76V XMBZJEYeRlxYc8fP9hZTeVuUEMVPfbNpjyVdfuGvimb/H8uuRDvkhEWikndEsthgItwD tj8x/4dL9BG+MQP+nLrjzGO11IEezG+b7LwahUq+0TI0E3VJOtOeS9MH9xA4lQFH9WRV Y8ofHDDrP0DOt2jjm5vxhmM+2/+VBNO52bFIeyVZvu3S384cnZlEGV2bIsMNLWjxNSSE s5wQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QIXjQp5VnrgnGPlYmtEBbC74Qvnoo9W+f4ufafZvkqw=; fh=ttd58PQB/9Jq7mprP/nc7Swd4f1ty4MwWMUAn54aZMY=; b=YM3EsUiRh0b+UQHVcwWhQg1joUhzbFDzkSfdtVZDFL/e7RkmSPkG+VsOV6gi6NQIkl M2+o9THgp0FvwAIthemyafeEkRYItWnPhgQK26Xz/FGoACWbQ/kft0B6oh3Jhrpf9V1/ 3172QyqNO9gc5dpEAmRYPBiWZ3SG6b6cUmYCuTN0E/JjXu6lrLDoB4BksrvERsijvvIt ae9Sczg0nfnGqIXGd9JJqnY8d7RAU6EWqJcM5t9MinIBQ/MSajFdenXFtCdBdhCv3OGk pGsHem6Sk5LqxN980UhVR5QfYEbafaFOHMfDpg4WAXkp+G9R8B8XHDS88Ek8yzM79Ol9 +ong==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=MhroF5ge; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-crypto+bounces-2776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2776-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id pa34-20020a05620a832200b0078a09c39c36si4721879qkn.526.2024.03.20.04.49.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 04:49:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=MhroF5ge; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-crypto+bounces-2776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2776-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4FA631C228BA for ; Wed, 20 Mar 2024 11:49:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 290EC4AEDF; Wed, 20 Mar 2024 11:48:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="MhroF5ge" X-Original-To: linux-crypto@vger.kernel.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 A13F84315B; Wed, 20 Mar 2024 11:48:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710935287; cv=none; b=mUBSSFJZt0vU+uYOWSUsmUS51kTxRyB8bOLSBy5c7I38nmSs3pfcMAa29g0BuO2+SnHu1fJrodrx+p0jNCJzcMzFkYvpNRiRyCMDDR1b7KWnzJjQ/MZTy2B49kNYJ8fjw2yJKTVtgflHQ5R3Pa6KPSV9+qyKDoxcTiLOHVKj17o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710935287; c=relaxed/simple; bh=aTNcGKZRDkNdIFQJEmnm6v8mNSne4oF/WdznYzYFbxk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WjqDJSCSvwdJ1j1ETtodeXCNTUx4Ju59sHl8Lpv9o1adYw9pwtHTVUXtsCuVidrbmRPjqE4ADKAogt80NN71OlMLVZcsEHAOk9VoULX6tNLpWHEEXjSw37OYpsORC7I7DTejMxb8aetzICm4HKSQnaki2oEHfYSKEd3Bm1rOHds= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=MhroF5ge; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42KBj7XA022720; Wed, 20 Mar 2024 11:47:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=QIXjQp5VnrgnGPlYmtEBbC74Qvnoo9W+f4ufafZvkqw=; b=MhroF5geWTz+8FyN0qRTz1npyBAvFMi+u0uxxV9+8latZ/Pgz79DOyNEwZfH2pa3YyNk GklX9u5s6UTxeixT0suogmxBzSw2NVjHk6Bw4RRo56c2vsoptn9Pq6N0PAMMhqvBBAnY RLtfDWy2i1loSFgBKvPbCxg7aReoCpfoBGnfDEG5t3cQkhEVfbrb4EfmkbP2SKaaOm8E 5JSaVtq7Te3++dPK0ti9Z63N7cGLXpR8gyuhQ2cuJK+qH16YtPy0iPMw4rQl/8ZZwwoP T7MF7hhtcqiMkTDrxscbzw+iCqxR5bisO7LYOeAvo5eLSqOeEbrIJZWGab64SiZHaaWv kg== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wyxxr014p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Mar 2024 11:47:50 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42KA96lw002778; Wed, 20 Mar 2024 11:47:49 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wwrf2nk30-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Mar 2024 11:47:49 +0000 Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42KBllUX56230184 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Mar 2024 11:47:49 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E1F0E58065; Wed, 20 Mar 2024 11:47:45 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5124958057; Wed, 20 Mar 2024 11:47:45 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 20 Mar 2024 11:47:45 +0000 (GMT) From: Stefan Berger To: keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net Cc: linux-kernel@vger.kernel.org, saulo.alessandre@tse.jus.br, lukas@wunner.de, bbhushan2@marvell.com, jarkko@kernel.org, Stefan Berger Subject: [PATCH v7 01/13] crypto: ecc - Use ECC_CURVE_NIST_P192/256/384_DIGITS where possible Date: Wed, 20 Mar 2024 07:47:13 -0400 Message-ID: <20240320114725.1644921-2-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240320114725.1644921-1-stefanb@linux.ibm.com> References: <20240320114725.1644921-1-stefanb@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: aR-lb3CmwDzAabCcEZDTwaKqbU8cEyAN X-Proofpoint-ORIG-GUID: aR-lb3CmwDzAabCcEZDTwaKqbU8cEyAN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-20_08,2024-03-18_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 spamscore=0 bulkscore=0 clxscore=1015 mlxscore=0 suspectscore=0 priorityscore=1501 adultscore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403140000 definitions=main-2403200093 Replace hard-coded numbers with ECC_CURVE_NIST_P192/256/384_DIGITS where possible. Signed-off-by: Stefan Berger Tested-by: Lukas Wunner Reviewed-by: Jarkko Sakkinen --- crypto/ecc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crypto/ecc.c b/crypto/ecc.c index f53fb4d6af99..415a2f4e7291 100644 --- a/crypto/ecc.c +++ b/crypto/ecc.c @@ -689,7 +689,7 @@ static void vli_mmod_barrett(u64 *result, u64 *product, const u64 *mod, static void vli_mmod_fast_192(u64 *result, const u64 *product, const u64 *curve_prime, u64 *tmp) { - const unsigned int ndigits = 3; + const unsigned int ndigits = ECC_CURVE_NIST_P192_DIGITS; int carry; vli_set(result, product, ndigits); @@ -717,7 +717,7 @@ static void vli_mmod_fast_256(u64 *result, const u64 *product, const u64 *curve_prime, u64 *tmp) { int carry; - const unsigned int ndigits = 4; + const unsigned int ndigits = ECC_CURVE_NIST_P256_DIGITS; /* t */ vli_set(result, product, ndigits); @@ -800,7 +800,7 @@ static void vli_mmod_fast_384(u64 *result, const u64 *product, const u64 *curve_prime, u64 *tmp) { int carry; - const unsigned int ndigits = 6; + const unsigned int ndigits = ECC_CURVE_NIST_P384_DIGITS; /* t */ vli_set(result, product, ndigits); @@ -932,13 +932,13 @@ static bool vli_mmod_fast(u64 *result, u64 *product, } switch (ndigits) { - case 3: + case ECC_CURVE_NIST_P192_DIGITS: vli_mmod_fast_192(result, product, curve_prime, tmp); break; - case 4: + case ECC_CURVE_NIST_P256_DIGITS: vli_mmod_fast_256(result, product, curve_prime, tmp); break; - case 6: + case ECC_CURVE_NIST_P384_DIGITS: vli_mmod_fast_384(result, product, curve_prime, tmp); break; default: -- 2.43.0