Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1317995rdb; Fri, 16 Feb 2024 11:40:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWhLq+pHvcoRHzXJz4zBPgX/qrFk+Zsfpad1CcpCZ65/Hz5nZCjWV/2kaLq+lpAGWQibr79X3OZKyRzqrQQBC8GWbxGRqzEkGgZ8+XsIw== X-Google-Smtp-Source: AGHT+IG73+z86JQ4lYvfaZbv0IDci3qR9IP+FiOMrMmxW4nt0zIlQfkQH3EPc/sq5hacUafwV1xW X-Received: by 2002:aa7:c6d6:0:b0:563:42c:5868 with SMTP id b22-20020aa7c6d6000000b00563042c5868mr4493059eds.25.1708112439585; Fri, 16 Feb 2024 11:40:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708112439; cv=pass; d=google.com; s=arc-20160816; b=LC6V3QZXFnwYxCQAgiAq3H9MTdIgEU83sNGIPua+lNzRsCE3QsbyQdbTiqJZvBTxfS hpf/7EashbMWxiKvGyGCuVmD1K8tHDaJBZObAhQpP33AZ8wxEf3DJ2suvrpb8A3rukio RQJAHOHtr6G/o8uRmBzyfflByL8ej0lEkMIYjmc9KSFbW28KHoviKlyVFK/Y5H1wUIuJ sOHDoCLCiv1Iram5XHKUydF1qr98dk3C5ZkYd3DRRxU8j46o21fhvKZ+u4Z1t5f45ENc 9zoFPmP6cYfH2gsyiRXEUc2S0Ip11k2N/kVyS16MGF3O6s62Bzj+HLE6VwJ+sxhDMXq0 gtNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:organization:references :in-reply-to:date:cc:to:from:subject:message-id:dkim-signature; bh=S3XNc86fIkfMukvVvTcsnQ6iarjT+k2RqqCdbeeV/AY=; fh=TjBY3+8z1NexdnvviZ1ddlmQaSH2fliQpsoc2HdFKeI=; b=ZRhmE4V2YWrWa5HCb/f0dqHbJuTj5+C904Cr+n4q4UPvRIwPifF4QTPZ4RkcFg0oKb 3UV8LGRTkoNWYoVVpFrkgc7PGt/3AENiNt1Fmxfnm370aiLX8fCp9AT9Tb35p8R/jvS2 W9id1vdpewEI66hrCoxNS9dKBWwhG4bP8Ba8hvPqlp70wae9xPAzKlqrwnAgyPLjCplF zJ9voS96jzpC60pNiiSygB1o7PYSxJDc9OjLMJ0o85kxE+v9TG/BdjJA4SKNr//NOD8v H2efk+Vf6CL9cGMo8ZWTwcuy6nBqTA/J9ej8g3RWRsKGIDNIRw6nMJZ2fm/zj5dXXWWt NaSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IrNflfaR; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-crypto+bounces-2134-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2134-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r13-20020aa7d14d000000b00563de654936si231506edo.40.2024.02.16.11.40.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 11:40:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2134-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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IrNflfaR; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-crypto+bounces-2134-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2134-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 2766D1F22F82 for ; Fri, 16 Feb 2024 19:40:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE91E137C3B; Fri, 16 Feb 2024 19:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IrNflfaR" X-Original-To: linux-crypto@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 D0376133439 for ; Fri, 16 Feb 2024 19:40:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708112430; cv=none; b=OpXp3oGJ12XDD81qCWHEsvXCyUSvZ+2Gh8kqB049I/i1qL8oakcJ7byN1xkrfCOSqc9vqYF9pjzlNcFBDQAA8exaI3NpdP1YKs5mkNzGSQRULEFvOOyhFYHYZy1Wh6q2vjCBx+dLESPzzGNvQAf0UM3VXQ3SuyIZNkjOkw0diJI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708112430; c=relaxed/simple; bh=2kEtxKUR+YXMyVhQ0XNlntdk3ty7ZikevcYC5ACSZCA=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=bduHMa+WASpv1tadHxFfvKaZD0gsYsTcAL+frnHOVbhX48i/UZ1usGdu76vfTobe9+Pijl4wYZyE3sGL/Tm2wNBuDVaDher7drBNn3hcdOdWOpjEJzxUQfncyyui8p4sPhMJHXrResYQ1h10wnNX+1cLK4HGyBrzP2Mk3KE9bXU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IrNflfaR; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708112427; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S3XNc86fIkfMukvVvTcsnQ6iarjT+k2RqqCdbeeV/AY=; b=IrNflfaRxRGcajOh1Bq9ni7C3uh9FZu109RU++bZ/RstL06UK02mgEoxwl8LFW8X5DQX+C oSVrp1x22LfrpM4m4O7VGzlVE7hoB4GD2tiiq17fgcsWorOY+NRTaqHPCoViN5qoZRSNbq xi9STXuqt9AMsoz4FLikgm8YQVLhdls= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-97-gogBN-BqOTyRq4-KHkugbQ-1; Fri, 16 Feb 2024 14:40:25 -0500 X-MC-Unique: gogBN-BqOTyRq4-KHkugbQ-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-42c70b8e409so64291271cf.0 for ; Fri, 16 Feb 2024 11:40:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708112425; x=1708717225; h=mime-version:user-agent:content-transfer-encoding:organization :references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=S3XNc86fIkfMukvVvTcsnQ6iarjT+k2RqqCdbeeV/AY=; b=bWQJSjqnZE295hkrHXrnmaWLVZKvJYyZZ6KufeS6B3teA5V1dH/5uuWUA+lP5f/1Bt jFD3qCEpCQx8iaYNpTtNWv31m8YnxT0Pbf/lvFNFk36BO5AbJEKuC0X0zju4tl0wbYTH NX9e4/GiuoYX6IPAfDxBHppTsMfjkg46sJS3huqLmfczPeHDm65fTBoDZhnOuz2WOZYN KRifAOD6sqGKERlc1cNr2LQt8LD/Ki4nI8gfggTtif0GLxJjhLgfXC0qmi/GvgqMEJtP YjsgXuOyhGulnCaY7W/epNpE4EYeq6AcoGDv+53hpF5vcK2XgFRFXsmjTdhlU06uHZ0Q ljZQ== X-Forwarded-Encrypted: i=1; AJvYcCV4PLndvKfRwKd41SkujS7+1e5HpB1Se3k7GtPQAeN/RIxjKsqs3kqYOoHyrmzTfnuThmQWjynNxyznPwn6avxeYC6dNzLJ07a7uc59 X-Gm-Message-State: AOJu0YytGPEQ8XTLHBvDPgLVLvYI+NyKtmX3t+H/tZfzSLxL4f1TS5X6 3uFVCi43J2N0e+H1Ib7kk2yfZgRfsQXrbZRW1JWkFosbxSk4YDmJSAroCrbO4KtN6Eaz7gc7Ewj xIE5ol5HceD7F+qy/1k86GurfU29Ila05vPueLUcJ8VyOiUG+2VBm9PB7gDZDwg== X-Received: by 2002:ac8:584e:0:b0:42d:ac7d:a334 with SMTP id h14-20020ac8584e000000b0042dac7da334mr10657989qth.33.1708112424920; Fri, 16 Feb 2024 11:40:24 -0800 (PST) X-Received: by 2002:ac8:584e:0:b0:42d:ac7d:a334 with SMTP id h14-20020ac8584e000000b0042dac7da334mr10657964qth.33.1708112424634; Fri, 16 Feb 2024 11:40:24 -0800 (PST) Received: from m8.users.ipa.redhat.com (2603-7000-9400-fe80-0000-0000-0000-0154.res6.spectrum.com. [2603:7000:9400:fe80::154]) by smtp.gmail.com with ESMTPSA id y5-20020ac87c85000000b0042c6c5bc47fsm207931qtv.83.2024.02.16.11.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 11:40:24 -0800 (PST) Message-ID: Subject: Re: [PATCH v2 00/14] Add support for NIST P521 to ecdsa and ecdh From: Simo Sorce To: Stefan Berger , 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 Date: Fri, 16 Feb 2024 14:40:23 -0500 In-Reply-To: References: <20240215231414.3857320-1-stefanb@linux.ibm.com> <3bdb1c9e0ac35c7dc3fbba1233bc7df80ac466a2.camel@redhat.com> Organization: Red Hat Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2024-02-16 at 14:32 -0500, Stefan Berger wrote: >=20 > On 2/16/24 14:27, Simo Sorce wrote: > > On Thu, 2024-02-15 at 18:13 -0500, Stefan Berger wrote: > > > This series of patches adds support for the NIST P521 curve to ecdsa = and > > > ecdh. Test cases for NIST P521 are added to both modules. > > >=20 > > > An issue with the current code in ecdsa and ecdh is that it assumes t= hat > > > input arrays providing key coordinates for example, are arrays of dig= its > > > (a 'digit' is a 'u64'). This works well for all currently supported > > > curves, such as NIST P192/256/384, but does not work for NIST P521 wh= ere > > > coordinates are 8 digits + 2 bytes long. So some of the changes deal = with > > > converting byte arrays to digits and digits to byte arrays. > > >=20 > > >=20 > > > Regards, > > > Stefan > > >=20 > > > v2: > > > - Reformulated some patch descriptions > > > - Fixed issue detected by krobot > > > - Some other small changes to the code > > >=20 > > > Stefan Berger (14): > > > crypto: ecdsa - Convert byte arrays with key coordinates to digits > > > crypto: ecdsa - Adjust tests on length of key parameters > > > crypto: ecdsa - Extend res.x mod n calculation for NIST P521 > > > crypto: ecc - Implement vli_mmod_fast_521 for NIST p521 > > > crypto: ecc - For NIST P521 use vli_num_bits to get number of bits > > > crypto: ecc - Add NIST P521 curve parameters > > > crypto: ecdsa - Register NIST P521 and extend test suite > > > x509: Add OID for NIST P521 and extend parser for it > > > crypto: ecdh - Use properly formatted digits to check for valid ke= y > > > crypto: ecc - Implement ecc_digits_to_bytes to convert digits to b= yte > > > array > > > crypto: Add nbits field to ecc_curve structure > > > crypto: ecc - Implement and use ecc_curve_get_nbytes to get curve'= s > > > nbytes > > > crypto: ecdh - Use functions to copy digits from and to byte array > > > crypto: ecdh - Add support for NIST P521 and add test case > > >=20 > > > crypto/asymmetric_keys/x509_cert_parser.c | 3 + > > > crypto/ecc.c | 71 +++++-- > > > crypto/ecc_curve_defs.h | 45 +++++ > > > crypto/ecdh.c | 59 +++++- > > > crypto/ecdsa.c | 48 ++++- > > > crypto/testmgr.c | 14 ++ > > > crypto/testmgr.h | 225 +++++++++++++++++++= +++ > > > include/crypto/ecc_curve.h | 3 + > > > include/crypto/ecdh.h | 1 + > > > include/crypto/internal/ecc.h | 61 +++++- > > > include/linux/oid_registry.h | 1 + > > > 11 files changed, 495 insertions(+), 36 deletions(-) > >=20 > > Hi Stefan, > > what kind of side-channel testing was performed on this code? > > And what is the use case you are adding it for? >=20 > We're using public keys for signature verification. I am not aware that > public key usage is critical to side channels. >=20 > The use case for adding it is primarily driven by closing a gap to=20 > complete the support for the common ECDSA NIST curves. Is there an assumption the ECDH code uses exclusively ephemeral keys? Simo. --=20 Simo Sorce Distinguished Engineer RHEL Crypto Team Red Hat, Inc