Message ID | 20240223204149.4055630-3-stefanb@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-79118-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp834210dyb; Fri, 23 Feb 2024 12:43:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUoK7GsN23DY/nbtTafQz3dkSGHxdo/gl8EvcWvwX6rYMxwoV1IYbm7dxdWdy77GiNBoqx16JsVix+CYReV5YJhXp079w== X-Google-Smtp-Source: AGHT+IHCU5GlVNIvApqmfIXJiy/NC2+Ziauz5VyW3JgGZRImFIcLrhaa5lhemzV1Lp5tD20NWaga X-Received: by 2002:a05:622a:8c:b0:42e:4e6b:5ed4 with SMTP id o12-20020a05622a008c00b0042e4e6b5ed4mr604260qtw.0.1708720991016; Fri, 23 Feb 2024 12:43:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708720991; cv=pass; d=google.com; s=arc-20160816; b=QxF8keCEg1+RIqzSH+nSdv2/pXOo7j9gmU1fT+J6yGlulF76+6CqUKTsgYuCrYrXlB nkCIBobnhKuZYxKaKWjMQUmyZqe6KKd9v732CYjBWyU91xYsP2FQafPc+WzQ778OY+6t LbbVKf74W/M+ennD46c4/JCBNm8uWVvIV7XbjZhgtmY/VmucE0yICJ2hdwxKxmLQc5bC IKNQCIHCccYq05icXvWq4gRcsOKwCgT8bVrQ4QuRywm7W+yfumAJI59R4KYTzY0yYt9k 0zgBm7uprcLZ+dJ93PEejjh7zq8nGr8rFKnPA/gMDtnDoGegiFZzzIibl4TzN/TjkqkA TAcQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=UfCoxw1GwPsVnPVgicCJh55bEckUIM/iCOGiq6BVP00=; fh=nKmjVxPwCa773nyq5JxrCa37ZALdOpLJMBES7dZaGuw=; b=G3IjMdpj4emUT3ZzC3klHJNBKOdCDwj0U+QnyvVlbSlcjeMqpuMnANOszEjCzuxxa6 2kCK4GXmDZQEwG0uDd7URvKiOJVL2sxIHyHDLHZew2RDkKsW0FkQC+T9sTb4lPcHQ+7i JwRPOT8yvqopoczXEJa9P5EapSMC9qSfHxHaInRt9yU6z5QfwvwnywxsBPzwrHB2ZNex jJ5xM3LBtr7P0td0W/gQ1oOf+tpmgS7A4nhxwyL7FtU2JlNq8YjFJaDktbRwoxbR8MU+ 2kfwmCJiZKkAAiziAtPv0rbLCFJDHm8mlYgegL1fSWJtoeZ+CHSSGq4Y54EMeyAoIPw4 y8Lw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lLeqXE5L; 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-kernel+bounces-79118-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79118-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f10-20020a05622a1a0a00b0042e4030e913si6190143qtb.293.2024.02.23.12.43.10 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 12:43:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79118-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lLeqXE5L; 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-kernel+bounces-79118-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79118-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CB1741C2287F for <ouuuleilei@gmail.com>; Fri, 23 Feb 2024 20:43:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DC3114CAC7; Fri, 23 Feb 2024 20:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="lLeqXE5L" 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 78F5114532B; Fri, 23 Feb 2024 20:42:13 +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=1708720934; cv=none; b=ncG6jPopy7uXFrpof2RzImyv3//s4f80s+edJBF5gPxFX0C+dES6Nudo5U18P9SoSuiu4oaqO03fh93PyG6fFFAGdlxio4OTH3pIzfeU+++6HChDZQY5sAHQDPhJK0iSPKzTCc2yFk8ruvcVZEm/+hvUWQ3TY5p4r37AKXqBqZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708720934; c=relaxed/simple; bh=lUuzPnZtqYdFvF6hiy1auTq+Az0+wC1o9vh1IKFDu8U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c/yhb/pyGhxaG0/JgkGjeGT++HJeG3zazdCXYu3P5OKzs96yvbC7I00TQa+vvihAmr3mBoXuo+YHulJyFD5kOtacy+SkfZ3B6PoKl/K5vTeV0uBtMci/IQqOpIi7oeh7zKheecTkdbM871h4I70pItFb6KPINY7Orb5Cy+VsDTk= 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=lLeqXE5L; 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 (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41NK27NB007232; Fri, 23 Feb 2024 20:42:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=UfCoxw1GwPsVnPVgicCJh55bEckUIM/iCOGiq6BVP00=; b=lLeqXE5LWjbiqIMEkg1GZbBv2F+XCdoCDCCG18DBDIQU3JeFrGpwK4/BjsnZKmi9VAU0 RxcXAgvLCp8HPIHxFRpCeMEDm+yFZKvsTNctGmsovMOfqykww8tWsRWyjOSIojPvRCWO KaGIq0JK98/mclmbAolC1oth8SM7f31FUPjxlf8ma/3/ENccFhThM6REhOfYi5KQ5nRB ljLceqEy/rW3QNWGCJhh08P7ZEPMCBk0hjP3+3Wtd8YkxUNsOLTv+rk5DNI2iFN4/+Sf VkZ5uVl8HHtviuQcSh3VnUBmr7dpaKSROAeesMvu7Xybtsm2CJg2NGj8N8o6qu8UZFWv ww== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wf21t0uqc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Feb 2024 20:42:07 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 41NKTIKi003611; Fri, 23 Feb 2024 20:42:06 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wb74u8bc0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Feb 2024 20:42:06 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41NKg4Jj6685332 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Feb 2024 20:42:06 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0CC5358059; Fri, 23 Feb 2024 20:42:04 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4BC3F58061; Fri, 23 Feb 2024 20:42:03 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Fri, 23 Feb 2024 20:42:03 +0000 (GMT) From: Stefan Berger <stefanb@linux.ibm.com> To: keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net Cc: linux-kernel@vger.kernel.org, saulo.alessandre@tse.jus.br, Stefan Berger <stefanb@linux.ibm.com> Subject: [PATCH v3 02/10] crypto: ecdsa - Adjust tests on length of key parameters Date: Fri, 23 Feb 2024 15:41:41 -0500 Message-ID: <20240223204149.4055630-3-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240223204149.4055630-1-stefanb@linux.ibm.com> References: <20240223204149.4055630-1-stefanb@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: vALespw88SB8BWtXSoUps--_cmqV19ZQ X-Proofpoint-ORIG-GUID: vALespw88SB8BWtXSoUps--_cmqV19ZQ 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-02-23_06,2024-02-23_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402230152 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791723821928267883 X-GMAIL-MSGID: 1791723821928267883 |
Series |
Add support for NIST P521 to ecdsa
|
|
Commit Message
Stefan Berger
Feb. 23, 2024, 8:41 p.m. UTC
In preparation for support of NIST P521, adjust the basic tests on the
length of the provided key parameters to only ensure that the length of the
x plus y coordinates parameter array is not an odd number and that each
coordinate fits into an array of 'ndigits' digits. Mathematical tests on
the key's parameters are then done in ecc_is_pubkey_valid_full rejecting
invalid keys.
The change is necessary since NIST P521 keys do not have keys with
coordinates that each fully require 'full' digits (= u64), unlike
NIST P192/256/384 that all require multiple 'full' digits.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
crypto/ecdsa.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Fri, Feb 23, 2024 at 03:41:41PM -0500, Stefan Berger wrote: > @@ -239,7 +239,7 @@ static int ecdsa_set_pub_key(struct crypto_akcipher *tfm, const void *key, unsig > keylen--; > digitlen = keylen >> 1; > > - ndigits = digitlen / sizeof(u64); > + ndigits = DIV_ROUND_UP(digitlen, sizeof(u64)); > if (ndigits != ctx->curve->g.ndigits) > return -EINVAL; This deletes a line inserted by the preceding patch in the series. I'd prefer just squashing the two patches together. Thanks, Lukas
On 2/29/24 04:16, Lukas Wunner wrote: > On Fri, Feb 23, 2024 at 03:41:41PM -0500, Stefan Berger wrote: >> @@ -239,7 +239,7 @@ static int ecdsa_set_pub_key(struct crypto_akcipher *tfm, const void *key, unsig >> keylen--; >> digitlen = keylen >> 1; >> >> - ndigits = digitlen / sizeof(u64); >> + ndigits = DIV_ROUND_UP(digitlen, sizeof(u64)); >> if (ndigits != ctx->curve->g.ndigits) >> return -EINVAL; > > This deletes a line inserted by the preceding patch in the series. > I'd prefer just squashing the two patches together. > Hm, I moved this part here into 1/10 and left he other hunk in 2/10 since they deal with slightly different issues. Stefan > Thanks, > > Lukas
diff --git a/crypto/ecdsa.c b/crypto/ecdsa.c index ba8fb76fd165..64e1e69d53ba 100644 --- a/crypto/ecdsa.c +++ b/crypto/ecdsa.c @@ -230,7 +230,7 @@ static int ecdsa_set_pub_key(struct crypto_akcipher *tfm, const void *key, unsig if (ret < 0) return ret; - if (keylen < 1 || (((keylen - 1) >> 1) % sizeof(u64)) != 0) + if (keylen < 1 || ((keylen - 1) & 1) != 0) return -EINVAL; /* we only accept uncompressed format indicated by '4' */ if (d[0] != 4) @@ -239,7 +239,7 @@ static int ecdsa_set_pub_key(struct crypto_akcipher *tfm, const void *key, unsig keylen--; digitlen = keylen >> 1; - ndigits = digitlen / sizeof(u64); + ndigits = DIV_ROUND_UP(digitlen, sizeof(u64)); if (ndigits != ctx->curve->g.ndigits) return -EINVAL;