From 67e3d46291607019f7071b6be47a6267ed8e935a Mon Sep 17 00:00:00 2001 From: kaczmarczyck <43844792+kaczmarczyck@users.noreply.github.com> Date: Mon, 14 Aug 2023 13:59:54 +0200 Subject: [PATCH] Cleans up warnings, unused functions and features (#643) --- Cargo.toml | 2 +- libraries/crypto/Cargo.toml | 1 - libraries/crypto/src/ecdsa.rs | 17 ----------------- libraries/opensk/Cargo.toml | 2 +- libraries/opensk/src/api/key_store.rs | 2 -- 5 files changed, 2 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8aeae9ce..2f791ccf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ debug_ctap = ["libtock_drivers/debug_ctap", "opensk/debug_ctap"] panic_console = ["lang_items/panic_console"] std = ["crypto/std", "lang_items/std", "persistent_store/std", "opensk/std", "libtock_unittest"] verbose = ["debug_ctap", "libtock_drivers/verbose_usb"] -with_ctap1 = ["crypto/with_ctap1", "opensk/with_ctap1"] +with_ctap1 = ["opensk/with_ctap1"] with_nfc = ["libtock_drivers/with_nfc"] vendor_hid = ["opensk/vendor_hid"] ed25519 = ["ed25519-compact", "opensk/ed25519"] diff --git a/libraries/crypto/Cargo.toml b/libraries/crypto/Cargo.toml index 989a8dee..89ae2c7b 100644 --- a/libraries/crypto/Cargo.toml +++ b/libraries/crypto/Cargo.toml @@ -24,4 +24,3 @@ zeroize = { version = "1.5.7", features = ["derive"] } [features] std = ["hex", "ring", "untrusted", "serde", "serde_json", "regex", "rand_core/getrandom"] -with_ctap1 = [] diff --git a/libraries/crypto/src/ecdsa.rs b/libraries/crypto/src/ecdsa.rs index ca29b8da..e1e6e9cb 100644 --- a/libraries/crypto/src/ecdsa.rs +++ b/libraries/crypto/src/ecdsa.rs @@ -229,9 +229,6 @@ impl Signature { } impl PubKey { - #[cfg(feature = "with_ctap1")] - const UNCOMPRESSED_LENGTH: usize = 1 + 2 * int256::NBYTES; - /// Creates a new PubKey from its coordinates on the elliptic curve. pub fn from_coordinates(x: &[u8; NBYTES], y: &[u8; NBYTES]) -> Option { PointP256::new_checked_vartime(Int256::from_bin(x), Int256::from_bin(y)) @@ -247,20 +244,6 @@ impl PubKey { self.p.to_bytes_uncompressed(bytes); } - #[cfg(feature = "with_ctap1")] - pub fn to_uncompressed(&self) -> [u8; PubKey::UNCOMPRESSED_LENGTH] { - // Formatting according to: - // https://tools.ietf.org/id/draft-jivsov-ecc-compact-05.html#overview - const B0_BYTE_MARKER: u8 = 0x04; - let mut representation = [0; PubKey::UNCOMPRESSED_LENGTH]; - let (marker, x, y) = - mut_array_refs![&mut representation, 1, int256::NBYTES, int256::NBYTES]; - marker[0] = B0_BYTE_MARKER; - self.p.getx().to_int().to_bin(x); - self.p.gety().to_int().to_bin(y); - representation - } - /// Writes the coordinates into the passed in arrays. pub fn to_coordinates(&self, x: &mut [u8; NBYTES], y: &mut [u8; NBYTES]) { self.p.getx().to_int().to_bin(x); diff --git a/libraries/opensk/Cargo.toml b/libraries/opensk/Cargo.toml index 707af94e..14bbd1ff 100644 --- a/libraries/opensk/Cargo.toml +++ b/libraries/opensk/Cargo.toml @@ -40,7 +40,7 @@ default = ["config_command", "with_ctap1"] config_command = [] debug_ctap = [] std = ["crypto/std", "persistent_store/std", "rand/std_rng", "config_command"] -with_ctap1 = ["crypto/with_ctap1"] +with_ctap1 = [] vendor_hid = [] fuzz = ["arbitrary", "std"] ed25519 = ["ed25519-compact"] diff --git a/libraries/opensk/src/api/key_store.rs b/libraries/opensk/src/api/key_store.rs index 4121da12..c50ff36e 100644 --- a/libraries/opensk/src/api/key_store.rs +++ b/libraries/opensk/src/api/key_store.rs @@ -375,11 +375,9 @@ fn extract_map(cbor_value: cbor::Value) -> Result