Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2155806rbb; Tue, 27 Feb 2024 12:23:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWs/6B6ihD/K9t5dyloJQOcjpSNq6/GMtid1TCpdkJNlKVUjmJ7ZbLnKJzLeK1kgzNORX2yVehU0YMM2LtzUdgjgTy/VtZqx23bG62YzA== X-Google-Smtp-Source: AGHT+IHUpGdhNhtJIukeBXRCmei9LN3654pdn/qg5R7YZtslq3CCPTGOqchjqrc3YgRtgG6mhRnt X-Received: by 2002:a05:6e02:1aac:b0:365:89a4:a7ab with SMTP id l12-20020a056e021aac00b0036589a4a7abmr13431333ilv.11.1709065433676; Tue, 27 Feb 2024 12:23:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709065433; cv=pass; d=google.com; s=arc-20160816; b=BloVMM2jaDy+ehh4rMxN609+cPCzV6XOzC3JJ3Fq8jH10SIrUV4CTfiBOPckxSFUlC HvBgDAoM6/hKBI774J3w2sWoKTVpE1hnK2NY3oEBzb6jd0bqyx9h6SL7LhmKynjxRyCo AWnCm4Kp63cwFrrv+7+y7cqcVpKQ/iz/BPPjt7Bnnz8aOCZ7IYqE6ltsI4h6lN2529lT Cw0LYV4vt1x2TO1Vi7MSBBvDZIVsP5IKJ62KuerZDMmyj9cjv0sDMCjtvx+hw/YEZdjl 0aa4whN9ov6yNKBbCydYHpDOqb88CSVtrURXBFCihSvCikCzBqyqzPfYQ6O1G8/xB1g2 rbLg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=qNrOZNaeruVvTprzcx0TyoBoC0VgBNhWbvIzNQDxkWI=; fh=/w08LdzNt1kNSwWwCVqhlqp7XWsG8pryXQF7MxR0bbE=; b=iwM5Vzp8JhKO1BgkJYz6RWcvX3Gj6Pt1U62EAMU/WgfkgxZisP9yCQ+hORZ49Hor0k uxpMr+E7vetpweuhPx3jFyLzrd0OSeUEKSB4phmhkt1jbTk1JUUeFLutl2dB14Nu5Aon Okm2Eo8AbkiI93uH8nDKTh0xfe//NUTiDqtDUpICJESf9G3JEEWDiLRe9IMlMwyNKx2m mkee2dvkh5bLpEgOu4hTi13R2+jwzMJscnFszpIyAiZtoNspJGgDAD6fuIwIGwwx0t41 XmcBWs1NNccezyycg6RG3XTNzCYk2gkcxVgVATtfChEeJC1/l/JmwFzEXQrared9dyps ndIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-crypto+bounces-2348-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2348-linux.lists.archive=gmail.com@vger.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 a8-20020a056a000c8800b006e544ff9109si2078862pfv.318.2024.02.27.12.23.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 12:23:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2348-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; arc=pass (i=1); spf=pass (google.com: domain of linux-crypto+bounces-2348-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2348-linux.lists.archive=gmail.com@vger.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 5E0B728B83E for ; Tue, 27 Feb 2024 20:23:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8081B14A4C5; Tue, 27 Feb 2024 20:23:48 +0000 (UTC) X-Original-To: linux-crypto@vger.kernel.org Received: from bmailout1.hostsharing.net (bmailout1.hostsharing.net [83.223.95.100]) (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 E88921D6A8; Tue, 27 Feb 2024 20:23:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.223.95.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709065428; cv=none; b=kldx9SWlqytSmz/CBmjvAorBti+NoRTZUDMwRCLDkerMOCJzTz+Zjqt+Vh2yUFc3RJyXSeqpXT4hAft5IZFpfHW7d4ucAx0eNF3vxROsQs5o8+T9uCJXxnxVr8LK8SVHTd7LHofVlpzY0NSdojzpLNBd6F98RLQhNBpDvNA7m5M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709065428; c=relaxed/simple; bh=irdNq1Mm9AfgWRQih82uRLxz7KfkC+JUxWNIWOC5zx0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FRTbdigH8ZNxuRSEbk1VX1EXKokAGnAP+fK4Bg01RBeGkrxsAVtnW6ck1pLfD1Vqd/JoGvr9lG5RrFmVjNjCntghktrewUmCtCJ0EzDyDUCY8VQMZbx/4wCE6lRpEYp3VF9nFs3BSzGWsU+JcQ9N5DVlSGtdooTTFhTZxNE3QUQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de; spf=none smtp.mailfrom=h08.hostsharing.net; arc=none smtp.client-ip=83.223.95.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=h08.hostsharing.net Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (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 bmailout1.hostsharing.net (Postfix) with ESMTPS id 82110300002C4; Tue, 27 Feb 2024 21:15:52 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 756A15D8259; Tue, 27 Feb 2024 21:15:52 +0100 (CET) Date: Tue, 27 Feb 2024 21:15:52 +0100 From: Lukas Wunner To: Stefan Berger Cc: keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net, linux-kernel@vger.kernel.org, saulo.alessandre@tse.jus.br Subject: Re: [PATCH v3 06/10] crypte: ecc - Implement ecc_curve_get_nbits to get number of bits Message-ID: <20240227201552.GA32765@wunner.de> References: <20240223204149.4055630-1-stefanb@linux.ibm.com> <20240223204149.4055630-7-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240223204149.4055630-7-stefanb@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) On Fri, Feb 23, 2024 at 03:41:45PM -0500, Stefan Berger wrote: > --- a/include/crypto/internal/ecc.h > +++ b/include/crypto/internal/ecc.h > @@ -75,6 +75,17 @@ static inline void ecc_digits_from_bytes(const u8 *in, unsigned int nbytes, > ecc_swap_digits(tmp, out, ndigits); > } > > +/** > + * ecc_curve_get_nbits() - Get the number of bits of the curve > + * @curve: The curve > + */ > +static inline unsigned int ecc_curve_get_nbits(const struct ecc_curve *curve) > +{ > + if (curve->nbits) > + return curve->nbits; > + return curve->g.ndigits << ECC_DIGITS_TO_BYTES_SHIFT * 8; > +} Since you're amending struct ecc_curve with an extra nbits value anyway, why not statically fill it in for all curves, instead of adding this extra complexity in the code? Thanks, Lukas