From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 82752605AA for ; Wed, 12 Jan 2022 14:52:49 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 79BB824E8 for ; Wed, 12 Jan 2022 14:52:19 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id CAD2124D5 for ; Wed, 12 Jan 2022 14:52:18 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id AA89146C88 for ; Wed, 12 Jan 2022 14:52:18 +0100 (CET) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Wed, 12 Jan 2022 14:52:09 +0100 Message-Id: <20220112135210.1698733-2-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220112135210.1698733-1-f.gruenbichler@proxmox.com> References: <20220112135210.1698733-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -1.380 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% ENA_SUBJ_ODD_CASE 3.2 Subject has odd case KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup 1/2] api-types: move RsaPubKeyInfo to pbs-client X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2022 13:52:49 -0000 it's the only thing requiring openssl in pbs-api-types, and it's only used by the client to pretty-print the 'master' key, which is client-specific. Signed-off-by: Fabian Grünbichler --- pbs-api-types/Cargo.toml | 1 - pbs-api-types/src/lib.rs | 33 ---------------------------- proxmox-backup-client/src/key.rs | 37 +++++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/pbs-api-types/Cargo.toml b/pbs-api-types/Cargo.toml index b40a707c..09107ace 100644 --- a/pbs-api-types/Cargo.toml +++ b/pbs-api-types/Cargo.toml @@ -21,4 +21,3 @@ proxmox-uuid = { version = "1.0.0", features = [ "serde" ] } [target.'cfg(not(target_arch="wasm32"))'.dependencies] proxmox-sys = "0.2" # only needed for nodename()?? -openssl = "0.10" diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs index 0a0dd33d..26bef33d 100644 --- a/pbs-api-types/src/lib.rs +++ b/pbs-api-types/src/lib.rs @@ -312,39 +312,6 @@ pub const PASSWORD_HINT_SCHEMA: Schema = StringSchema::new("Password hint.") .schema(); -#[api] -#[derive(Deserialize, Serialize)] -/// RSA public key information -pub struct RsaPubKeyInfo { - /// Path to key (if stored in a file) - #[serde(skip_serializing_if="Option::is_none")] - pub path: Option, - /// RSA exponent - pub exponent: String, - /// Hex-encoded RSA modulus - pub modulus: String, - /// Key (modulus) length in bits - pub length: usize, -} - -#[cfg(not(target_arch="wasm32"))] -impl std::convert::TryFrom> for RsaPubKeyInfo { - type Error = anyhow::Error; - - fn try_from(value: openssl::rsa::Rsa) -> Result { - let modulus = value.n().to_hex_str()?.to_string(); - let exponent = value.e().to_dec_str()?.to_string(); - let length = value.size() as usize * 8; - - Ok(Self { - path: None, - exponent, - modulus, - length, - }) - } -} - #[api()] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "PascalCase")] diff --git a/proxmox-backup-client/src/key.rs b/proxmox-backup-client/src/key.rs index 427a58df..288d6c67 100644 --- a/proxmox-backup-client/src/key.rs +++ b/proxmox-backup-client/src/key.rs @@ -2,6 +2,7 @@ use std::convert::TryFrom; use std::path::PathBuf; use anyhow::{bail, format_err, Error}; +use serde::{Deserialize, Serialize}; use serde_json::Value; use proxmox_sys::linux::tty; @@ -13,7 +14,7 @@ use proxmox_router::cli::{ }; use proxmox_schema::{api, ApiType, ReturnType}; -use pbs_api_types::{RsaPubKeyInfo, PASSWORD_HINT_SCHEMA, Kdf, KeyInfo}; +use pbs_api_types::{PASSWORD_HINT_SCHEMA, Kdf, KeyInfo}; use pbs_config::key_config::{KeyConfig, rsa_decrypt_key_config}; use pbs_datastore::paperkey::{generate_paper_key, PaperkeyFormat}; use pbs_client::tools::key_source::{ @@ -21,6 +22,40 @@ use pbs_client::tools::key_source::{ place_default_encryption_key, place_default_master_pubkey, }; +#[api] +#[derive(Deserialize, Serialize)] +/// RSA public key information +pub struct RsaPubKeyInfo { + /// Path to key (if stored in a file) + #[serde(skip_serializing_if="Option::is_none")] + pub path: Option, + /// RSA exponent + pub exponent: String, + /// Hex-encoded RSA modulus + pub modulus: String, + /// Key (modulus) length in bits + pub length: usize, +} + +#[cfg(not(target_arch="wasm32"))] +impl std::convert::TryFrom> for RsaPubKeyInfo { + type Error = anyhow::Error; + + fn try_from(value: openssl::rsa::Rsa) -> Result { + let modulus = value.n().to_hex_str()?.to_string(); + let exponent = value.e().to_dec_str()?.to_string(); + let length = value.size() as usize * 8; + + Ok(Self { + path: None, + exponent, + modulus, + length, + }) + } +} + + #[api( input: { properties: { -- 2.30.2