diff options
author | Igor Matuszewski <igor@sequoia-pgp.org> | 2020-04-10 02:30:04 +0200 |
---|---|---|
committer | Igor Matuszewski <igor@sequoia-pgp.org> | 2020-06-22 12:02:10 +0200 |
commit | 9c7d76437a74d9e21d6f43d3e7784f7554928568 (patch) | |
tree | 61955e31f411a9f4ed6e9c47e49aac23d0985656 | |
parent | 3588924dc56a5e4a059084f62a4c86b47db12b86 (diff) |
openpgp: Inline {ed,x}25519 size constants in MPI point decoding
-rw-r--r-- | openpgp/src/crypto/mpi.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/openpgp/src/crypto/mpi.rs b/openpgp/src/crypto/mpi.rs index d1249e73..25150a7e 100644 --- a/openpgp/src/crypto/mpi.rs +++ b/openpgp/src/crypto/mpi.rs @@ -92,19 +92,21 @@ impl MPI { /// supported, `Error::MalformedMPI` if the point is formatted /// incorrectly. pub fn decode_point(&self, curve: &Curve) -> Result<(&[u8], &[u8])> { - use nettle::{ed25519, curve25519}; + const ED25519_KEY_SIZE: usize = 32; + const CURVE25519_SIZE: usize = 32; use self::Curve::*; match &curve { Ed25519 | Cv25519 => { - assert_eq!(curve25519::CURVE25519_SIZE, - ed25519::ED25519_KEY_SIZE); + assert_eq!(CURVE25519_SIZE, ED25519_KEY_SIZE); // This curve uses a custom compression format which // only contains the X coordinate. - if self.value().len() != 1 + curve25519::CURVE25519_SIZE { + if self.value().len() != 1 + CURVE25519_SIZE { return Err(Error::MalformedMPI( format!("Bad size of Curve25519 key: {} expected: {}", self.value().len(), - 1 + curve25519::CURVE25519_SIZE)).into()); + 1 + CURVE25519_SIZE + ) + ).into()); } if self.value().get(0).map(|&b| b != 0x40).unwrap_or(true) { |