From 9c7d76437a74d9e21d6f43d3e7784f7554928568 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Fri, 10 Apr 2020 02:30:04 +0200 Subject: openpgp: Inline {ed,x}25519 size constants in MPI point decoding --- openpgp/src/crypto/mpi.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'openpgp') 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) { -- cgit v1.2.3