Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1201449lqg; Sat, 2 Mar 2024 22:37:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+AZHCZTEFklBh7UyKqHm/AbGrNmjhNVjP5Lga+1vw1cAWAUDyr+ozl8aY1nepFrvpwVb1+AnKLesdEvYuV4Qlf6ZthUVPcKkNrJH6NQ== X-Google-Smtp-Source: AGHT+IEW8E12sBVxhKYyRL/X67/fKS5fRZQhbh6j/ojpj1eEZzPP4WIchPaIReEfqdx92B1qchVz X-Received: by 2002:a17:902:8a89:b0:1dc:cbc0:1971 with SMTP id p9-20020a1709028a8900b001dccbc01971mr5664816plo.49.1709447851595; Sat, 02 Mar 2024 22:37:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709447851; cv=pass; d=google.com; s=arc-20160816; b=CRI9ij1FjiWJUUCqhs/CvT85RZK62FSJf08EySh9CuCwhp9ipR7gu9/7etly79Ic8m hnd11AhyysPn0K1ZlroDv/qOWq5ODRMbQ9MzlQpqhq+WIL/Vhx6D32NiB9qsN/nyZjVl OjWbkBXzCtbWANtVPbkUfJJ8AtLv78y9BiZIviexO8xaSnGOXldwsfveQ2P3u/w+gy2U BuAOTDmLcVMEUDVlTiH0OcfsHSxtf/njmN+kwIymxYCmh3/H6krCxnO7jFG6+nmCOu42 d5iOr9fGzo2zYR59atIGQB7SjFDFTmzA3IFyeXvOuUd2m9UPA+ugN3K5inURuLoXgKSj 9Phw== 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:user-agent:references:in-reply-to :date:cc:to:from:subject:message-id:dkim-signature:dkim-signature; bh=ZelwAesumEay/d5x5ExL/yW44xMufklWx2DQ4lr/aAk=; fh=TKSn56wS1px9xlFiDi3iXsRL+NuGoTgf7TnYgj35aHQ=; b=Pa/iFnYQ6R5lmbNb+j52h6IUvn0e7CfBAMsdpyVUcjiCkPVEwUUq1UNgPnT2rvLPr5 CTxpbGcbrmRdZeHSMv28v38Y0FO4WfGA4mHK/LlQlDhe8wBW/DujU/QuzXUYJE4MlTra lDcNeJQ3ZWYjpzKD7Vq7JpFgY2wy/wf43/ZaK5wKcBh5JKxXg2IavqARq5MED+adxTQk E5lk+Anp6GJZ6NBCRwrldi+pBcs7nEFed5VdOEmX+AIhX6ZoJXR//kjobe8W0AxLGROC ZHCeWIOxV6jJy1HXkYmYbrrq+Dudl7b43unqMVBbBktU9Dr9/vKPSiYEjAOBTwMlCP05 PILA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=K1qlQmq2; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=K1qlQmq2; arc=pass (i=1 spf=pass spfdomain=hansenpartnership.com dkim=pass dkdomain=hansenpartnership.com dkim=pass dkdomain=hansenpartnership.com dmarc=pass fromdomain=hansenpartnership.com); spf=pass (google.com: domain of linux-kernel+bounces-89662-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89662-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u12-20020a170902e20c00b001db339f4096si6159748plb.395.2024.03.02.22.37.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 22:37:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89662-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=@hansenpartnership.com header.s=20151216 header.b=K1qlQmq2; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=K1qlQmq2; arc=pass (i=1 spf=pass spfdomain=hansenpartnership.com dkim=pass dkdomain=hansenpartnership.com dkim=pass dkdomain=hansenpartnership.com dmarc=pass fromdomain=hansenpartnership.com); spf=pass (google.com: domain of linux-kernel+bounces-89662-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89662-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4AC61283E22 for ; Sun, 3 Mar 2024 06:37:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A311D9468; Sun, 3 Mar 2024 06:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hansenpartnership.com header.i=@hansenpartnership.com header.b="K1qlQmq2"; dkim=pass (1024-bit key) header.d=hansenpartnership.com header.i=@hansenpartnership.com header.b="K1qlQmq2" Received: from bedivere.hansenpartnership.com (bedivere.hansenpartnership.com [96.44.175.130]) (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 CE7B78BF3; Sun, 3 Mar 2024 06:37:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=96.44.175.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709447843; cv=none; b=Dd9DiNZh/b/OBn0BGNyP9qPCePdhhlgnf9URlYBLKgPxhSAP0dgnis4gQ/nJsJDEIfF7kJYXwZFhnJB+UWgCcttDUpPK4bB4Zvi7Ww0uiqPsszor2yTSdhBH/cTmY0Y6tA0K5eeusQfme/LqEB9gVhmQkq9Hh8jdcnTwGXhHrJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709447843; c=relaxed/simple; bh=Mi/1sj0+EwyDTN7bDczKsKPQ5d8sXsTdgkNDwNjo7u8=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=UJGfj7nNLrh0XcV8uhaK6juq/t1I+WmqLf6RnE67jrmECTO8qAjL3WyDHEnpdxutILIEQALcNpuxm341qMBz1YYzikjcwJMNR9Fmu7hYqxr8ru9mdt3WBmIKNdvQRwTzinnKDbxF1PTUnwrkgikBLtP8lEAijHCxZQ1LwjNOhRc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=HansenPartnership.com; spf=pass smtp.mailfrom=HansenPartnership.com; dkim=pass (1024-bit key) header.d=hansenpartnership.com header.i=@hansenpartnership.com header.b=K1qlQmq2; dkim=pass (1024-bit key) header.d=hansenpartnership.com header.i=@hansenpartnership.com header.b=K1qlQmq2; arc=none smtp.client-ip=96.44.175.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=HansenPartnership.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=HansenPartnership.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1709447840; bh=Mi/1sj0+EwyDTN7bDczKsKPQ5d8sXsTdgkNDwNjo7u8=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=K1qlQmq2ZgLYGQE2Y7p53QE3LjGwYBigLKKyz6tlNIlQ24KGyL5boMI4CMkmH6EL9 HnFt619DD4D8mfzxGTuC78ShdKZdyDA6+DLoq4cBWP5+9jMKMtZtm2Fv9nILFS2alg PA71UbUk2w/x9IZAIslQBYA7Qt/t9vVOa7S3y+M4= Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id BF3B712864AB; Sun, 3 Mar 2024 01:37:20 -0500 (EST) Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavis, port 10024) with ESMTP id NNLYqV4Cspjy; Sun, 3 Mar 2024 01:37:20 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1709447840; bh=Mi/1sj0+EwyDTN7bDczKsKPQ5d8sXsTdgkNDwNjo7u8=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=K1qlQmq2ZgLYGQE2Y7p53QE3LjGwYBigLKKyz6tlNIlQ24KGyL5boMI4CMkmH6EL9 HnFt619DD4D8mfzxGTuC78ShdKZdyDA6+DLoq4cBWP5+9jMKMtZtm2Fv9nILFS2alg PA71UbUk2w/x9IZAIslQBYA7Qt/t9vVOa7S3y+M4= Received: from [10.0.15.72] (unknown [49.231.15.39]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id 9AFF5128646B; Sun, 3 Mar 2024 01:37:17 -0500 (EST) Message-ID: <5227f58bb2caf9ce76e131b4d775df4755a0cafb.camel@HansenPartnership.com> Subject: Re: [PATCH v4 01/12] crypto: ecdsa - Convert byte arrays with key coordinates to digits From: James Bottomley To: Lukas Wunner , 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 Date: Sun, 03 Mar 2024 13:37:10 +0700 In-Reply-To: <20240302213427.GA30938@wunner.de> References: <20240301022007.344948-1-stefanb@linux.ibm.com> <20240301022007.344948-2-stefanb@linux.ibm.com> <20240302213427.GA30938@wunner.de> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Sat, 2024-03-02 at 22:34 +0100, Lukas Wunner wrote: > On Thu, Feb 29, 2024 at 09:19:56PM -0500, Stefan Berger wrote: [...] > > @@ -238,12 +237,17 @@ static int ecdsa_set_pub_key(struct > > crypto_akcipher *tfm, const void *key, unsig > >                 return -EINVAL; > >   > >         keylen--; > > -       ndigits = (keylen >> 1) / sizeof(u64); > > +       digitlen = keylen >> 1; > > + > > +       ndigits = DIV_ROUND_UP(digitlen, sizeof(u64)); > > Instead of introducing an additional digitlen variable, you could > just use keylen.  It seems it's not used in the remainder of the > function, so modifying it is harmless: > >         keylen--; > +       keylen >>= 1; > -       ndigits = (keylen >> 1) / sizeof(u64); > +       ndigits = DIV_ROUND_UP(digitlen, sizeof(u64)); > > Just a suggestion. The compiler will optimize the variables like this anyway (reuse registers or frames after a current consumer becomes unused) so there's no requirement to do this for efficiency, the only real question is whether using digitlen is clearer than reusing keylen, which I'll leave to the author. James