feat: v0.10.4, add feature with-sequoia-openpgp

This commit is contained in:
2024-09-07 19:32:26 +08:00
parent 8ec07eb01a
commit a61782e3fe
4 changed files with 30 additions and 10 deletions

View File

@@ -21,11 +21,13 @@ mod cmd_u2fsign;
mod cmd_rsaencrypt;
mod cmd_rsadecrypt;
mod cmd_rsaverify;
#[cfg(feature = "with-sequoia-openpgp")]
mod cmd_pgp;
mod cmd_pgpcardadmin;
mod cmd_pgpcardlist;
mod cmd_pgpcardsign;
mod cmd_pgpcarddecrypt;
#[cfg(feature = "with-sequoia-openpgp")]
mod cmd_pgpcardmake;
mod cmd_piv;
mod cmd_pivsummary;
@@ -86,11 +88,13 @@ fn inner_main() -> CommandError {
Box::new(cmd_rsaencrypt::CommandImpl),
Box::new(cmd_rsadecrypt::CommandImpl),
Box::new(cmd_rsaverify::CommandImpl),
#[cfg(feature = "with-sequoia-openpgp")]
Box::new(cmd_pgp::CommandImpl),
Box::new(cmd_pgpcardadmin::CommandImpl),
Box::new(cmd_pgpcardlist::CommandImpl),
Box::new(cmd_pgpcardsign::CommandImpl),
Box::new(cmd_pgpcarddecrypt::CommandImpl),
#[cfg(feature = "with-sequoia-openpgp")]
Box::new(cmd_pgpcardmake::CommandImpl),
Box::new(cmd_piv::CommandImpl),
Box::new(cmd_pivsummary::CommandImpl),
@@ -114,10 +118,20 @@ fn inner_main() -> CommandError {
Box::new(cmd_signfile::CommandImpl),
Box::new(cmd_verifyfile::CommandImpl),
];
let mut features = vec![];
#[cfg(feature = "with-sequoia-openpgp")]
features.push("with-sequoia-openpgp");
let about = format!(
"{}, features: [{}]",
"Card Cli is a command tool for WebAuthn, OpenPGP, YubiKey ... smart cards",
features.join(", "),
);
let mut app = App::new(env!("CARGO_PKG_NAME"))
.version(env!("CARGO_PKG_VERSION"))
.about(env!("CARGO_PKG_DESCRIPTION"))
.long_about("Card Cli is a command tool for WebAuthn, OpenPGP, YubiKey ... smart cards")
.long_about(about.as_str())
.setting(AppSettings::ColoredHelp);
app = DefaultCommandImpl::process_command(app);
for command in &commands {

View File

@@ -3,6 +3,7 @@ use openssl::bn::BigNum;
use openssl::rsa::Rsa;
use pem::Pem;
use rust_util::XResult;
#[cfg(feature = "with-sequoia-openpgp")]
use sequoia_openpgp::crypto::mpi::PublicKey;
use x509_parser::x509::AlgorithmIdentifier;
@@ -42,6 +43,7 @@ pub fn bytes_to_pem<T>(tag: &str, contents: T) -> String where T: Into<Vec<u8>>
pem::encode(&cert_public_key_pem_obj).trim().to_string()
}
#[cfg(feature = "with-sequoia-openpgp")]
pub fn sequoia_openpgp_public_key_pem(public_key: &PublicKey) -> Option<(Vec<u8>, String)> {
match public_key {
PublicKey::RSA { e, n } => {