Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1059335lqg; Sat, 2 Mar 2024 13:34:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXMpY8ysP/GnNPYEAs0V6xJGqxjNdm958C9+am1PFFOAJ0VcW6wbe7/HnI2SSGJlyhQotuUNppvqMT20ryQI2PX9B6uiUGtsEK8VySgOw== X-Google-Smtp-Source: AGHT+IEe172iZqE55nS8Hmu++gzWWUp8HkxaaGJfZfRYefwzdpdI0BtNHFp5JPWaAPYdJrV1fh79 X-Received: by 2002:a17:906:d209:b0:a44:5927:3e67 with SMTP id w9-20020a170906d20900b00a4459273e67mr3958741ejz.23.1709415278195; Sat, 02 Mar 2024 13:34:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709415278; cv=pass; d=google.com; s=arc-20160816; b=kdHlA3BVLtvI3OpXcCTJMyzk0rL6Hc5ZaIKmiE28KACiafrzmAJkZoxfZHahhSv19o mFdDcZB4alqiqLkWotdTuczvgHvE93FxnyElsBfmB3B+jS0OqqXgAkhdtT1sQBJK2M6E WYssUCmExga95eaqnmVamNTn0qHPz1kKe0vYa690Je7Zk6trNWlnKUD3/fmrkyGZPx9c rNempIenYu6AUEOVB9idvSEbxbkQVw+3E4t+x79imO65OMZGZhQgxnYSoIrL8CPQ9yGB z0NqtJueGUp36vqNjB35Ia1+ffy6g6RCgouiDBGZsHdm5xlx60LRuGL2oel/RWrMTHUU g+lg== 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=NkbV9rfxL+/duuYIh4l/tPm9oRZShKKMKeww4Wl2Fn4=; fh=/w08LdzNt1kNSwWwCVqhlqp7XWsG8pryXQF7MxR0bbE=; b=d3ku8mZC2qMwEymMkYaIGc+IV0NSqzP/Vo9kcGin64Nyuvou+j4JJtF7bRVlUQ0aL7 5+i/u/KbqjGtNicFljK22nea6kVcR5c/oV1teAP/YvgawkW5osHluxHKxyr3eLKXkk3A q4iSIz8hGkdKsU+VaAXw9w8z7fhmhJ1cF+sKw86uvghSSk3thzkc1Whm+IS7OoQMPrKl HPx3iAdPOH4VKejKG+7K45doF2COWCdFBZzyoiC+W5Umdof764Vm6cgqsOj538mKpB7i ClBZQGANpSjQxsWkWfsyYrphUNUNS9Y6Mxdi+zeI8gaEwoKdfUjWaSeFD+2qeuh7Jq/P Ylkw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-crypto+bounces-2466-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2466-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s5-20020a170906c30500b00a450f93b6d7si103674ejz.426.2024.03.02.13.34.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 13:34:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2466-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-crypto+bounces-2466-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2466-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 am.mirrors.kernel.org (Postfix) with ESMTPS id D62141F2247C for ; Sat, 2 Mar 2024 21:34:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87A5E41757; Sat, 2 Mar 2024 21:34:33 +0000 (UTC) X-Original-To: linux-crypto@vger.kernel.org Received: from bmailout3.hostsharing.net (bmailout3.hostsharing.net [176.9.242.62]) (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 BB4F91F16B; Sat, 2 Mar 2024 21:34:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=176.9.242.62 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709415273; cv=none; b=Tcl6tbfjQR/emzFHQlNtJ+K8QnXggd2Pc9rZ1n9wSZY/qVnUcIPO4CP6zPhAVAUw7grku9KBDTUfHU+63kE3H5qMLuvg6UwwQS/OgcDkWIlkOr0tTcV3SRyOu3PcPaQqY/G8FRCe5ev/spnIJy2UaQQiWZs5/1hy3CEA6vlVE0c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709415273; c=relaxed/simple; bh=qa67s/52VE4paDCQ+GpC5YuWdKmXNoqBaJKRgm4xFWg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DWeXy0dhW33U8ihdv1ugnj35JrXsuVuxScHcTHeDQsisv+MxCOWvHZ3aVrKYd/S39mmFQn2/+IARQx2s4UvRU1fQoKPYrP5X02ion8KBDzGGbSrfJFWrsIQIewJpvTQCjafQNo2af3ZgNfj5lgkLlnTTXp0PO0Vxy9txbcfkOSg= 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=176.9.242.62 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 [83.223.95.28]) (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 bmailout3.hostsharing.net (Postfix) with ESMTPS id 5C393100D9401; Sat, 2 Mar 2024 22:34:27 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 3AD9F2E081; Sat, 2 Mar 2024 22:34:27 +0100 (CET) Date: Sat, 2 Mar 2024 22:34:27 +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 v4 01/12] crypto: ecdsa - Convert byte arrays with key coordinates to digits Message-ID: <20240302213427.GA30938@wunner.de> References: <20240301022007.344948-1-stefanb@linux.ibm.com> <20240301022007.344948-2-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: <20240301022007.344948-2-stefanb@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) On Thu, Feb 29, 2024 at 09:19:56PM -0500, Stefan Berger wrote: > --- a/crypto/ecdsa.c > +++ b/crypto/ecdsa.c > @@ -222,9 +222,8 @@ static int ecdsa_ecc_ctx_reset(struct ecc_ctx *ctx) > static int ecdsa_set_pub_key(struct crypto_akcipher *tfm, const void *key, unsigned int keylen) > { > struct ecc_ctx *ctx = akcipher_tfm_ctx(tfm); > + unsigned int digitlen, ndigits; > const unsigned char *d = key; > - const u64 *digits = (const u64 *)&d[1]; > - unsigned int ndigits; > int ret; > > ret = ecdsa_ecc_ctx_reset(ctx); Hm, the removal of digits isn't strictly necessary. If you would keep it, the patch would become simpler (fewer lines changes). > @@ -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. Thanks, Lukas