diff options
-rw-r--r-- | autocrypt/src/cert.rs | 2 | ||||
-rw-r--r-- | ipc/src/gnupg.rs | 18 | ||||
-rw-r--r-- | openpgp/src/crypto/asymmetric.rs | 54 | ||||
-rw-r--r-- | openpgp/src/crypto/ecdh.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/keygrip.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/mod.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/mpi.rs (renamed from openpgp/src/crypto/mpis.rs) | 0 | ||||
-rw-r--r-- | openpgp/src/crypto/sexp.rs | 40 | ||||
-rw-r--r-- | openpgp/src/message/mod.rs | 2 | ||||
-rw-r--r-- | openpgp/src/packet/key.rs | 122 | ||||
-rw-r--r-- | openpgp/src/packet/pkesk.rs | 8 | ||||
-rw-r--r-- | openpgp/src/packet/signature/mod.rs | 26 | ||||
-rw-r--r-- | openpgp/src/parse.rs | 8 | ||||
-rw-r--r-- | openpgp/src/parse/mpis.rs | 64 | ||||
-rw-r--r-- | openpgp/src/policy.rs | 2 | ||||
-rw-r--r-- | openpgp/src/serialize.rs | 42 | ||||
-rw-r--r-- | tool/src/commands/dump.rs | 58 |
17 files changed, 226 insertions, 226 deletions
diff --git a/autocrypt/src/cert.rs b/autocrypt/src/cert.rs index 4063e97a..dd7b29e1 100644 --- a/autocrypt/src/cert.rs +++ b/autocrypt/src/cert.rs @@ -71,7 +71,7 @@ mod tests { assert_eq!(cert1.keys().subkeys().next().unwrap().key().pk_algo(), PublicKeyAlgorithm::ECDH); match cert1.keys().subkeys().next().unwrap().key().mpis() { - openpgp::crypto::mpis::PublicKey::ECDH { + openpgp::crypto::mpi::PublicKey::ECDH { curve: openpgp::types::Curve::Cv25519, .. } => (), m => panic!("unexpected mpi: {:?}", m), diff --git a/ipc/src/gnupg.rs b/ipc/src/gnupg.rs index 7220b7f0..a1b4a45c 100644 --- a/ipc/src/gnupg.rs +++ b/ipc/src/gnupg.rs @@ -286,7 +286,7 @@ impl Agent { pub fn sign<'a, R>(&'a mut self, key: &'a Key<key::PublicParts, R>, algo: HashAlgorithm, digest: &'a [u8]) - -> impl Future<Item = crypto::mpis::Signature, + -> impl Future<Item = crypto::mpi::Signature, Error = anyhow::Error> + 'a where R: key::KeyRole { @@ -297,7 +297,7 @@ impl Agent { /// by the agent. pub fn decrypt<'a, R>(&'a mut self, key: &'a Key<key::PublicParts, R>, - ciphertext: &'a crypto::mpis::Ciphertext) + ciphertext: &'a crypto::mpi::Ciphertext) -> impl Future<Item = crypto::SessionKey, Error = anyhow::Error> + 'a where R: key::KeyRole @@ -406,7 +406,7 @@ fn protocol_error<T>(response: &assuan::Response) -> Result<T> { impl<'a, 'b, 'c, R> Future for SigningRequest<'a, 'b, 'c, R> where R: key::KeyRole { - type Item = crypto::mpis::Signature; + type Item = crypto::mpi::Signature; type Error = anyhow::Error; fn poll(&mut self) -> std::result::Result<Async<Self::Item>, Self::Error> { @@ -520,7 +520,7 @@ struct DecryptionRequest<'a, 'b, 'c, R> { c: &'a mut assuan::Client, key: &'b Key<key::PublicParts, R>, - ciphertext: &'c crypto::mpis::Ciphertext, + ciphertext: &'c crypto::mpi::Ciphertext, options: Vec<String>, state: DecryptionRequestState, } @@ -530,7 +530,7 @@ impl<'a, 'b, 'c, R> DecryptionRequest<'a, 'b, 'c, R> { fn new(c: &'a mut assuan::Client, key: &'b Key<key::PublicParts, R>, - ciphertext: &'c crypto::mpis::Ciphertext) + ciphertext: &'c crypto::mpi::Ciphertext) -> Self { Self { c, @@ -713,10 +713,10 @@ impl<'a> crypto::Signer for KeyPair<'a> { } fn sign(&mut self, hash_algo: HashAlgorithm, digest: &[u8]) - -> openpgp::Result<openpgp::crypto::mpis::Signature> + -> openpgp::Result<openpgp::crypto::mpi::Signature> { use crate::openpgp::types::PublicKeyAlgorithm::*; - use crate::openpgp::crypto::mpis::PublicKey; + use crate::openpgp::crypto::mpi::PublicKey; #[allow(deprecated)] match (self.public.pk_algo(), self.public.mpis()) @@ -743,11 +743,11 @@ impl<'a> crypto::Decryptor for KeyPair<'a> { self.public } - fn decrypt(&mut self, ciphertext: &crypto::mpis::Ciphertext, + fn decrypt(&mut self, ciphertext: &crypto::mpi::Ciphertext, _plaintext_len: Option<usize>) -> openpgp::Result<crypto::SessionKey> { - use crate::openpgp::crypto::mpis::{PublicKey, Ciphertext}; + use crate::openpgp::crypto::mpi::{PublicKey, Ciphertext}; match (self.public.mpis(), ciphertext) { (PublicKey::RSA { .. }, Ciphertext::RSA { .. }) diff --git a/openpgp/src/crypto/asymmetric.rs b/openpgp/src/crypto/asymmetric.rs index 566f39d9..534e4912 100644 --- a/openpgp/src/crypto/asymmetric.rs +++ b/openpgp/src/crypto/asymmetric.rs @@ -4,7 +4,7 @@ use nettle::{dsa, ecc, ecdsa, ed25519, rsa, random::Yarrow}; use crate::packet::{self, key, Key}; use crate::crypto::SessionKey; -use crate::crypto::mpis::{self, MPI}; +use crate::crypto::mpi::{self, MPI}; use crate::types::{Curve, HashAlgorithm}; use crate::Error; @@ -22,7 +22,7 @@ pub trait Signer { /// Creates a signature over the `digest` produced by `hash_algo`. fn sign(&mut self, hash_algo: HashAlgorithm, digest: &[u8]) - -> Result<mpis::Signature>; + -> Result<mpi::Signature>; } impl Signer for Box<dyn Signer> { @@ -31,7 +31,7 @@ impl Signer for Box<dyn Signer> { } fn sign(&mut self, hash_algo: HashAlgorithm, digest: &[u8]) - -> Result<mpis::Signature> { + -> Result<mpi::Signature> { self.as_mut().sign(hash_algo, digest) } } @@ -47,7 +47,7 @@ pub trait Decryptor { fn public(&self) -> &Key<key::PublicParts, key::UnspecifiedRole>; /// Decrypts `ciphertext`, returning the plain session key. - fn decrypt(&mut self, ciphertext: &mpis::Ciphertext, + fn decrypt(&mut self, ciphertext: &mpi::Ciphertext, plaintext_len: Option<usize>) -> Result<SessionKey>; } @@ -95,10 +95,10 @@ impl Signer for KeyPair { } fn sign(&mut self, hash_algo: HashAlgorithm, digest: &[u8]) - -> Result<mpis::Signature> + -> Result<mpi::Signature> { use crate::PublicKeyAlgorithm::*; - use crate::crypto::mpis::PublicKey; + use crate::crypto::mpi::PublicKey; let mut rng = Yarrow::default(); @@ -108,10 +108,10 @@ impl Signer for KeyPair { { (RSASign, &PublicKey::RSA { ref e, ref n }, - &mpis::SecretKeyMaterial::RSA { ref p, ref q, ref d, .. }) | + &mpi::SecretKeyMaterial::RSA { ref p, ref q, ref d, .. }) | (RSAEncryptSign, &PublicKey::RSA { ref e, ref n }, - &mpis::SecretKeyMaterial::RSA { ref p, ref q, ref d, .. }) => { + &mpi::SecretKeyMaterial::RSA { ref p, ref q, ref d, .. }) => { let public = rsa::PublicKey::new(n.value(), e.value())?; let secret = rsa::PrivateKey::new(d.value(), p.value(), q.value(), Option::None)?; @@ -129,20 +129,20 @@ impl Signer for KeyPair { hash_algo.oid()?, &mut rng, &mut sig)?; - Ok(mpis::Signature::RSA { + Ok(mpi::Signature::RSA { s: MPI::new(&sig), }) }, (DSA, &PublicKey::DSA { ref p, ref q, ref g, .. }, - &mpis::SecretKeyMaterial::DSA { ref x }) => { + &mpi::SecretKeyMaterial::DSA { ref x }) => { let params = dsa::Params::new(p.value(), q.value(), g.value()); let secret = dsa::PrivateKey::new(x.value()); let sig = dsa::sign(¶ms, &secret, digest, &mut rng)?; - Ok(mpis::Signature::DSA { + Ok(mpi::Signature::DSA { r: MPI::new(&sig.r()), s: MPI::new(&sig.s()), }) @@ -150,7 +150,7 @@ impl Signer for KeyPair { (EdDSA, &PublicKey::EdDSA { ref curve, ref q }, - &mpis::SecretKeyMaterial::EdDSA { ref scalar }) => match curve { + &mpi::SecretKeyMaterial::EdDSA { ref scalar }) => match curve { Curve::Ed25519 => { let public = q.decode_point(&Curve::Ed25519)?.0; @@ -173,7 +173,7 @@ impl Signer for KeyPair { } res?; - Ok(mpis::Signature::EdDSA { + Ok(mpi::Signature::EdDSA { r: MPI::new(&sig[..32]), s: MPI::new(&sig[32..]), }) @@ -184,7 +184,7 @@ impl Signer for KeyPair { (ECDSA, &PublicKey::ECDSA { ref curve, .. }, - &mpis::SecretKeyMaterial::ECDSA { ref scalar }) => { + &mpi::SecretKeyMaterial::ECDSA { ref scalar }) => { let secret = match curve { Curve::NistP256 => ecc::Scalar::new::<ecc::Secp256r1>( @@ -203,7 +203,7 @@ impl Signer for KeyPair { let sig = ecdsa::sign(&secret, digest, &mut rng); - Ok(mpis::Signature::ECDSA { + Ok(mpi::Signature::ECDSA { r: MPI::new(&sig.r()), s: MPI::new(&sig.s()), }) @@ -223,19 +223,19 @@ impl Decryptor for KeyPair { } /// Creates a signature over the `digest` produced by `hash_algo`. - fn decrypt(&mut self, ciphertext: &mpis::Ciphertext, + fn decrypt(&mut self, ciphertext: &mpi::Ciphertext, plaintext_len: Option<usize>) -> Result<SessionKey> { use crate::PublicKeyAlgorithm::*; - use crate::crypto::mpis::PublicKey; + use crate::crypto::mpi::PublicKey; self.secret.map( |secret| Ok(match (self.public.mpis(), secret, ciphertext) { (PublicKey::RSA{ ref e, ref n }, - mpis::SecretKeyMaterial::RSA{ ref p, ref q, ref d, .. }, - mpis::Ciphertext::RSA{ ref c }) => { + mpi::SecretKeyMaterial::RSA{ ref p, ref q, ref d, .. }, + mpi::Ciphertext::RSA{ ref c }) => { // Workaround for #440: Make sure c is of the same // length as n. // XXX: Remove once we depend on nettle > 7.0.0. @@ -272,14 +272,14 @@ impl Decryptor for KeyPair { } (PublicKey::ElGamal{ .. }, - mpis::SecretKeyMaterial::ElGamal{ .. }, - mpis::Ciphertext::ElGamal{ .. }) => + mpi::SecretKeyMaterial::ElGamal{ .. }, + mpi::Ciphertext::ElGamal{ .. }) => return Err( Error::UnsupportedPublicKeyAlgorithm(ElGamalEncrypt).into()), (PublicKey::ECDH{ .. }, - mpis::SecretKeyMaterial::ECDH { .. }, - mpis::Ciphertext::ECDH { .. }) => + mpi::SecretKeyMaterial::ECDH { .. }, + mpi::Ciphertext::ECDH { .. }) => crate::crypto::ecdh::decrypt(&self.public, secret, ciphertext)?, (public, secret, ciphertext) => @@ -300,7 +300,7 @@ impl From<KeyPair> for Key<key::SecretParts, key::UnspecifiedRole> { impl<P: key::KeyParts, R: key::KeyRole> Key<P, R> { /// Encrypts the given data with this key. - pub fn encrypt(&self, data: &SessionKey) -> Result<mpis::Ciphertext> { + pub fn encrypt(&self, data: &SessionKey) -> Result<mpi::Ciphertext> { use crate::PublicKeyAlgorithm::*; #[allow(deprecated)] @@ -308,14 +308,14 @@ impl<P: key::KeyParts, R: key::KeyRole> Key<P, R> { RSAEncryptSign | RSAEncrypt => { // Extract the public recipient. match self.mpis() { - mpis::PublicKey::RSA { e, n } => { + mpi::PublicKey::RSA { e, n } => { // The ciphertext has the length of the modulus. let mut esk = vec![0u8; n.value().len()]; let mut rng = Yarrow::default(); let pk = rsa::PublicKey::new(n.value(), e.value())?; rsa::encrypt_pkcs1(&pk, &mut rng, data, &mut esk)?; - Ok(mpis::Ciphertext::RSA { + Ok(mpi::Ciphertext::RSA { c: MPI::new(&esk), }) }, @@ -337,7 +337,7 @@ impl<P: key::KeyParts, R: key::KeyRole> Key<P, R> { pub fn verify(&self, sig: &packet::Signature, digest: &[u8]) -> Result<()> { use crate::PublicKeyAlgorithm::*; - use crate::crypto::mpis::{PublicKey, Signature}; + use crate::crypto::mpi::{PublicKey, Signature}; #[allow(deprecated)] let ok = match (sig.pk_algo(), self.mpis(), sig.mpis()) { diff --git a/openpgp/src/crypto/ecdh.rs b/openpgp/src/crypto/ecdh.rs index 3a982621..e95ecd58 100644 --- a/openpgp/src/crypto/ecdh.rs +++ b/openpgp/src/crypto/ecdh.rs @@ -19,7 +19,7 @@ use crate::utils::{ }; use crate::crypto::SessionKey; use crate::crypto::mem::Protected; -use crate::crypto::mpis::{MPI, PublicKey, SecretKeyMaterial, Ciphertext}; +use crate::crypto::mpi::{MPI, PublicKey, SecretKeyMaterial, Ciphertext}; use nettle::{cipher, curve25519, mode, mode::Mode, ecc, ecdh, random::Yarrow}; /// Wraps a session key using Elliptic Curve Diffie-Hellman. diff --git a/openpgp/src/crypto/keygrip.rs b/openpgp/src/crypto/keygrip.rs index d059ae25..68401e53 100644 --- a/openpgp/src/crypto/keygrip.rs +++ b/openpgp/src/crypto/keygrip.rs @@ -3,7 +3,7 @@ use std::fmt; use crate::Error; use crate::Result; use crate::types::{Curve, HashAlgorithm}; -use crate::crypto::mpis::{MPI, PublicKey}; +use crate::crypto::mpi::{MPI, PublicKey}; /// A proprietary, protocol agnostic identifier for public keys. /// diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs index 3cb029dd..081e7a0b 100644 --- a/openpgp/src/crypto/mod.rs +++ b/openpgp/src/crypto/mod.rs @@ -17,7 +17,7 @@ pub mod hash; mod keygrip; pub use self::keygrip::Keygrip; pub mod mem; -pub mod mpis; +pub mod mpi; mod s2k; pub use s2k::S2K; pub mod sexp; diff --git a/openpgp/src/crypto/mpis.rs b/openpgp/src/crypto/mpi.rs index a23cc64f..a23cc64f 100644 --- a/openpgp/src/crypto/mpis.rs +++ b/openpgp/src/crypto/mpi.rs diff --git a/openpgp/src/crypto/sexp.rs b/openpgp/src/crypto/sexp.rs index c4325e57..479fb8e3 100644 --- a/openpgp/src/crypto/sexp.rs +++ b/openpgp/src/crypto/sexp.rs @@ -11,7 +11,7 @@ use std::fmt; use std::ops::Deref; use quickcheck::{Arbitrary, Gen}; -use crate::crypto::{self, mpis, SessionKey}; +use crate::crypto::{self, mpi, SessionKey}; use crate::crypto::mem::Protected; use crate::Error; @@ -47,12 +47,12 @@ impl Sexp { pub fn finish_decryption<R>(&self, recipient: &crate::packet::Key< crate::packet::key::PublicParts, R>, - ciphertext: &mpis::Ciphertext, + ciphertext: &mpi::Ciphertext, padding: bool) -> Result<SessionKey> where R: crate::packet::key::KeyRole { - use crate::crypto::mpis::PublicKey; + use crate::crypto::mpi::PublicKey; let not_a_session_key = || -> anyhow::Error { Error::MalformedMPI( format!("Not a session key: {:?}", self)).into() @@ -119,7 +119,7 @@ impl Sexp { PublicKey::ECDH { curve, .. } => { // The shared point has been computed by the // remote agent. The shared point is not padded. - let mut s = mpis::MPI::new(s); + let mut s = mpi::MPI::new(s); #[allow(non_snake_case)] let S: Protected = s.decode_point(curve)?.0.into(); s.secure_memzero(); @@ -141,7 +141,7 @@ impl Sexp { /// /// Such an expression is returned from gpg-agent's `PKSIGN` /// command. - pub fn to_signature(&self) -> Result<mpis::Signature> { + pub fn to_signature(&self) -> Result<mpi::Signature> { let not_a_signature = || -> anyhow::Error { Error::MalformedMPI( format!("Not a signature: {:?}", self)).into() @@ -159,9 +159,9 @@ impl Sexp { p.get(b"s").ok().unwrap_or_default() .and_then(|l| l.get(0).and_then(Sexp::string).cloned()) }).ok_or_else(not_a_signature)?; - Ok(mpis::Signature::EdDSA { - r: mpis::MPI::new(&r), - s: mpis::MPI::new(&s), + Ok(mpi::Signature::EdDSA { + r: mpi::MPI::new(&r), + s: mpi::MPI::new(&s), }) } else if let Some(param) = sig.get(b"ecdsa")? { let r = param.iter().find_map(|p| { @@ -172,17 +172,17 @@ impl Sexp { p.get(b"s").ok().unwrap_or_default() .and_then(|l| l.get(0).and_then(Sexp::string).cloned()) }).ok_or_else(not_a_signature)?; - Ok(mpis::Signature::ECDSA { - r: mpis::MPI::new(&r), - s: mpis::MPI::new(&s), + Ok(mpi::Signature::ECDSA { + r: mpi::MPI::new(&r), + s: mpi::MPI::new(&s), }) } else if let Some(param) = sig.get(b"rsa")? { let s = param.iter().find_map(|p| { p.get(b"s").ok().unwrap_or_default() .and_then(|l| l.get(0).and_then(Sexp::string).cloned()) }).ok_or_else(not_a_signature)?; - Ok(mpis::Signature::RSA { - s: mpis::MPI::new(&s), + Ok(mpi::Signature::RSA { + s: mpi::MPI::new(&s), }) } else if let Some(param) = sig.get(b"dsa")? { let r = param.iter().find_map(|p| { @@ -193,9 +193,9 @@ impl Sexp { p.get(b"s").ok().unwrap_or_default() .and_then(|l| l.get(0).and_then(Sexp::string).cloned()) }).ok_or_else(not_a_signature)?; - Ok(mpis::Signature::DSA { - r: mpis::MPI::new(&r), - s: mpis::MPI::new(&s), + Ok(mpi::Signature::DSA { + r: mpi::MPI::new(&r), + s: mpi::MPI::new(&s), }) } else { Err(Error::MalformedMPI( @@ -240,15 +240,15 @@ impl Sexp { } } -impl TryFrom<&mpis::Ciphertext> for Sexp { +impl TryFrom<&mpi::Ciphertext> for Sexp { type Error = anyhow::Error; /// Constructs an S-Expression representing `ciphertext`. /// /// The resulting expression is suitable for gpg-agent's `INQUIRE /// CIPHERTEXT` inquiry. - fn try_from(ciphertext: &mpis::Ciphertext) -> Result<Self> { - use crate::crypto::mpis::Ciphertext::*; + fn try_from(ciphertext: &mpi::Ciphertext) -> Result<Self> { + use crate::crypto::mpi::Ciphertext::*; match ciphertext { RSA { ref c } => Ok(Sexp::List(vec![ @@ -411,7 +411,7 @@ mod tests { #[test] fn to_signature() { - use crate::crypto::mpis::Signature::*; + use crate::crypto::mpi::Signature::*; assert_match!(DSA { .. } = Sexp::from_bytes( crate::tests::file("sexp/dsa-signature.sexp")).unwrap() .to_signature().unwrap()); diff --git a/openpgp/src/message/mod.rs b/openpgp/src/message/mod.rs index dd25fb4a..8dd1b197 100644 --- a/openpgp/src/message/mod.rs +++ b/openpgp/src/message/mod.rs @@ -483,7 +483,7 @@ mod tests { use crate::PublicKeyAlgorithm; use crate::SignatureType; use crate::crypto::S2K; - use crate::crypto::mpis::{Ciphertext, MPI}; + use crate::crypto::mpi::{Ciphertext, MPI}; use crate::packet::prelude::*; #[test] diff --git a/openpgp/src/packet/key.rs b/openpgp/src/packet/key.rs index 5fb91aea..ec43be0a 100644 --- a/openpgp/src/packet/key.rs +++ b/openpgp/src/packet/key.rs @@ -58,7 +58,7 @@ use quickcheck::{Arbitrary, Gen}; use crate::Error; use crate::cert::prelude::*; -use crate::crypto::{self, mem::{self, Protected}, mpis, hash::Hash}; +use crate::crypto::{self, mem::{self, Protected}, mpi, hash::Hash}; use crate::packet; use crate::packet::prelude::*; use crate::PublicKeyAlgorithm; @@ -818,7 +818,7 @@ pub struct Key4<P, R> /// Public key algorithm of this signature. pk_algo: PublicKeyAlgorithm, /// Public key MPIs. - mpis: mpis::PublicKey, + mpis: mpi::PublicKey, /// Optional secret part of the key. secret: Option<SecretKeyMaterial>, @@ -917,7 +917,7 @@ impl<R> Key4<key::PublicParts, R> { /// Creates a new OpenPGP key packet. pub fn new<T>(creation_time: T, pk_algo: PublicKeyAlgorithm, - mpis: mpis::PublicKey) + mpis: mpi::PublicKey) -> Result<Self> where T: Into<time::SystemTime> { @@ -950,11 +950,11 @@ impl<R> Key4<key::PublicParts, R> Self::new( ctime.into().unwrap_or_else(time::SystemTime::now), PublicKeyAlgorithm::ECDH, - mpis::PublicKey::ECDH { + mpi::PublicKey::ECDH { curve: Curve::Cv25519, hash: hash.into().unwrap_or(HashAlgorithm::SHA512), sym: sym.into().unwrap_or(SymmetricAlgorithm::AES256), - q: mpis::MPI::new(&point), + q: mpi::MPI::new(&point), }) } @@ -973,9 +973,9 @@ impl<R> Key4<key::PublicParts, R> Self::new( ctime.into().unwrap_or_else(time::SystemTime::now), PublicKeyAlgorithm::EdDSA, - mpis::PublicKey::EdDSA { + mpi::PublicKey::EdDSA { curve: Curve::Ed25519, - q: mpis::MPI::new(&point), + q: mpi::MPI::new(&point), }) } @@ -990,9 +990,9 @@ impl<R> Key4<key::PublicParts, R> Self::new( ctime.into().unwrap_or_else(time::SystemTime::now), PublicKeyAlgorithm::RSAEncryptSign, - mpis::PublicKey::RSA { - e: mpis::MPI::new(e), - n: mpis::MPI::new(n), + mpi::PublicKey::RSA { + e: mpi::MPI::new(e), + n: mpi::MPI::new(n), }) } } @@ -1002,7 +1002,7 @@ impl<R> Key4<SecretParts, R> { /// Creates a new OpenPGP key packet with secrets. pub fn with_secret<T>(creation_time: T, pk_algo: PublicKeyAlgorithm, - mpis: mpis::PublicKey, + mpis: mpi::PublicKey, secret: SecretKeyMaterial) -> Result<Self> where T: Into<time::SystemTime> @@ -1041,13 +1041,13 @@ impl<R> Key4<SecretParts, R> Self::with_secret( ctime.into().unwrap_or_else(time::SystemTime::now), PublicKeyAlgorithm::ECDH, - mpis::PublicKey::ECDH { + mpi::PublicKey::ECDH { curve: Curve::Cv25519, hash: hash.into().unwrap_or(HashAlgorithm::SHA512), sym: sym.into().unwrap_or(SymmetricAlgorithm::AES256), - q: mpis::MPI::new(&public_key), + q: mpi::MPI::new(&public_key), }, - mpis::SecretKeyMaterial::ECDH { + mpi::SecretKeyMaterial::ECDH { scalar: private_key.into(), }.into()) } @@ -1069,12 +1069,12 @@ impl<R> Key4<SecretParts, R> Self::with_secret( ctime.into().unwrap_or_else(time::SystemTime::now), PublicKeyAlgorithm::EdDSA, - mpis::PublicKey::EdDSA { + mpi::PublicKey::EdDSA { curve: Curve::Ed25519, - q: mpis::MPI::new(&public_key), + q: mpi::MPI::new(&public_key), }, - mpis::SecretKeyMaterial::EdDSA { - scalar: mpis::MPI::new(private_key).into(), + mpi::SecretKeyMaterial::EdDSA { + scalar: mpi::MPI::new(private_key).into(), }.into()) } @@ -1095,22 +1095,22 @@ impl<R> Key4<SecretParts, R> Self::with_secret( ctime.into().unwrap_or_else(time::SystemTime::now), PublicKeyAlgorithm::RSAEncryptSign, - mpis::PublicKey::RSA { - e: mpis::MPI::new(&key.e()[..]), - n: mpis::MPI::new(&key.n()[..]), + mpi::PublicKey::RSA { + e: mpi::MPI::new(&key.e()[..]), + n: mpi::MPI::new(&key.n()[..]), }, - mpis::SecretKeyMaterial::RSA { - d: mpis::MPI::new(d).into(), - p: mpis::MPI::new(&a[..]).into(), - q: mpis::MPI::new(&b[..]).into(), - u: mpis::MPI::new(&c[..]).into(), + mpi::SecretKeyMaterial::RSA { + d: mpi::MPI::new(d).into(), + p: mpi::MPI::new(&a[..]).into(), + q: mpi::MPI::new(&b[..]).into(), + u: mpi::MPI::new(&c[..]).into(), }.into()) } /// Generates a new RSA key with a public modulos of size `bits`. pub fn generate_rsa(bits: usize) -> Result<Self> { use nettle::{rsa, random::Yarrow}; - use crate::crypto::mpis::{MPI, PublicKey}; + use crate::crypto::mpi::{MPI, PublicKey}; let mut rng = Yarrow::default(); let (public, private) = rsa::generate_keypair(&mut rng, bits as u32)?; @@ -1119,7 +1119,7 @@ impl<R> Key4<SecretParts, R> e: MPI::new(&*public.e()).into(), n: MPI::new(&*public.n()).into(), }; - let private_mpis = mpis::SecretKeyMaterial::RSA { + let private_mpis = mpi::SecretKeyMaterial::RSA { d: MPI::new(&*private.d()).into(), p: MPI::new(&*p).into(), q: MPI::new(&*q).into(), @@ -1147,7 +1147,7 @@ impl<R> Key4<SecretParts, R> curve25519, curve25519::CURVE25519_SIZE, ecc, ecdh, ecdsa, }; |