From patchwork Thu Feb 15 23:14:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 201838 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp181909dyb; Thu, 15 Feb 2024 15:22:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUdTaJzRjZmz1+lthtHoFCW1vKzz+AGEe51zTXyH0Zd0mhVmY+V1pEMO92mO2lAb6vWXvBQZkVUgWDq7oVSJYz//qgr7w== X-Google-Smtp-Source: AGHT+IEnl+azrrbNDu+9KKu44XH31djRnwycJUTqAb0GjX2W+UudssTEmykfLZMtcftztlRP8KaI X-Received: by 2002:a17:90a:a008:b0:297:24b8:6dd4 with SMTP id q8-20020a17090aa00800b0029724b86dd4mr3098055pjp.21.1708039323383; Thu, 15 Feb 2024 15:22:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708039323; cv=pass; d=google.com; s=arc-20160816; b=ClezrBfOXGhY2cgWwJBdIjf/O/tb62K3397CWD24e7UOM8fn5uy6zXgUq2VIfXUt+V 9VT6Y8jPl8nSvCZWjPnrjXUqCUtvrxMS7IKUY0oJKpV+b7KMW8o4GzujYQ3eEc1elgr5 rMQBuLBym9+/RrrvInyEfGElGLaRKtzbYmZbrMrODwJPGezBNBQ3Y1Hw3fmOdc/jhEmT hNe8HuwWwaxG28EUdkgG0Hh2YtQwlnFNcVkMd6kTpgsV+JJhl0q1XDPQR0EDbVy9wedK hTBDPvir2unDP347w4sGRbKBVnGZp6HNwlcBvYmMKrsBHRCFTL9IkKcjwbGSdFA/5mZN jG9Q== 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=MinIzDKfCKQy6B0slQpidM9BwLl++KcE0MImdVgZ1ZI=; fh=nKmjVxPwCa773nyq5JxrCa37ZALdOpLJMBES7dZaGuw=; b=exLDvKjkUSYLJza86XzYfpHSQnbuggBdiknjXZ6PwRcRWFEbIzAwGUQ+9nvOAqBiyj pqvQ9L3xui/lMGeAA8nYGK1qRuNE16wKYXXE6wSQxzxBND1iOtsprGUeO23zB49b0C+g 3onCxYfAZ93VMLXOBH9Rr7r2k5pmZUTcfPCy6OBJQKhWUGozA/vFRNApz+aKNzH3aw/K pPCN0m9Z/OrWdVy41130V5+zblBWdSgzlxTCITCls1U0Gn/+sdmeFcwftMnCvLvc2/6g aMUKuS0vTHbYWrFiDQenjfrU1IStjc1a+dSh4g/DjJpbRsPXXVQOLF8xvys/jZUon8ld 8qVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=GCabvGSt; 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-kernel+bounces-67810-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67810-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id ot15-20020a17090b3b4f00b0029934baabd0si52034pjb.68.2024.02.15.15.22.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 15:22:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67810-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=GCabvGSt; 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-kernel+bounces-67810-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67810-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2924FB211E3 for ; Thu, 15 Feb 2024 23:17:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B83E514A4C7; Thu, 15 Feb 2024 23:14:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="GCabvGSt" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 D1A87145340; Thu, 15 Feb 2024 23:14:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708038880; cv=none; b=kGK1r+GVAyYd4Dz/dju6K8s7Wpgb9OI1VlT/WPv4xxYhaZalYDfdhM4RpADglvlwGD4acI5V7lfcHi9eoIktgTqu5y6sn4Bo+4SXAGMjI/NFiJL56EK2hVLsuX4NG0eemeilPYVlqoYCdVSOUvUt4pIxWjy+HJPH/NRig0RRIK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708038880; c=relaxed/simple; bh=4gmnt0N+ElRQcbrv32rTMnC0LI2f7oMrwo91K3z9nhY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qL9SIb8ALREVdkfcq3GOTHqXgnBJxA0A699Q1quzsO+8Zt2CQVSTdr/ezVh9FkYy4TaHPjXSd6RRXhnNWxLQSeTeOcN8rT4IyFjk8rGJr+2l20tWYmNIPrnTIQzkaK1ps0GX/6BcRTmR5cRiRhwN7upBazKb2U42xw1lDZQ4D8c= 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=GCabvGSt; arc=none smtp.client-ip=148.163.156.1 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 (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41FMQV7h004908; Thu, 15 Feb 2024 23:14:34 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=MinIzDKfCKQy6B0slQpidM9BwLl++KcE0MImdVgZ1ZI=; b=GCabvGStxnUyUHLASCWPT6P/DZIgj/VmgpLR0keqS0hw34z561dq4Jtre994N66OGewv V2IU7n10rA9XpcfS+4Ehq/3R1JEzj1N/iTrASkkOTUrzgm9IULkEY6iMayNHXMTVPAlI wqObly0L8ByU7Yd/g3I+o+MONb/OY8KVRSkZ3N616N0UGKCdVsOC/IXh8xKiksafWK8q Br1szEzwjFPR8iAV6a54xZuAH2wBmEptjz8FbZMrmT5qvtC1OtZb6X/4k/TqKrFZrDIp AmOfCT6VZYvr8L5Nmo1AFCKqXeO71EhwDErGVO0NZs9IQaJo8g738Y1szs1PIa0wrvlI 4g== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w9u52a565-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Feb 2024 23:14:33 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 41FLuPM4004258; Thu, 15 Feb 2024 23:14:32 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3w6kv0r3pn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Feb 2024 23:14:32 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41FNETLn6357966 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Feb 2024 23:14:31 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7FBB158061; Thu, 15 Feb 2024 23:14:29 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CF3E158050; Thu, 15 Feb 2024 23:14:28 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 15 Feb 2024 23:14:28 +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, Stefan Berger Subject: [PATCH v2 11/14] crypto: Add nbits field to ecc_curve structure Date: Thu, 15 Feb 2024 18:14:10 -0500 Message-ID: <20240215231414.3857320-12-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215231414.3857320-1-stefanb@linux.ibm.com> References: <20240215231414.3857320-1-stefanb@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: CsLwuN1bCkc0LPLu-6Og_En6AG20EVR2 X-Proofpoint-GUID: CsLwuN1bCkc0LPLu-6Og_En6AG20EVR2 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-02-15_22,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 mlxlogscore=945 impostorscore=0 mlxscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402150181 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791009041799755963 X-GMAIL-MSGID: 1791009041799755963 Add the number of bits a curve has to the ecc_curve definition. This field only needs to be set for curves that don't fill up all bytes in their digits, such as NIST P521 which has only 9 bits in the most significant digit. This field will be used to determine the number of bytes a curve requires for its key coordinates for example. Signed-off-by: Stefan Berger --- crypto/ecc_curve_defs.h | 1 + include/crypto/ecc_curve.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/crypto/ecc_curve_defs.h b/crypto/ecc_curve_defs.h index 93a47a5d460a..09a221657c31 100644 --- a/crypto/ecc_curve_defs.h +++ b/crypto/ecc_curve_defs.h @@ -119,6 +119,7 @@ static u64 nist_p521_b[] = { 0xef451fd46b503f00ull, 0x3573df883d2c34f1ull, 0x051ull }; static struct ecc_curve nist_p521 = { .name = "nist_521", + .nbits = 521, .g = { .x = nist_p521_g_x, .y = nist_p521_g_y, diff --git a/include/crypto/ecc_curve.h b/include/crypto/ecc_curve.h index 70964781eb68..337a44956926 100644 --- a/include/crypto/ecc_curve.h +++ b/include/crypto/ecc_curve.h @@ -23,6 +23,8 @@ struct ecc_point { * struct ecc_curve - definition of elliptic curve * * @name: Short name of the curve. + * @nbits: Curves that do not use all bits in their ndigits must specify + * their number of bits here, otherwise can leave at 0. * @g: Generator point of the curve. * @p: Prime number, if Barrett's reduction is used for this curve * pre-calculated value 'mu' is appended to the @p after ndigits. @@ -34,6 +36,7 @@ struct ecc_point { */ struct ecc_curve { char *name; + unsigned int nbits; struct ecc_point g; u64 *p; u64 *n;