mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-07 13:33:17 +00:00
api-types: move RsaPubKeyInfo to pbs-client
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>
This commit is contained in:
parent
fb3fe5561e
commit
588001cf8d
@ -21,4 +21,3 @@ proxmox-uuid = { version = "1.0.0", features = [ "serde" ] }
|
|||||||
|
|
||||||
[target.'cfg(not(target_arch="wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch="wasm32"))'.dependencies]
|
||||||
proxmox-sys = "0.2" # only needed for nodename()??
|
proxmox-sys = "0.2" # only needed for nodename()??
|
||||||
openssl = "0.10"
|
|
||||||
|
@ -312,39 +312,6 @@ pub const PASSWORD_HINT_SCHEMA: Schema = StringSchema::new("Password hint.")
|
|||||||
.schema();
|
.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()]
|
#[api()]
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "PascalCase")]
|
#[serde(rename_all = "PascalCase")]
|
||||||
|
Loading…
Reference in New Issue
Block a user