From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id C63CD1FF13A for ; Wed, 01 Apr 2026 09:55:54 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1D8F610FFA; Wed, 1 Apr 2026 09:56:17 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox 01/20] pbs-api-types: define encryption key type and schema Date: Wed, 1 Apr 2026 09:55:02 +0200 Message-ID: <20260401075521.176354-2-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260401075521.176354-1-c.ebner@proxmox.com> References: <20260401075521.176354-1-c.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1775030085905 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.438 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 5W4UPBRGK2WONNA6SUSCEL2ZOLWST2H3 X-Message-ID-Hash: 5W4UPBRGK2WONNA6SUSCEL2ZOLWST2H3 X-MailFrom: c.ebner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Will be used to store and uniquly identify encryption keys in the config. Contains the KeyInfo extended by the unique key identifier. Signed-off-by: Christian Ebner --- pbs-api-types/src/key_derivation.rs | 34 ++++++++++++++++++++++++++--- pbs-api-types/src/lib.rs | 2 +- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/pbs-api-types/src/key_derivation.rs b/pbs-api-types/src/key_derivation.rs index 57ae353a..2a986c21 100644 --- a/pbs-api-types/src/key_derivation.rs +++ b/pbs-api-types/src/key_derivation.rs @@ -3,12 +3,13 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "enum-fallback")] use proxmox_fixed_string::FixedString; -use proxmox_schema::api; +use proxmox_schema::api_types::SAFE_ID_FORMAT; +use proxmox_schema::{api, Schema, StringSchema, Updater}; use crate::CERT_FINGERPRINT_SHA256_SCHEMA; #[api(default: "scrypt")] -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)] #[serde(rename_all = "lowercase")] /// Key derivation function for password protected encryption keys. pub enum Kdf { @@ -41,7 +42,7 @@ impl Default for Kdf { }, }, )] -#[derive(Deserialize, Serialize)] +#[derive(Clone, Default, Deserialize, Serialize, Updater, PartialEq)] /// Encryption Key Information pub struct KeyInfo { /// Path to key (if stored in a file) @@ -59,3 +60,30 @@ pub struct KeyInfo { #[serde(skip_serializing_if = "Option::is_none")] pub hint: Option, } + +/// ID to uniquely identify an encryption key. +pub const ENCRYPTION_KEY_ID_SCHEMA: Schema = + StringSchema::new("ID to uniquely identify encryption key") + .format(&SAFE_ID_FORMAT) + .min_length(3) + .max_length(32) + .schema(); + +#[api( + properties: { + id: { + schema: ENCRYPTION_KEY_ID_SCHEMA, + }, + info: { + type: KeyInfo, + }, + }, +)] +#[derive(Clone, Default, Deserialize, Serialize, Updater, PartialEq)] +/// Encryption Key Information +pub struct EncryptionKey { + #[updater(skip)] + pub id: String, + #[serde(flatten)] + pub info: KeyInfo, +} diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs index 54547291..ddd5840e 100644 --- a/pbs-api-types/src/lib.rs +++ b/pbs-api-types/src/lib.rs @@ -104,7 +104,7 @@ mod jobs; pub use jobs::*; mod key_derivation; -pub use key_derivation::{Kdf, KeyInfo}; +pub use key_derivation::{EncryptionKey, Kdf, KeyInfo, ENCRYPTION_KEY_ID_SCHEMA}; mod maintenance; pub use maintenance::*; -- 2.47.3