From nobody Sat Apr 27 10:35:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640096734; cv=none; d=zohomail.com; s=zohoarc; b=bcDIiAv9eMnhQSaWrakovOyp8vbQcITC44BMsALL/fr8uMdL1nIu1Z27yMvokiO87mdvm4aKJgcTCvlhXwr69dj8ydWmF4+UJawuV3Hd8RGRNIPlDd+7zEqd2KPtqcATzwFVANdoCnluk9J43R9rB2uOzhoNczVaSDhiqCnhkzA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640096734; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bVsv+1xk0Yrh2Yf8q5IZmgX2pwXK8Nhh6x8qS7zNFaQ=; b=RRjzpYTynVoR1DDSD4bRT5XCkMQonXey5LOTG+oqIxJQus9BjZn21k7RS6BcBybyUHVbD32MshFnRFoKw8FP26WWP6ZNjxwpjYKb8bPowXL82YvE6wGtBd3nR8wCF+TLVUUvLP6NDIQnqUuNWUYN+t/uE3TBNRbhrNwdSEQEcHE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1640096734278716.0627857909122; Tue, 21 Dec 2021 06:25:34 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-91-Hs_ZZmK4OE250oFUMhUUlA-1; Tue, 21 Dec 2021 09:25:31 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 159B985EE62; Tue, 21 Dec 2021 14:25:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC58F519C8; Tue, 21 Dec 2021 14:25:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BAABC1809CBF; Tue, 21 Dec 2021 14:25:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BLENOBc007775 for ; Tue, 21 Dec 2021 09:23:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5FF9D7B015; Tue, 21 Dec 2021 14:23:24 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0D7078DFF for ; Tue, 21 Dec 2021 14:23:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640096733; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bVsv+1xk0Yrh2Yf8q5IZmgX2pwXK8Nhh6x8qS7zNFaQ=; b=Q7Sp2/6n4lQkMwT56yjjCNnQVrPA1l8s5a16AxtnEdF3NqRzUqoF2yuD+wdKFWYpfviWDI jP1ZST+67vE4qgFQnQx6K4XQQM/8eN54rK5oukG1csgbGCs5UkKf3DlzLJrw3xsP7AewMM dM0C54TXYjh1SbmOBb2oj7tz+90T5bU= X-MC-Unique: Hs_ZZmK4OE250oFUMhUUlA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] virnettlscontext: Drop gnutls_dh_set_prime_bits() Date: Tue, 21 Dec 2021 15:22:58 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640096734802100001 Content-Type: text/plain; charset="utf-8" According to the gnutls_dh_set_prime_bits() manpage: The function has no effect in server side. Therefore, don't call it when creating server side context. Signed-off-by: Michal Privoznik Reviewed-by: Ani Sinha --- src/rpc/virnettlscontext.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c index 1a3dd92676..3b6687e7f4 100644 --- a/src/rpc/virnettlscontext.c +++ b/src/rpc/virnettlscontext.c @@ -1233,8 +1233,6 @@ virNetTLSSession *virNetTLSSessionNew(virNetTLSContex= t *ctxt, */ if (ctxt->isServer) { gnutls_certificate_server_set_request(sess->session, GNUTLS_CERT_R= EQUEST); - - gnutls_dh_set_prime_bits(sess->session, DH_BITS); } =20 gnutls_transport_set_ptr(sess->session, sess); --=20 2.32.0 From nobody Sat Apr 27 10:35:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640096684; cv=none; d=zohomail.com; s=zohoarc; b=filfCkiwkga9yAa4s5SRHmd52QLZE9mtFOm2QO+tql3Ozhb6VzxqXuANC4yN9KUnqLo/cTMQQyo/i0Fb8cOLybCsuH6U3hnp/yAelI8cB0IBiYYNEmxwDZiR/ZCnmq2XOF863OEbFY+CM/N6OeDkV1H/mSpV6iD7lUEAzgIhptM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640096684; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=B/xtnnMgG7fJBPoKDSiXspgETCT2hz/Mo8iJqOZv/Iw=; b=l25ZqFQOlAH68k5TPnyRTAqGkcZHDtp1Etl+7lvIriTFrIT5ltREmbvXLcymdnHDRG2QTlQ4hlPPlGXtefUg7CNH9pfV0IepulGRPOn5ihT/RU6iRrMS7710jlPWW9cYnDCdhbP2kL2DEli+JPESJGGL4IWV5u4u0JpzNrStfrk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1640096684894306.83301888912536; Tue, 21 Dec 2021 06:24:44 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-31-W7zk0buqN3ycQkOg3BUqhw-1; Tue, 21 Dec 2021 09:24:40 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70757801B25; Tue, 21 Dec 2021 14:24:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 617334BC70; Tue, 21 Dec 2021 14:24:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 25E1F4BB7C; Tue, 21 Dec 2021 14:24:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BLENf4S007796 for ; Tue, 21 Dec 2021 09:23:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id A721C7EBC9; Tue, 21 Dec 2021 14:23:40 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 082C37D4B0 for ; Tue, 21 Dec 2021 14:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640096683; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=B/xtnnMgG7fJBPoKDSiXspgETCT2hz/Mo8iJqOZv/Iw=; b=FLsrh9HzNplWZG4TFVzHuo910YBA7B+CKzMUkue4SZJmCLxQtAfHsGr4hKwzI/UrQWHcjS YMCL/zHWcsLJNalHMoix3gsya9/2FxOn4rWUXnUbDNP1bXKMLwuuhdbQIlGi9efTEIYaLX VhQBnXU7Qccu4Kx9d4c6M5CrbPPsBwU= X-MC-Unique: W7zk0buqN3ycQkOg3BUqhw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] virnettlscontext: Don't pass static key length to gnutls_dh_params_generate2() Date: Tue, 21 Dec 2021 15:22:59 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640096686819100001 Content-Type: text/plain; charset="utf-8" As encryption norms get more strict it's easy to fall on the insecure side. For instance, so far we are generating 2048 bits long prime for Diffie-Hellman keys. Some systems consider this not long enough. While we may just keep increasing the value passed to the corresponding gnutls_* function, that is not well maintainable. Instead, we may do what's recommended in the gnutls_* manpage. From gnutls_dh_params_generate2(3): It is recommended not to set the number of bits directly, but use gnutls_sec_param_to_pk_bits() instead. Looking into the gnutls_sec_param_to_pk_bits() then [1], 2048 bits corresponds to parameter MEDIUM. Therefore, we want to chose the next size (HIGH) to be future proof. 1: https://www.gnutls.org/manual/gnutls.html#tab_003akey_002dsizes Signed-off-by: Michal Privoznik Reviewed-by: Ani Sinha Reviewed-by: J=C3=A1n Tomko --- src/rpc/virnettlscontext.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c index 3b6687e7f4..f0b1e8f9c1 100644 --- a/src/rpc/virnettlscontext.c +++ b/src/rpc/virnettlscontext.c @@ -38,8 +38,6 @@ #include "virthread.h" #include "configmake.h" =20 -#define DH_BITS 2048 - #define LIBVIRT_PKI_DIR SYSCONFDIR "/pki" #define LIBVIRT_CACERT LIBVIRT_PKI_DIR "/CA/cacert.pem" #define LIBVIRT_CACRL LIBVIRT_PKI_DIR "/CA/cacrl.pem" @@ -718,6 +716,15 @@ static virNetTLSContext *virNetTLSContextNew(const cha= r *cacert, * security requirements. */ if (isServer) { + unsigned int bits =3D 0; + + bits =3D gnutls_sec_param_to_pk_bits(GNUTLS_PK_DH, GNUTLS_SEC_PARA= M_HIGH); + if (bits =3D=3D 0) { + virReportError(VIR_ERR_SYSTEM_ERROR, "%s", + _("Unable to get key length for diffie-hellman = parameters")); + goto error; + } + err =3D gnutls_dh_params_init(&ctxt->dhParams); if (err < 0) { virReportError(VIR_ERR_SYSTEM_ERROR, @@ -725,7 +732,7 @@ static virNetTLSContext *virNetTLSContextNew(const char= *cacert, gnutls_strerror(err)); goto error; } - err =3D gnutls_dh_params_generate2(ctxt->dhParams, DH_BITS); + err =3D gnutls_dh_params_generate2(ctxt->dhParams, bits); if (err < 0) { virReportError(VIR_ERR_SYSTEM_ERROR, _("Unable to generate diffie-hellman parameters= : %s"), --=20 2.32.0