From 488e40c0943964492afae4c5ccf2ab36bbf56a0b Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Tue, 12 Nov 2024 00:59:12 +0100 Subject: [PATCH] Make HSM support optional, for static binary support --- Cargo.toml | 7 ++++--- src/hsm/mod.rs | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 73dabb3..b82678a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,8 @@ readme = "README.md" edition = "2021" [features] -default = ["zstd/pkg-config"] # https://github.com/gyscos/zstd-rs/pull/309 +default = ["hsm", "zstd/pkg-config"] # https://github.com/gyscos/zstd-rs/pull/309 +hsm = ["pcsc", "talktosc"] vendored = ["openssl/vendored", "xz2/static"] [dependencies] @@ -46,7 +47,7 @@ oci-spec = { version = "0.7", features = ["image"], default-features = false } once_cell = "1.15.0" openssl = "0.10.60" osshkeys = { version = "0.7", features = ["rustcrypto-cipher"], default-features = false } -pcsc = "2.7.0" +pcsc = { version = "2.7.0", optional = true } peekread = "0.1.1" rcgen = { version = "0.13", features = ["aws_lc_rs"] } regex = "1.7.0" @@ -58,7 +59,7 @@ serde_yaml = "0.9.13" sha1 = "0.10.5" sha2 = "0.10.6" shell-escape = "0.1.5" -talktosc = "0.2" +talktosc = { version = "0.2", optional = true } tar = "0.4.38" tempfile = "3.3.0" termcolor = "1.1.3" diff --git a/src/hsm/mod.rs b/src/hsm/mod.rs index fdbc175..334989f 100644 --- a/src/hsm/mod.rs +++ b/src/hsm/mod.rs @@ -1 +1,13 @@ +#[cfg(feature = "hsm")] pub mod pgp; + +// Expose dummy functions +#[cfg(not(feature = "hsm"))] +pub mod pgp { + use crate::args::HsmAccess; + use crate::errors::*; + + pub fn access(_access: &HsmAccess) -> Result<()> { + bail!("HSM support is not available in this binary"); + } +}