From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/2] api-types: move RsaPubKeyInfo to pbs-client
Date: Wed, 12 Jan 2022 14:52:09 +0100 [thread overview]
Message-ID: <20220112135210.1698733-2-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20220112135210.1698733-1-f.gruenbichler@proxmox.com>
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 <f.gruenbichler@proxmox.com>
---
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<String>,
- /// 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<openssl::rsa::Rsa<openssl::pkey::Public>> for RsaPubKeyInfo {
- type Error = anyhow::Error;
-
- fn try_from(value: openssl::rsa::Rsa<openssl::pkey::Public>) -> Result<Self, Self::Error> {
- 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<String>,
+ /// 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<openssl::rsa::Rsa<openssl::pkey::Public>> for RsaPubKeyInfo {
+ type Error = anyhow::Error;
+
+ fn try_from(value: openssl::rsa::Rsa<openssl::pkey::Public>) -> Result<Self, Self::Error> {
+ 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
next prev parent reply other threads:[~2022-01-12 13:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-12 13:52 [pbs-devel] [PATCH proxmox-backup 0/2] reduce pbs-api-types deps Fabian Grünbichler
2022-01-12 13:52 ` Fabian Grünbichler [this message]
2022-01-12 13:52 ` [pbs-devel] [PATCH proxmox-backup 2/2] api-types: relax NODENAME_SCHEMA Fabian Grünbichler
2022-01-14 5:30 ` [pbs-devel] applied-series: [PATCH proxmox-backup 0/2] reduce pbs-api-types deps Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220112135210.1698733-2-f.gruenbichler@proxmox.com \
--to=f.gruenbichler@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.