Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1454549lqt; Wed, 20 Mar 2024 04:49:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVcYWvTdhUg4LIlwVBf1SqBjIF63EXpDC+582B8y29hU9ZXcWe6XZpSLiDKGTUi3AXz+RX+6PQnyJL9GjfrkdDkyBwOUvAlHjwNyBDP7g== X-Google-Smtp-Source: AGHT+IFn72ygtKcawUvlYM85TOtw+wbEC5HKltwTSUHTrBKIr6FNJY6i1J0YC6KaoOqrUCf/aMYT X-Received: by 2002:a17:902:7790:b0:1dd:8daf:99b2 with SMTP id o16-20020a170902779000b001dd8daf99b2mr13422897pll.13.1710935358749; Wed, 20 Mar 2024 04:49:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710935358; cv=pass; d=google.com; s=arc-20160816; b=droTeaf5uqc/qR5z8swGuHv/k/VXUfdtl/GBOM2CnQcWttq+4+xVCDy+prHxW/2MMB CGhUpz56JlyuepcekdCp94tqwAWTjXEZ4+L19MClVFqpqBDy/psiQ2q9/avOm8myF3Zx Z7uKHh9LeYVrMa0IsNbwmVEoZpjnIWNNedMhLmEN4qtpPX4JfVxwD/pSKJ4e8jt6DFTv lmCC0uTEmjThFsHBgPaf8wLu9e2W/fuSXd7tU6hYRIQTbrOswDhJrYgtPIJRUHXcJlx9 opLEuBMj+I7eZop+0cU66/RuUQAY4iGvyP9M2KH7siyloyr05je4x/4nP6AM7Fjt0DKo wbfQ== 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=fqBVxCI9drzgI4JARsB4lrXIflRkdUMYH0t/R3+EjIY=; fh=ttd58PQB/9Jq7mprP/nc7Swd4f1ty4MwWMUAn54aZMY=; b=x8+nEGGZEmQbR9imkhXcjVc16qNpEoOgrRAD9rqdgr8n1bcSrUeiWhp/5kzukc2jEK D/Ers6X+mGci1bxtvdihdjp5ijtHQ1HI+vGbNp/rUqDXW3ucC2Av+LDoG+XJ5qDtvjhn UUPL1r8tsi2tLvQgBA2d/Qw94eaONJ5l1tyyrBpXdjGG4HHhQmghLiuUvxdkfKl3w3zH JYyCq3v+LPHLYP8uRo+iLyIHg3LaczoLB+XPZKLR830DnC4DFJE9/4dpLcQoITPi2O+P 8s6wOhD8mTwtUvhDbW5EiURhSnQA21bc+cykLz/rqkvaPAZmoyQ5Jf8UsTnBruazm2Jp IVDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=qYJlKsJQ; 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-2773-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2773-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id ll13-20020a170903090d00b001dcad9c5095si5216734plb.429.2024.03.20.04.49.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 04:49:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2773-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=qYJlKsJQ; 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-2773-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2773-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7E5D0B21AA2 for ; Wed, 20 Mar 2024 11:49:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1D9A433D5; Wed, 20 Mar 2024 11:48:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="qYJlKsJQ" 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 9A54D3FE20; Wed, 20 Mar 2024 11:48:03 +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=1710935285; cv=none; b=hhNSHS4o9Wdf5s8bru9cQLj9OXy+Fp5kcQw4GzJnwG2oPU1iXdGuO5SiNA909xYe8LVY1O4CMBGURX8xrSz13tCYfkCIJdVH6JLWJqr5Sj3XQdBcbh3DqgCoFQ4aA/lPFbYtJv4MhV/itL3sIAPefKsX9g+6C4ANZrDZaLYQW1Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710935285; c=relaxed/simple; bh=7WqSylbIzOjh21fPLC7Si2XXorC24cDxT/Kun4cDdE0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RFGHXfipXqnmmemIVHBMrhBehGB8mQkSv4d3BvDvdqFmLcg4zwP8Mh2wRLnKB+xKb3sVZ8cgTWtJR5BAhAUMDPHw0a4yk6uzuboSlT2vczyKgIwPU0agpsB9zZXizVvQspqtAu+E4mToDp//a00Whtr+NL0jyt5edk20D/ifzpc= 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=qYJlKsJQ; 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 42K92K2R000765; Wed, 20 Mar 2024 11:47:54 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=fqBVxCI9drzgI4JARsB4lrXIflRkdUMYH0t/R3+EjIY=; b=qYJlKsJQekA2vLb0Rv5dAyuUxKRAjt15CVexH21mlysiFzZvxAUmVMbzLqePj/MGDnKT 4Y3gMevKBm3w+BoA37rawtfRKA5jSt9NJpBOsl3ckjnelNC7Q1A9endYfswo+Dh6UaFV 73oRqs64f9s/OEFN7ITC5br24KS/stRTsxpmGugm0w2sQl5gEhCMbZ2Uwfl0Ktt/aPJb 22BxaJ8MRPhwYANKohCuqeRfVG4G6Q4PsJpvbXKTrlH/tbY03MNjpkCRzTla4ZT0i6I9 Nxp+ZWu/1SGPFgfIbdpA58HPydI7lDJjqB1UuzAJ0gYsGlpvLEbbhCR+EQgPOSsg7xM3 5A== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wyvte0bky-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Mar 2024 11:47:54 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42KA8uWY010083; Wed, 20 Mar 2024 11:47:53 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wxvav314r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Mar 2024 11:47:53 +0000 Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42KBlo5N25363084 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Mar 2024 11:47:52 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 695B858063; Wed, 20 Mar 2024 11:47:50 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B67F758058; Wed, 20 Mar 2024 11:47:49 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 20 Mar 2024 11:47:49 +0000 (GMT) From: Stefan Berger 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, lukas@wunner.de, bbhushan2@marvell.com, jarkko@kernel.org, Stefan Berger Subject: [PATCH v7 07/13] crypto: ecc - Add special case for NIST P521 in ecc_point_mult Date: Wed, 20 Mar 2024 07:47:19 -0400 Message-ID: <20240320114725.1644921-8-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240320114725.1644921-1-stefanb@linux.ibm.com> References: <20240320114725.1644921-1-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-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: e4D1qK_SgN5z2ArxzC5VTMfcX8m5yvbR X-Proofpoint-GUID: e4D1qK_SgN5z2ArxzC5VTMfcX8m5yvbR 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-20_08,2024-03-18_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 clxscore=1015 impostorscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403140000 definitions=main-2403200093 In ecc_point_mult use the number of bits of the NIST P521 curve + 2. The change is required specifically for NIST P521 to pass mathematical tests on the public key. Signed-off-by: Stefan Berger Tested-by: Lukas Wunner Reviewed-by: Jarkko Sakkinen --- crypto/ecc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crypto/ecc.c b/crypto/ecc.c index 99d41887c005..ead40b5ebb46 100644 --- a/crypto/ecc.c +++ b/crypto/ecc.c @@ -1320,7 +1320,10 @@ static void ecc_point_mult(struct ecc_point *result, carry = vli_add(sk[0], scalar, curve->n, ndigits); vli_add(sk[1], sk[0], curve->n, ndigits); scalar = sk[!carry]; - num_bits = sizeof(u64) * ndigits * 8 + 1; + if (curve->nbits == 521) /* NIST P521 */ + num_bits = curve->nbits + 2; + else + num_bits = sizeof(u64) * ndigits * 8 + 1; vli_set(rx[1], point->x, ndigits); vli_set(ry[1], point->y, ndigits); -- 2.43.0