Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1407513lqg; Sun, 3 Mar 2024 08:35:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWhmnP8Mzgn1Gis9iGwuNj/pEXHDJG2uSchXsuEiFqWGpD7K/Kwkf66UCcn7C7fGi6rFw8QtOTcd+JVc/cDoz1yJsjrpA69fp7L43PUdA== X-Google-Smtp-Source: AGHT+IHIc2dInYdLnUbZtIo1/7mTutY56DcWQhk0wWc2ZNc/i3SxB7Nrqr2wJq9+AWdYU5Ar9AP/ X-Received: by 2002:a50:8dc9:0:b0:565:ddc7:6dcd with SMTP id s9-20020a508dc9000000b00565ddc76dcdmr4434970edh.8.1709483706928; Sun, 03 Mar 2024 08:35:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709483706; cv=pass; d=google.com; s=arc-20160816; b=qVS/merIG/YB96GO0s4IFIsAYbrCBawdhH6V8wivsGxuR2ngNGxFzfZmOYvhwmvF/m bEmb3NLOJmkWnN8lJQNHbGzaW6KAH51IG8UVsgN9rsY8IdyYKqpwWNJGPeXMeEOTrobZ KknEEw5+gtTNvkduhikIZriO91lGWWBohEINnEQD4vse5AMzGeAy6WoUsCpCkEwB/PMI H+pQJeBAb2KMx9KdzTHMxi5edwCGvACgvd+gt18AgJ3YVS9necQZ6b6blSVJGjhsoGsF GlVEhqPxKHIdAOZl2Jc8x8uZ32+hdX3zLknVypeA0wUsQbaKA3bubwm+mQF3jIpqg/To L7hw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=41iZvq4eVdevoNfTtBHjCCDQIdJbG0eX+7Gd0Vpc0BM=; fh=oaC6g1rvngpUy3NBPUH3HwPaOzR9292cM7qLBeN9XRU=; b=cBFa3oYzRMz0RO5QMZsxoXcKRVdP0hlzAxk9v+rU0MBpxtt5lgzZkUh9wjonld4K/J p7vWi2Qme8zuDLLkzPH+cKk+dJanuo9w/HvTOc9t0UhJ2NGOH2SQVGyy46kmJpMUepOy TUcSEDPr6JRlxTL0xXSTlzfRAHEGHHqaNUkD1YXvtseo2L0jMkIR9O287xMbKKX6dC5p BhiJp9KyIibCvEQcKSm5H7YFj4K6Dnr1fccIW0Y3jL+x0I/oa7VYyYcbpB2mVZR/osgh 6JbKR5JHJh6PaaLLG3oBjFNyI9P096o75fCeoCKiLT4ioo8vJ/vvBsm0YIWsTxVXpCTe 6r2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=dhfEA0Co; 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-crypto+bounces-2474-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2474-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u23-20020a50d517000000b005664cf05f01si3318189edi.558.2024.03.03.08.35.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 08:35:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2474-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=dhfEA0Co; 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-crypto+bounces-2474-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2474-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9CF711F22D62 for ; Sun, 3 Mar 2024 16:35:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F20D36BFB1; Sun, 3 Mar 2024 16:35:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="dhfEA0Co" X-Original-To: linux-crypto@vger.kernel.org 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 D062266B5F; Sun, 3 Mar 2024 16:34:59 +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=1709483701; cv=none; b=NW/rBQXD8eiQtcGuB2W3WykqY6b2eY/fkFqtcgBXPlc0n7Vumpqoxw5plz88Z5lpeOI9LKRNXpxv6ElTZofxsOAGh0Q+uTBQT3abhl3NwiCDAtGVE2T/alWsBU92bP9Mr9zBmJ0l7fgebqAxTxEhwQe/6lFB8Eytj7PdFtVMUDI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709483701; c=relaxed/simple; bh=2825eaZss1IHkN+3rVm4G15pyNS+UryEWrk3AiEzljI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=X8w7LxMJccNZ5jTtzlNxj7s2gbjQq9XL3RW4qdppK6xYC9UqunsM9vK5g0QTdP6xpEC12+6cpY85UOj/u1sbj5r2EZHfXeAXT469cLtFpfN6S1K9mle+K4aSxnqzkNEUuRIfHzWeav55jggP7VnvaCly9Wdfzki/An6j2EJrMnw= 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=dhfEA0Co; 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 (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 423GWJWL012301; Sun, 3 Mar 2024 16:34:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=41iZvq4eVdevoNfTtBHjCCDQIdJbG0eX+7Gd0Vpc0BM=; b=dhfEA0Co6RO/7yi53GXTWDpZl57n2JE+PshldFOrv1ezgl2XZ8r6q3U/bZyoKE+FNIo1 xJz1ZTtt6dTcx0/ce+3reetZ0PhnwTfvCT1quFefHhVw8LiCkM4+1xqiby5a3fIRjOdJ JWDAMw9/AMjIoxB1cqYRSsii1qtq4xNdVtfJGy2ulPBOaOLgeXBO6Bs3c1VpQ17pKalE 0HwKTreWuYKToPOMWqbWeRLeDFAXclWOZ4ZoeQCuf9Tpe+W1pMEjV7LA6X9Tp47Q7kDJ 5NcI3LkSlT7CwHjDZGuP19sn4ZNgRJUC+zWYLbmzBEQozITgSPSexAakuohhnxpo7vVT 3w== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wmvth80tq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Mar 2024 16:34:54 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 423D9thD020596; Sun, 3 Mar 2024 16:34:53 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wmfxkbc8b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Mar 2024 16:34:53 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 423GYo8s8651282 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 3 Mar 2024 16:34:52 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B0D6858066; Sun, 3 Mar 2024 16:34:50 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0A1F05804B; Sun, 3 Mar 2024 16:34:50 +0000 (GMT) Received: from [9.47.158.152] (unknown [9.47.158.152]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Sun, 3 Mar 2024 16:34:49 +0000 (GMT) Message-ID: <66333389-1d5e-4d86-bfc6-119bfa6b393d@linux.ibm.com> Date: Sun, 3 Mar 2024 11:34:49 -0500 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 01/12] crypto: ecdsa - Convert byte arrays with key coordinates to digits Content-Language: en-US To: Lukas Wunner 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 References: <20240301022007.344948-1-stefanb@linux.ibm.com> <20240301022007.344948-2-stefanb@linux.ibm.com> <20240302213427.GA30938@wunner.de> From: Stefan Berger In-Reply-To: <20240302213427.GA30938@wunner.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ssrt6So7zSWUQifCxZX0VWQEYuo_nNM4 X-Proofpoint-ORIG-GUID: ssrt6So7zSWUQifCxZX0VWQEYuo_nNM4 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-03-03_07,2024-03-01_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 adultscore=0 priorityscore=1501 spamscore=0 malwarescore=0 phishscore=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403030139 On 3/2/24 16:34, Lukas Wunner wrote: > 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. I would prefer 'digitlen' rather than repurposing keylen and giving it a different meaning... Stefan > > Thanks, > > Lukas