From nobody Fri Dec 12 14:05:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1764228757; cv=none; d=zohomail.com; s=zohoarc; b=QcETRr9LEYBmuI4H4BPEVg3g3tFFzAsZtZvsGoMIArM231BLxv1yNmgzKdkiMuwngGy5H41pZgcJpSSfRy70SgZFpiv8oMp3beHfUDZnSBaWIacdMYsCwijR3tx9pZfEUYZFO14ntVdGcpmbLgDRz0Vq2gIlc14bCEu9+VsmphQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1764228757; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=lA0uZitrNVtHHY1KGKd3uXjNLwxTN92r80ylLtcDuSw=; b=hcJuU74h+kdWR2i/O4c4tQozt8w622/lGV6+/xCg0EsI/VOB2pQo0UojhBIi8nqLS2OcNe0jDiPH+Sec0Pz9yV+TzpxhlmhwTUEEacAzNj1u7i+OdCC1PZfzw1ftTTppZNpt5kePmvTuYqhUlx582ayBj2PHBo1W9DeICY2f5CI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 17642287575741005.3279417814666; Wed, 26 Nov 2025 23:32:37 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 08DA8418CE; Thu, 27 Nov 2025 02:32:36 -0500 (EST) Received: from [172.19.199.74] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id B4EFB44C5A; Thu, 27 Nov 2025 02:28:57 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id C93E6442E2; Thu, 27 Nov 2025 02:22:53 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id C1A5843E80 for ; Thu, 27 Nov 2025 02:22:51 -0500 (EST) Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-1M3s--XaMHybaIG-IBLfbg-1; Thu, 27 Nov 2025 02:22:48 -0500 Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-297f3710070so12104355ad.2 for ; Wed, 26 Nov 2025 23:22:47 -0800 (PST) Received: from armenon-kvm.armenon-thinkpadp16vgen1.bengluru.csb ([49.47.195.90]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29bce478762sm7801695ad.45.2025.11.26.23.22.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 23:22:45 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764228171; 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=lA0uZitrNVtHHY1KGKd3uXjNLwxTN92r80ylLtcDuSw=; b=O9/mEPNzPAik6kwrC1sHlvNKvz9p97Kyt9Hz3XbEW9XufFaFai0geE2yXy4nVOUDp1CJnu LN33AzDigJLHsm1qjXkkZ6pFemqcFC3jtMqBopbnbr40zU6maDaU579tY3pSOVEo+zKhh4 bD/kHfhG+qKZsK/2evVB86kOge43AHA= X-MC-Unique: 1M3s--XaMHybaIG-IBLfbg-1 X-Mimecast-MFC-AGG-ID: 1M3s--XaMHybaIG-IBLfbg_1764228167 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764228167; x=1764832967; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lA0uZitrNVtHHY1KGKd3uXjNLwxTN92r80ylLtcDuSw=; b=BO26ZOixaOsbYM55aTqKdgEF7AZfpI526oaA3eZuZyxGpA0anc3pl+ryDua2t/4fcU c61ztIrcqGB0ui6BGYEl1TYc1pFG8QpK/6LZHKG1PLehbikGJj7oRWrfxfCBoctgqwqy NsLeH9/A8LHqVKLyk8XsPqfMFBfYXP0FGU1kjxLgS7pZwrPDS30s7IfDej0oLVCpepJs KgCr9OjbLQhTL4IaEU7ihV9nRUOETLwD4Led+viMObTsCXqFqdetJeqq6lA7Ye9ySekU IBU80VwWJn5073QSlXtiBw8QBiXXJab5qfIoUO+Rs3HSBSMkhyH/Wyf3Y8OE6Bx8re1c kJMA== X-Gm-Message-State: AOJu0Yzm4UHj/W3pOCOz/H1ACBHTpSdZdD9zxOowMq/52HZn2Bb99KTU SxculGKkP8dCkx3sLzM42HFMq+DzPITyTN3iNQ+rBfNS2rFOmuJ/xKFl2xArQOdm2/siKSG7iLJ Y2qulch0Az4MFbN3/OXwDuErA5Tm26k0m4zH8KG+6SHHsZhcn9Dagk6rnaNe8GiAPlwxDFOrjez 3qhP/rUXaoH0H4U04IICvzYtrlpR6Nk9/HBRYrzZDzZQ== X-Gm-Gg: ASbGncvso0vFBGU4zPypc3ZQXPymbixGCgoiDMfTwT3RW2mBxyWOMnS+sA7ZCMED/DJ XnQ+GOX68LmkwU1yJZ066exjLGmVOSefE3Aikh6Bau+7pGUaI4moQSAkw6P3ovi+63nbLkbBd0f ZVs/ZbuwRYMdNIrXNH6qtSTBT9tYuYdVTlDnMYUktpLfFOAOxMpK8+MBPiLVnGkpyIxzQ09Jnxz 7EERR0Pubik69w3bAfbV+UsZqO49klgoX8HcucmjDU8NArnvBo8EsxQitYKgdrSrT1G4F1h1tTI ZHTlPWCRikdFU1smbdOOPjWUK9ikSO+xH1sT7uyhCFylOR1N/cQoXQB1WiApFsMuSGyuusLLhAY fAnTsnjwmytZ97hGxyxBHVpDvOBYFvsdmjMuohFamBNOhcwniuyjZO/Mi X-Received: by 2002:a17:903:11cd:b0:295:1e50:e7cb with SMTP id d9443c01a7336-29b6c514f0amr242844335ad.23.1764228166782; Wed, 26 Nov 2025 23:22:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxF/ZHJUnXZsKW5H68ux1xasg03b0eRJy9x27u4uTLcGTo03F8wi/3wNvNVKkGyhe6jpvspA== X-Received: by 2002:a17:903:11cd:b0:295:1e50:e7cb with SMTP id d9443c01a7336-29b6c514f0amr242844085ad.23.1764228166212; Wed, 26 Nov 2025 23:22:46 -0800 (PST) To: devel@lists.libvirt.org Subject: [RFC v3 4/5] secret: Add encryptionSchemeType attribute to store ciphers Date: Thu, 27 Nov 2025 12:52:31 +0530 Message-ID: <20251127072232.38426-5-armenon@redhat.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251127072232.38426-1-armenon@redhat.com> References: <20251127072232.38426-1-armenon@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: W1_2prx8soURbFq7WoJn09Y0KpDcXjkhy7oPAacwRr0_1764228167 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6LISX7VO4NH6IQBRQNLSTSQUMN7M55XI X-Message-ID-Hash: 6LISX7VO4NH6IQBRQNLSTSQUMN7M55XI X-MailFrom: armenon@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Arun Menon X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Arun Menon via Devel Reply-To: Arun Menon X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1764228762575019200 Content-Type: text/plain; charset="utf-8"; x-default="true" The new attribute will store the available ciphers with which secrets can be encrypted. At the moment only aes256cbc encryption method is used. This can be extended in future. Rename the file name structure attribute from base64File to secretValueFile. Signed-off-by: Arun Menon --- include/libvirt/libvirt-secret.h | 20 ++++++++++++++++++++ src/conf/secret_conf.h | 1 + src/conf/virsecretobj.c | 22 +++++++++++----------- src/util/virsecret.c | 4 ++++ src/util/virsecret.h | 1 + 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/include/libvirt/libvirt-secret.h b/include/libvirt/libvirt-sec= ret.h index 761437d4ad..768c92c10c 100644 --- a/include/libvirt/libvirt-secret.h +++ b/include/libvirt/libvirt-secret.h @@ -70,6 +70,26 @@ typedef enum { # endif } virSecretUsageType; =20 +/** + * virSecretEncryptionSchemeType: + * + * Since: 11.10.0 + */ +typedef enum { + VIR_SECRET_ENCRYPTION_SCHEME_NONE =3D 0, /* (Since: 11.10.0) */ + VIR_SECRET_ENCRYPTION_SCHEME_AES256CBC =3D 1, /* (Since: 11.10.0) */ +# ifdef VIR_ENUM_SENTINELS + VIR_SECRET_ENCRYPTION_SCHEME_LAST + /* + * NB: this enum value will increase over time as new encryption schem= es are + * added to the libvirt API. It reflects the last enncryption scheme s= upported + * by this version of the libvirt API. + * + * Since: 11.10.0 + */ +# endif +} virSecretEncryptionSchemeType; + virConnectPtr virSecretGetConnect (virSecretPtr secret); int virConnectNumOfSecrets (virConnectPtr conn); int virConnectListSecrets (virConnectPtr conn, diff --git a/src/conf/secret_conf.h b/src/conf/secret_conf.h index 8f8f47933a..a12bc8e095 100644 --- a/src/conf/secret_conf.h +++ b/src/conf/secret_conf.h @@ -30,6 +30,7 @@ struct _virSecretDef { char *description; /* May be NULL */ virSecretUsageType usage_type; char *usage_id; /* May be NULL */ + virSecretEncryptionSchemeType encryption_scheme; /* virSecretEncryptio= nSchemeType */ }; =20 void virSecretDefFree(virSecretDef *def); diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index 66270e2751..a3dd7983bb 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -39,7 +39,7 @@ VIR_LOG_INIT("conf.virsecretobj"); struct _virSecretObj { virObjectLockable parent; char *configFile; - char *base64File; + char *secretValueFile; virSecretDef *def; unsigned char *value; /* May be NULL */ size_t value_size; @@ -139,7 +139,7 @@ virSecretObjDispose(void *opaque) g_free(obj->value); } g_free(obj->configFile); - g_free(obj->base64File); + g_free(obj->secretValueFile); } =20 =20 @@ -378,11 +378,11 @@ virSecretObjListAdd(virSecretObjList *secrets, if (!(obj =3D virSecretObjNew())) goto cleanup; =20 - /* Generate the possible configFile and base64File strings + /* Generate the possible configFile and secretValueFile strings * using the configDir, uuidstr, and appropriate suffix */ if (!(obj->configFile =3D virFileBuildPath(configDir, uuidstr, ".x= ml")) || - !(obj->base64File =3D virFileBuildPath(configDir, uuidstr, ".b= ase64"))) + !(obj->secretValueFile =3D virFileBuildPath(configDir, uuidstr= , ".base64"))) goto cleanup; =20 if (virHashAddEntry(secrets->objs, uuidstr, obj) < 0) @@ -656,7 +656,7 @@ virSecretObjDeleteData(virSecretObj *obj) { /* The configFile will already be removed, so secret won't be * loaded again if this fails */ - unlink(obj->base64File); + unlink(obj->secretValueFile); } =20 =20 @@ -691,7 +691,7 @@ virSecretObjSaveData(virSecretObj *obj) =20 base64 =3D g_base64_encode(obj->value, obj->value_size); =20 - if (virFileRewriteStr(obj->base64File, S_IRUSR | S_IWUSR, base64) < 0) + if (virFileRewriteStr(obj->secretValueFile, S_IRUSR | S_IWUSR, base64)= < 0) return -1; =20 return 0; @@ -813,26 +813,26 @@ virSecretLoadValue(virSecretObj *obj) struct stat st; g_autofree char *contents =3D NULL; =20 - if ((fd =3D open(obj->base64File, O_RDONLY)) =3D=3D -1) { + if ((fd =3D open(obj->secretValueFile, O_RDONLY)) =3D=3D -1) { if (errno =3D=3D ENOENT) { ret =3D 0; goto cleanup; } virReportSystemError(errno, _("cannot open '%1$s'"), - obj->base64File); + obj->secretValueFile); goto cleanup; } =20 if (fstat(fd, &st) < 0) { virReportSystemError(errno, _("cannot stat '%1$s'"), - obj->base64File); + obj->secretValueFile); goto cleanup; } =20 if ((size_t)st.st_size !=3D st.st_size) { virReportError(VIR_ERR_INTERNAL_ERROR, _("'%1$s' file does not fit in memory"), - obj->base64File); + obj->secretValueFile); goto cleanup; } =20 @@ -845,7 +845,7 @@ virSecretLoadValue(virSecretObj *obj) =20 if (saferead(fd, contents, st.st_size) !=3D st.st_size) { virReportSystemError(errno, _("cannot read '%1$s'"), - obj->base64File); + obj->secretValueFile); goto cleanup; } contents[st.st_size] =3D '\0'; diff --git a/src/util/virsecret.c b/src/util/virsecret.c index 8e74df3b93..c9d9cf2c8a 100644 --- a/src/util/virsecret.c +++ b/src/util/virsecret.c @@ -36,6 +36,10 @@ VIR_ENUM_IMPL(virSecretUsage, VIR_SECRET_USAGE_TYPE_LAST, "none", "volume", "ceph", "iscsi", "tls", "vtpm", ); +VIR_ENUM_IMPL(virSecretEncryptionScheme, + VIR_SECRET_ENCRYPTION_SCHEME_LAST, + "none", "aes256cbc", +); =20 void virSecretLookupDefClear(virSecretLookupTypeDef *def) diff --git a/src/util/virsecret.h b/src/util/virsecret.h index c803f0fe33..01998e307d 100644 --- a/src/util/virsecret.h +++ b/src/util/virsecret.h @@ -27,6 +27,7 @@ #include "virenum.h" =20 VIR_ENUM_DECL(virSecretUsage); +VIR_ENUM_DECL(virSecretEncryptionScheme); =20 typedef enum { VIR_SECRET_LOOKUP_TYPE_NONE, --=20 2.51.1