diff options
author | Igor Matuszewski <igor@sequoia-pgp.org> | 2020-04-05 19:42:28 +0200 |
---|---|---|
committer | Igor Matuszewski <igor@sequoia-pgp.org> | 2020-04-08 17:35:44 +0200 |
commit | e9f1216d8d5c4de851bfe9f98d65bce473320e9f (patch) | |
tree | f94a99744c1cc0595d010930a767269b12db8a15 /openpgp | |
parent | 6e065c1cc0054770a59fd84ca05d8e47feed793c (diff) |
openpgp: Rename crypto::mpis to crypto::mpi
To be consistent; we don't use plural forms for modules anywhere else
and Rust always uses singular forms.
Diffstat (limited to 'openpgp')
-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 |
14 files changed, 187 insertions, 187 deletions
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, }; - use crate::crypto::mpis::{MPI, PublicKey}; + use crate::crypto::mpi::{MPI, PublicKey}; use crate::PublicKeyAlgorithm::*; let mut rng = Yarrow::default(); @@ -1165,7 +1165,7 @@ impl<R> Key4<SecretParts, R> curve: Curve::Ed25519, q: MPI::new(&public), }; - let private_mpis = mpis::SecretKeyMaterial::EdDSA { + let private_mpis = mpi::SecretKeyMaterial::EdDSA { scalar: private.into(), }; let sec = private_mpis.into(); @@ -1192,7 +1192,7 @@ impl<R> Key4<SecretParts, R> hash: HashAlgorithm::SHA256, sym: SymmetricAlgorithm::AES256, }; - let private_mpis = mpis::SecretKeyMaterial::ECDH { + let private_mpis = mpi::SecretKeyMaterial::ECDH { scalar: private.into(), }; let sec = private_mpis.into(); @@ -1221,11 +1221,11 @@ impl<R> Key4<SecretParts, R> _ => unreachable!(), }; let (pub_x, pub_y) = public.as_bytes(); - let public_mpis = mpis::PublicKey::ECDSA{ + let public_mpis = mpi::PublicKey::ECDSA{ curve, q: MPI::new_weierstrass(&pub_x, &pub_y, field_sz), }; - let private_mpis = mpis::SecretKeyMaterial::ECDSA{ + let private_mpis = mpi::SecretKeyMaterial::ECDSA{ scalar: MPI::new(&private.as_bytes()).into(), }; let sec = private_mpis.into(); @@ -1258,13 +1258,13 @@ impl<R> Key4<SecretParts, R> }; let public = ecdh::point_mul_g(&private); let (pub_x, pub_y) = public.as_bytes(); - let public_mpis = mpis::PublicKey::ECDH{ + let public_mpis = mpi::PublicKey::ECDH{ curve, q: MPI::new_weierstrass(&pub_x, &pub_y, field_sz), hash, sym: SymmetricAlgorithm::AES256, }; - let private_mpis = mpis::SecretKeyMaterial::ECDH{ + let private_mpis = mpi::SecretKeyMaterial::ECDH{ scalar: MPI::new(&private.as_bytes()).into(), }; let sec = private_mpis.into(); @@ -1315,17 +1315,17 @@ impl<P, R> Key4<P, R> } /// Gets the key packet's MPIs. - pub fn mpis(&self) -> &mpis::PublicKey { + pub fn mpis(&self) -> &mpi::PublicKey { &self.mpis } /// Gets a mutable reference to the key packet's MPIs. - pub fn mpis_mut(&mut self) -> &mut mpis::PublicKey { + pub fn mpis_mut(&mut self) -> &mut mpi::PublicKey { &mut self.mpis } /// Sets the key packet's MPIs. - pub fn set_mpis(&mut self, mpis: mpis::PublicKey) -> mpis::PublicKey { + pub fn set_mpis(&mut self, mpis: mpi::PublicKey) -> mpi::PublicKey { ::std::mem::replace(&mut self.mpis, mpis) } @@ -1456 |