v1.7.8, update config display

This commit is contained in:
2024-01-14 22:03:26 +08:00
parent 62feb2e246
commit 80ce9fcece
4 changed files with 12 additions and 7 deletions

2
Cargo.lock generated
View File

@@ -1847,7 +1847,7 @@ dependencies = [
[[package]] [[package]]
name = "tiny-encrypt" name = "tiny-encrypt"
version = "1.7.7" version = "1.7.8"
dependencies = [ dependencies = [
"aes-gcm-stream", "aes-gcm-stream",
"base64", "base64",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "tiny-encrypt" name = "tiny-encrypt"
version = "1.7.7" version = "1.7.8"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
description = "A simple and tiny file encrypt tool" description = "A simple and tiny file encrypt tool"

View File

@@ -71,8 +71,12 @@ fn config_key_filter(cmd_version: &CmdConfig, config: &TinyEncryptConfig) -> XRe
information!("Found {} envelops", envelops.len()); information!("Found {} envelops", envelops.len());
let mut config_envelops = vec![]; let mut config_envelops = vec![];
for envelop in envelops { for envelop in envelops {
let hardware_security_mark = match envelop.r#type.is_hardware_security() {
None => " ?",
Some(hardware_security) => iff!(hardware_security, " *", "")
};
config_envelops.push(ConfigEnvelop { config_envelops.push(ConfigEnvelop {
r#type: format!("{}{}", envelop.r#type.get_name(), iff!(envelop.r#type.is_hardware_security(), " *", "")), r#type: format!("{}{}", envelop.r#type.get_name(), hardware_security_mark),
sid: strip_field(&envelop.sid.as_ref().map(ToString::to_string).unwrap_or_else(|| "-".to_string()), 25), sid: strip_field(&envelop.sid.as_ref().map(ToString::to_string).unwrap_or_else(|| "-".to_string()), 25),
kid: strip_field(&envelop.kid, 40), kid: strip_field(&envelop.kid, 40),
desc: strip_field(&envelop.desc.as_ref().map(ToString::to_string).unwrap_or_else(|| "-".to_string()), 40), desc: strip_field(&envelop.desc.as_ref().map(ToString::to_string).unwrap_or_else(|| "-".to_string()), 40),

View File

@@ -140,7 +140,7 @@ impl TinyEncryptEnvelopType {
} }
} }
pub fn is_hardware_security(&self) -> bool { pub fn is_hardware_security(&self) -> Option<bool> {
match self { match self {
TinyEncryptEnvelopType::PgpRsa TinyEncryptEnvelopType::PgpRsa
| TinyEncryptEnvelopType::PgpX25519 | TinyEncryptEnvelopType::PgpX25519
@@ -148,11 +148,12 @@ impl TinyEncryptEnvelopType {
| TinyEncryptEnvelopType::PivP256 | TinyEncryptEnvelopType::PivP256
| TinyEncryptEnvelopType::PivP384 | TinyEncryptEnvelopType::PivP384
| TinyEncryptEnvelopType::PivRsa | TinyEncryptEnvelopType::PivRsa
| TinyEncryptEnvelopType::Age => true, | TinyEncryptEnvelopType::Age => Some(true),
TinyEncryptEnvelopType::StaticX25519 TinyEncryptEnvelopType::StaticX25519
| TinyEncryptEnvelopType::StaticKyber1024 | TinyEncryptEnvelopType::StaticKyber1024
| TinyEncryptEnvelopType::Gpg // GPG is unknown(hardware/software) | TinyEncryptEnvelopType::Kms => Some(false),
| TinyEncryptEnvelopType::Kms => false, // GPG is unknown(hardware/software)
TinyEncryptEnvelopType::Gpg => None,
} }
} }
} }