diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-08-14 22:13:33 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-08-23 19:15:13 +0200 |
commit | 56eacae5037826b7d6bf15962065287960d8b894 (patch) | |
tree | 8f2249537cbca8904dbe2ecf45542e12404d7be3 /tool/src | |
parent | c678874604b1a48a9aa46276e001ed540a823c06 (diff) |
openpgp: Rename SecretKey to SecretKeyMaterial.
- When the `SecretKey` type only refers to the secret key material
and not a TPK-like thing, call it `SecretKeyMaterial`.
Diffstat (limited to 'tool/src')
-rw-r--r-- | tool/src/commands/decrypt.rs | 4 | ||||
-rw-r--r-- | tool/src/commands/dump.rs | 20 | ||||
-rw-r--r-- | tool/src/commands/mod.rs | 6 |
3 files changed, 15 insertions, 15 deletions
diff --git a/tool/src/commands/decrypt.rs b/tool/src/commands/decrypt.rs index b1ec3ee5..748f9c7a 100644 --- a/tool/src/commands/decrypt.rs +++ b/tool/src/commands/decrypt.rs @@ -10,7 +10,7 @@ use crate::openpgp::constants::SymmetricAlgorithm; use crate::openpgp::conversions::hex; use crate::openpgp::crypto::SessionKey; use crate::openpgp::{Fingerprint, TPK, KeyID, Result}; -use crate::openpgp::packet::{Key, key::SecretKey, Signature, PKESK, SKESK}; +use crate::openpgp::packet::{Key, key::SecretKeyMaterial, Signature, PKESK, SKESK}; use crate::openpgp::parse::PacketParser; use crate::openpgp::parse::stream::{ VerificationHelper, DecryptionHelper, Decryptor, MessageStructure, @@ -122,7 +122,7 @@ impl<'a> DecryptionHelper for Helper<'a> { for pkesk in pkesks { let keyid = pkesk.recipient(); if let Some(key) = self.secret_keys.get(&keyid) { - if let Some(SecretKey::Unencrypted { .. }) = key.secret() { + if let Some(SecretKeyMaterial::Unencrypted { .. }) = key.secret() { if let Ok(sk) = key.clone().into_keypair() .and_then(|mut keypair| pkesk.decrypt(&mut keypair)) .and_then(|(algo, sk)| { decrypt(algo, &sk)?; Ok(sk) }) diff --git a/tool/src/commands/dump.rs b/tool/src/commands/dump.rs index 27619b7a..8fb98ffe 100644 --- a/tool/src/commands/dump.rs +++ b/tool/src/commands/dump.rs @@ -403,40 +403,40 @@ impl PacketDumper { } if let Some(secrets) = k.secret() { - use self::openpgp::packet::key::SecretKey; + use self::openpgp::packet::key::SecretKeyMaterial; writeln!(output, "{}", i)?; writeln!(output, "{} Secret Key:", i)?; let ii = format!("{} ", i); match secrets { - SecretKey::Unencrypted(ref u) => u.map( + SecretKeyMaterial::Unencrypted(ref u) => u.map( |mpis| -> Result<()> { match mpis { - mpis::SecretKey::RSA { d, p, q, u } => + mpis::SecretKeyMaterial::RSA { d, p, q, u } => self.dump_mpis(output, &ii, &[d.value(), p.value(), q.value(), u.value()], &["d", "p", "q", "u"])?, - mpis::SecretKey::DSA { x } => + mpis::SecretKeyMaterial::DSA { x } => self.dump_mpis(output, &ii, &[x.value()], &["x"])?, - mpis::SecretKey::Elgamal { x } => + mpis::SecretKeyMaterial::Elgamal { x } => self.dump_mpis(output, &ii, &[x.value()], &["x"])?, - mpis::SecretKey::EdDSA { scalar } => + mpis::SecretKeyMaterial::EdDSA { scalar } => self.dump_mpis(output, &ii, &[scalar.value()], &["scalar"])?, - mpis::SecretKey::ECDSA { scalar } => + mpis::SecretKeyMaterial::ECDSA { scalar } => self.dump_mpis(output, &ii, &[scalar.value()], &["scalar"])?, - mpis::SecretKey::ECDH { scalar } => + mpis::SecretKeyMaterial::ECDH { scalar } => self.dump_mpis(output, &ii, &[scalar.value()], &["scalar"])?, - mpis::SecretKey::Unknown { mpis, rest } => { + mpis::SecretKeyMaterial::Unknown { mpis, rest } => { let keys: Vec<String> = (0..mpis.len()).map( |i| format!("mpi{}", i)).collect(); @@ -453,7 +453,7 @@ impl PacketDumper { &["rest"])?; }, } Ok(()) })?, - SecretKey::Encrypted(ref e) => { + SecretKeyMaterial::Encrypted(ref e) => { writeln!(output, "{}", i)?; write!(output, "{} S2K: ", ii)?; self.dump_s2k(output, &ii, e.s2k())?; diff --git a/tool/src/commands/mod.rs b/tool/src/commands/mod.rs index 114a57e3..c4175cd9 100644 --- a/tool/src/commands/mod.rs +++ b/tool/src/commands/mod.rs @@ -11,7 +11,7 @@ use sequoia_core::Context; use crate::openpgp::constants::DataFormat; use crate::openpgp::crypto; use crate::openpgp::{TPK, KeyID, Result}; -use crate::openpgp::packet::key::SecretKey; +use crate::openpgp::packet::key::SecretKeyMaterial; use crate::openpgp::parse::{ Parse, PacketParserResult, @@ -51,14 +51,14 @@ fn get_signing_keys(tpks: &[openpgp::TPK]) -> Result<Vec<crypto::KeyPair>> { { if let Some(secret) = key.secret() { let unencrypted = match secret { - SecretKey::Encrypted(ref e) => { + SecretKeyMaterial::Encrypted(ref e) => { let password = rpassword::read_password_from_tty(Some( &format!("Please enter password to decrypt {}/{}: ", tsk, key))).unwrap(); e.decrypt(key.pk_algo(), &password.into()) .expect("decryption failed") }, - SecretKey::Unencrypted(ref u) => u.clone(), + SecretKeyMaterial::Unencrypted(ref u) => u.clone(), }; keys.push(crypto::KeyPair::new(key.clone(), unencrypted) |