Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp616610lqp; Thu, 21 Mar 2024 10:17:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU5cA1dKOJUxj2RN3KN2BjPacRUH8vaNg3hVlyiA3gqBWiS2Km8mWnKo4PV3KQnw4bLsOJugmCpDijqin7lES1XsI6sTAFd0Bq1oswObg== X-Google-Smtp-Source: AGHT+IF2+e/K0mhY780V3FjdbyEiXqr/MlMUXLoLS1KingmcUoa3vLVH7kVz1bxK20vpo4e3jheF X-Received: by 2002:a17:90a:bf06:b0:2a0:2113:cc0a with SMTP id c6-20020a17090abf0600b002a02113cc0amr2409869pjs.23.1711041446071; Thu, 21 Mar 2024 10:17:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711041446; cv=pass; d=google.com; s=arc-20160816; b=nZb2O5CeL5o4fm3PyIIbF0htrYwzdAi7Mjb8OunJKeF3Wco+3+N44yt/jMteBGRI1n nkgbUpSwLDCsYhOPdW3BmLeszl5IdZFGbUTWc9qQsPXGZIPfX5vFW6388Q81ij1amddn 09DXIH4NsLglbyZWUp6YFxIqEMBA2bOwIvi5oecTfKHKMRBZkPvEqMBTg6mExbHQ6nm4 +jS0egESQVsqm02joSxQ/0ULXnWQS5I3S3kRHndisKpUMjD3r5XGFdImsqZHGWgyGdop hryfUQVZnC8+1ySw3T80e+Dr3R1UUYc1Cu2J3/8ggZ7Fm9ADw+iLYbXHdvn5zkCGqt4/ Hp+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=6x2Oli3qgGl7XWaYDmqx5h3z7u3K/qfY9qQi9MZsllA=; fh=nR2nS9yvo8rBLcqBTWdVdTZMSYf1MQu9UGN1RA8/poQ=; b=vXRf1TaytnefXqxfajDhUmD84AOc4QxQ62JJiMC+QWiHpYhRtsoHoi3VmRcDsLLEOY RdvXCP/gvbCR+v/xlHSpkjtVEdcp5PGr/W1TLOlNtiKv4Y23tsIN0V36tsRkDR9A9Vp0 HeRlOia58bKSOwWInZPzKrkC4MOWGHegTnsqL3Glx3BqDi1Y9IrocB0JMaPrLKHqmvzy cnY+0bI3/tisf9O18weHUhLqSxtGVLfSvWAeyRt0DKqJH7EmZwMixrKOrEZXLPjtxS0s oOA7HlDYqXONh4TRUIu2ZrcUA6Ab5Immo16v11NEqBRsZHjO9HmWYIq3Ut3R3+aLz27J SObw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RBlmFhni; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-2809-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2809-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y21-20020a17090aa41500b0029b6b5a5b1esi217043pjp.108.2024.03.21.10.17.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 10:17:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2809-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RBlmFhni; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-2809-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2809-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B6CF5282C6C for ; Thu, 21 Mar 2024 17:17:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9E7D1E528; Thu, 21 Mar 2024 17:17:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RBlmFhni" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A17AAC2E9; Thu, 21 Mar 2024 17:17:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711041440; cv=none; b=Lj7cpLqHGy491RhbxWKQVfXRFKqen7EAULj2KJG6tooW0gCYpQe0KtG+nO6ZfeZMZcmp3MQK+z5SA0xchy0QwQoaqMjPGxQTeZ+VWCuNLDenT0loNq57ycfQ/0f7h+dBFuRz11rDBSQ+FQVpnGQVSV31v6aZybJgLE8bSXPZP00= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711041440; c=relaxed/simple; bh=9ac2pFm45Vkb4zyIlPdYjwUY5c7XpoySPr8khkoLHbY=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=fQwq6tEY4qMkigKB9PhqVbp22KlehFFTDz4AvCskrVELTk2g/WmE3qEDrGDGgqxOzhQiJk3FzggjO0/dDdmI4xEomMswYy5g1k1zKwlCMRjt67C5Ka0VDwhM+Iam4Gy/IZcvm2sed3eijNmUKI3z+QTPFHW1HbXpNTWktyaDAYM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RBlmFhni; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 616D0C433F1; Thu, 21 Mar 2024 17:17:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711041440; bh=9ac2pFm45Vkb4zyIlPdYjwUY5c7XpoySPr8khkoLHbY=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=RBlmFhnivZexbInTZDJc+eICAX81KkmJawXjaNdXrtVnjPUjVqsp6kfe4fdNYXUzX yFGOQux2Ncm1+jaBSKCQ7wwJWKYleWIf5qxy/iZsADTfjVDY9rVU1kXTmMQBcgEC63 Z1eyYHGwH6TBnKbzPgUcUAxotQjwIGldeB+5ed8bdcS4Ud6Y+GpqhxCwDNMRNxyavY uuCQSABxCBPTb+DGGVOB0t/Uk4+7911qdL67fqAWOjL9jrMJsdjJfdF8BqrHYD7hd7 meIfWlby2JRU3OrdZgs97i7psq853pKXMrnmZQv+AxmN0QAOb2XUgjTWV9mU50gieZ JRQJHrBJOTWxw== Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 21 Mar 2024 19:17:16 +0200 Message-Id: Cc: , , , Subject: Re: [PATCH v7 05/13] crypto: ecc - Add nbits field to ecc_curve structure From: "Jarkko Sakkinen" To: "Stefan Berger" , , , , X-Mailer: aerc 0.17.0 References: <20240320114725.1644921-1-stefanb@linux.ibm.com> <20240320114725.1644921-6-stefanb@linux.ibm.com> In-Reply-To: <20240320114725.1644921-6-stefanb@linux.ibm.com> On Wed Mar 20, 2024 at 1:47 PM EET, Stefan Berger wrote: > Add the number of bits a curve has to the ecc_curve definition to be able > to derive the number of bytes a curve requires for its coordinates from i= t. > It also allows one to identify a curve by its particular size. Set the > number of bits on all curve definitions. > > Signed-off-by: Stefan Berger > Tested-by: Lukas Wunner > --- > crypto/ecc_curve_defs.h | 4 ++++ > crypto/ecrdsa_defs.h | 5 +++++ > include/crypto/ecc_curve.h | 2 ++ > 3 files changed, 11 insertions(+) > > diff --git a/crypto/ecc_curve_defs.h b/crypto/ecc_curve_defs.h > index 9719934c9428..ab1ef3d94be5 100644 > --- a/crypto/ecc_curve_defs.h > +++ b/crypto/ecc_curve_defs.h > @@ -17,6 +17,7 @@ static u64 nist_p192_b[] =3D { 0xFEB8DEECC146B9B1ull, 0= x0FA7E9AB72243049ull, > 0x64210519E59C80E7ull }; > static struct ecc_curve nist_p192 =3D { > .name =3D "nist_192", > + .nbits =3D 192, > .g =3D { > .x =3D nist_p192_g_x, > .y =3D nist_p192_g_y, > @@ -43,6 +44,7 @@ static u64 nist_p256_b[] =3D { 0x3BCE3C3E27D2604Bull, 0= x651D06B0CC53B0F6ull, > 0xB3EBBD55769886BCull, 0x5AC635D8AA3A93E7ull }; > static struct ecc_curve nist_p256 =3D { > .name =3D "nist_256", > + .nbits =3D 256, > .g =3D { > .x =3D nist_p256_g_x, > .y =3D nist_p256_g_y, > @@ -75,6 +77,7 @@ static u64 nist_p384_b[] =3D { 0x2a85c8edd3ec2aefull, 0= xc656398d8a2ed19dull, > 0x988e056be3f82d19ull, 0xb3312fa7e23ee7e4ull }; > static struct ecc_curve nist_p384 =3D { > .name =3D "nist_384", > + .nbits =3D 384, > .g =3D { > .x =3D nist_p384_g_x, > .y =3D nist_p384_g_y, > @@ -95,6 +98,7 @@ static u64 curve25519_a[] =3D { 0x000000000001DB41, 0x0= 000000000000000, > 0x0000000000000000, 0x0000000000000000 }; > static const struct ecc_curve ecc_25519 =3D { > .name =3D "curve25519", > + .nbits =3D 255, > .g =3D { > .x =3D curve25519_g_x, > .ndigits =3D 4, > diff --git a/crypto/ecrdsa_defs.h b/crypto/ecrdsa_defs.h > index 0056335b9d03..1c2c2449e331 100644 > --- a/crypto/ecrdsa_defs.h > +++ b/crypto/ecrdsa_defs.h > @@ -47,6 +47,7 @@ static u64 cp256a_b[] =3D { > =20 > static struct ecc_curve gost_cp256a =3D { > .name =3D "cp256a", > + .nbits =3D 256, > .g =3D { > .x =3D cp256a_g_x, > .y =3D cp256a_g_y, > @@ -80,6 +81,7 @@ static u64 cp256b_b[] =3D { > =20 > static struct ecc_curve gost_cp256b =3D { > .name =3D "cp256b", > + .nbits =3D 256, > .g =3D { > .x =3D cp256b_g_x, > .y =3D cp256b_g_y, > @@ -117,6 +119,7 @@ static u64 cp256c_b[] =3D { > =20 > static struct ecc_curve gost_cp256c =3D { > .name =3D "cp256c", > + .nbits =3D 256, > .g =3D { > .x =3D cp256c_g_x, > .y =3D cp256c_g_y, > @@ -166,6 +169,7 @@ static u64 tc512a_b[] =3D { > =20 > static struct ecc_curve gost_tc512a =3D { > .name =3D "tc512a", > + .nbits =3D 512, > .g =3D { > .x =3D tc512a_g_x, > .y =3D tc512a_g_y, > @@ -211,6 +215,7 @@ static u64 tc512b_b[] =3D { > =20 > static struct ecc_curve gost_tc512b =3D { > .name =3D "tc512b", > + .nbits =3D 512, > .g =3D { > .x =3D tc512b_g_x, > .y =3D tc512b_g_y, > diff --git a/include/crypto/ecc_curve.h b/include/crypto/ecc_curve.h > index 70964781eb68..63d5754e7614 100644 > --- a/include/crypto/ecc_curve.h > +++ b/include/crypto/ecc_curve.h > @@ -23,6 +23,7 @@ struct ecc_point { > * struct ecc_curve - definition of elliptic curve > * > * @name: Short name of the curve. > + * @nbits: The number of bits of a curve. > * @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 +35,7 @@ struct ecc_point { > */ > struct ecc_curve { > char *name; > + unsigned int nbits; Nit: Hmm not strongly opionated here but wouldn't it be more consistent to use u32 here as the types below are also exact bitsize types? > struct ecc_point g; > u64 *p; > u64 *n; BR, Jarkko