feat: v1.2.1, optimize naming
This commit is contained in:
@@ -432,11 +432,11 @@ pub fn try_decrypt_key(config: &Option<TinyEncryptConfig>,
|
||||
pin: &Option<String>,
|
||||
slot: &Option<String>) -> XResult<Vec<u8>> {
|
||||
match envelop.r#type {
|
||||
TinyEncryptEnvelopType::Pgp => try_decrypt_key_pgp(envelop, pin),
|
||||
TinyEncryptEnvelopType::PgpRsa => try_decrypt_key_pgp(envelop, pin),
|
||||
TinyEncryptEnvelopType::PgpX25519 => try_decrypt_key_ecdh_pgp_x25519(envelop, pin),
|
||||
#[cfg(feature = "macos")]
|
||||
TinyEncryptEnvelopType::StaticX25519 => try_decrypt_key_ecdh_static_x25519(config, envelop),
|
||||
TinyEncryptEnvelopType::Ecdh | TinyEncryptEnvelopType::EcdhP384 => try_decrypt_key_ecdh(config, envelop, pin, slot),
|
||||
TinyEncryptEnvelopType::PivP256 | TinyEncryptEnvelopType::EcdhP384 => try_decrypt_key_ecdh(config, envelop, pin, slot),
|
||||
#[cfg(feature = "secure-enclave")]
|
||||
TinyEncryptEnvelopType::KeyP256 => try_decrypt_se_key_ecdh(config, envelop),
|
||||
unknown_type => simple_error!("Unknown or unsupported type: {}", unknown_type.get_name()),
|
||||
|
||||
@@ -265,13 +265,13 @@ fn encrypt_envelops(cryptor: Cryptor, key: &[u8], envelops: &[&TinyEncryptConfig
|
||||
let mut encrypted_envelops = vec![];
|
||||
for envelop in envelops {
|
||||
match envelop.r#type {
|
||||
TinyEncryptEnvelopType::Pgp => {
|
||||
TinyEncryptEnvelopType::PgpRsa => {
|
||||
encrypted_envelops.push(encrypt_envelop_pgp(key, envelop)?);
|
||||
}
|
||||
TinyEncryptEnvelopType::PgpX25519 | TinyEncryptEnvelopType::StaticX25519 => {
|
||||
encrypted_envelops.push(encrypt_envelop_ecdh_x25519(cryptor, key, envelop)?);
|
||||
}
|
||||
TinyEncryptEnvelopType::Ecdh | TinyEncryptEnvelopType::KeyP256 => {
|
||||
TinyEncryptEnvelopType::PivP256 | TinyEncryptEnvelopType::KeyP256 => {
|
||||
encrypted_envelops.push(encrypt_envelop_ecdh(cryptor, key, envelop)?);
|
||||
}
|
||||
TinyEncryptEnvelopType::EcdhP384 => {
|
||||
|
||||
36
src/spec.rs
36
src/spec.rs
@@ -65,26 +65,26 @@ pub struct TinyEncryptEnvelop {
|
||||
/// NOTICE: Kms and Age is not being supported in the future
|
||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, PartialOrd)]
|
||||
pub enum TinyEncryptEnvelopType {
|
||||
// OpenPGP RSA
|
||||
#[serde(rename = "pgp")]
|
||||
Pgp,
|
||||
// OpenPGP X25519
|
||||
// OpenPGP Card RSA
|
||||
#[serde(rename = "pgp-rsa", alias = "pgp")]
|
||||
PgpRsa,
|
||||
// OpenPGP Card X25519
|
||||
#[serde(rename = "pgp-x25519")]
|
||||
PgpX25519,
|
||||
// Static X25519 (less secure)
|
||||
// Keychain Static X25519 (less secure)
|
||||
#[serde(rename = "static-x25519")]
|
||||
StaticX25519,
|
||||
// Key P256 (Private key in Secure Enclave)
|
||||
// Secure Enclave ECDH P256
|
||||
#[serde(rename = "key-p256")]
|
||||
KeyP256,
|
||||
// Age, tiny-encrypt-rs is not supported
|
||||
#[serde(rename = "age")]
|
||||
Age,
|
||||
// ECDH P256
|
||||
#[serde(rename = "ecdh")]
|
||||
Ecdh,
|
||||
// ECDH P384
|
||||
#[serde(rename = "ecdh-p384")]
|
||||
// PIV ECDH P256
|
||||
#[serde(rename = "piv-p256", alias = "ecdh")]
|
||||
PivP256,
|
||||
// PIV ECDH P384
|
||||
#[serde(rename = "piv-p384", alias = "ecdh-p384")]
|
||||
EcdhP384,
|
||||
// KMS, tiny-encrypt-rs is not supported
|
||||
#[serde(rename = "kms")]
|
||||
@@ -98,25 +98,25 @@ impl TinyEncryptEnvelopType {
|
||||
|
||||
pub fn get_name(&self) -> &'static str {
|
||||
match self {
|
||||
TinyEncryptEnvelopType::Pgp => "pgp",
|
||||
TinyEncryptEnvelopType::PgpRsa => "pgp-rsa",
|
||||
TinyEncryptEnvelopType::PgpX25519 => "pgp-x25519",
|
||||
TinyEncryptEnvelopType::StaticX25519 => "static-x25519",
|
||||
TinyEncryptEnvelopType::KeyP256 => "key-p256",
|
||||
TinyEncryptEnvelopType::Age => "age",
|
||||
TinyEncryptEnvelopType::Ecdh => "ecdh",
|
||||
TinyEncryptEnvelopType::EcdhP384 => "ecdh-p384",
|
||||
TinyEncryptEnvelopType::PivP256 => "piv-p256",
|
||||
TinyEncryptEnvelopType::EcdhP384 => "piv-p384",
|
||||
TinyEncryptEnvelopType::Kms => "kms",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn auto_select(&self) -> bool {
|
||||
match self {
|
||||
TinyEncryptEnvelopType::Pgp => false,
|
||||
TinyEncryptEnvelopType::PgpRsa => false,
|
||||
TinyEncryptEnvelopType::PgpX25519 => false,
|
||||
TinyEncryptEnvelopType::StaticX25519 => true,
|
||||
TinyEncryptEnvelopType::KeyP256 => true,
|
||||
TinyEncryptEnvelopType::Age => false,
|
||||
TinyEncryptEnvelopType::Ecdh => false,
|
||||
TinyEncryptEnvelopType::PivP256 => false,
|
||||
TinyEncryptEnvelopType::EcdhP384 => false,
|
||||
TinyEncryptEnvelopType::Kms => true,
|
||||
}
|
||||
@@ -215,7 +215,7 @@ impl TinyEncryptMeta {
|
||||
if let (Some(pgp_envelop), Some(pgp_fingerprint), Some(envelops))
|
||||
= (&self.pgp_envelop, &self.pgp_fingerprint, &mut self.envelops) {
|
||||
envelops.push(TinyEncryptEnvelop {
|
||||
r#type: TinyEncryptEnvelopType::Pgp,
|
||||
r#type: TinyEncryptEnvelopType::PgpRsa,
|
||||
kid: pgp_fingerprint.into(),
|
||||
desc: None,
|
||||
encrypted_key: pgp_envelop.into(),
|
||||
@@ -243,7 +243,7 @@ impl TinyEncryptMeta {
|
||||
if let (Some(ecdh_envelop), Some(ecdh_point), Some(envelops))
|
||||
= (&self.ecdh_envelop, &self.ecdh_point, &mut self.envelops) {
|
||||
envelops.push(TinyEncryptEnvelop {
|
||||
r#type: TinyEncryptEnvelopType::Ecdh,
|
||||
r#type: TinyEncryptEnvelopType::PivP256,
|
||||
kid: ecdh_point.into(),
|
||||
desc: None,
|
||||
encrypted_key: ecdh_envelop.into(),
|
||||
|
||||
Reference in New Issue
Block a user