From 935ccf366865c4c0055be67127222177fe2f5cda Mon Sep 17 00:00:00 2001 From: Julien Cretin Date: Tue, 9 Jun 2020 11:55:36 +0200 Subject: [PATCH] Revert "Propagate the NBYTES constant from Int256 to SecKey" This reverts commit 0073c153d257986e3260cac181bea80b50af789b. --- libraries/crypto/src/ecdsa.rs | 6 ++---- src/ctap/storage.rs | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libraries/crypto/src/ecdsa.rs b/libraries/crypto/src/ecdsa.rs index 8b4329a..966552d 100644 --- a/libraries/crypto/src/ecdsa.rs +++ b/libraries/crypto/src/ecdsa.rs @@ -22,8 +22,6 @@ use super::{Hash256, HashBlockSize64Bytes}; use alloc::vec::Vec; use core::marker::PhantomData; -pub use super::ec::int256::NBYTES; - #[derive(Clone, PartialEq)] #[cfg_attr(feature = "derive_debug", derive(Debug))] pub struct SecKey { @@ -142,7 +140,7 @@ impl SecKey { } } - pub fn from_bytes(bytes: &[u8; NBYTES]) -> Option { + pub fn from_bytes(bytes: &[u8; 32]) -> Option { let k = NonZeroExponentP256::from_int_checked(Int256::from_bin(bytes)); // The branching here is fine because all this reveals is whether the key was invalid. if bool::from(k.is_none()) { @@ -152,7 +150,7 @@ impl SecKey { Some(SecKey { k }) } - pub fn to_bytes(&self, bytes: &mut [u8; NBYTES]) { + pub fn to_bytes(&self, bytes: &mut [u8; 32]) { self.k.to_int().to_bin(bytes); } } diff --git a/src/ctap/storage.rs b/src/ctap/storage.rs index c138660..452bff6 100644 --- a/src/ctap/storage.rs +++ b/src/ctap/storage.rs @@ -62,7 +62,7 @@ const AAGUID: usize = 7; const NUM_TAGS: usize = 8; const MAX_PIN_RETRIES: u8 = 6; -const ATTESTATION_PRIVATE_KEY_LENGTH: usize = crypto::ecdsa::NBYTES; +const ATTESTATION_PRIVATE_KEY_LENGTH: usize = 32; const AAGUID_LENGTH: usize = 16; #[derive(PartialEq, Eq, PartialOrd, Ord)]