From 522e6079e3a879bf8c14fab992e050298533496d Mon Sep 17 00:00:00 2001 From: kaczmarczyck <43844792+kaczmarczyck@users.noreply.github.com> Date: Tue, 30 Nov 2021 11:07:17 +0100 Subject: [PATCH] Forward desktop test fixes (#419) * fixes clippy warnings for compilers until 2021-11-25 * fixes run_desktop_tests * removes page_size --- examples/store_latency.rs | 8 +++----- libraries/crypto/Cargo.toml | 2 +- src/ctap/client_pin.rs | 10 +++++----- src/ctap/command.rs | 1 + src/ctap/data_formats.rs | 5 +++-- src/ctap/hid/mod.rs | 2 +- src/ctap/hid/receive.rs | 2 +- src/ctap/mod.rs | 6 +++--- src/ctap/response.rs | 1 + src/ctap/storage.rs | 2 +- 10 files changed, 20 insertions(+), 19 deletions(-) diff --git a/examples/store_latency.rs b/examples/store_latency.rs index 9b5ee7e..2ea3a91 100644 --- a/examples/store_latency.rs +++ b/examples/store_latency.rs @@ -54,7 +54,6 @@ unsafe fn boot_store(erase: bool) -> Store { #[derive(Debug)] struct StorageConfig { - page_size: usize, num_pages: usize, } @@ -62,7 +61,6 @@ fn storage_config() -> StorageConfig { use persistent_store::Storage; let storage = new_storage().unwrap(); StorageConfig { - page_size: storage.page_size(), num_pages: storage.num_pages(), } } @@ -120,7 +118,7 @@ fn compute_latency( // Measure latency of insert. let key = 1 + key_increment * count; - let ((), time) = measure(&timer, || { + let ((), time) = measure(timer, || { store.insert(key, &vec![0; 4 * word_length]).unwrap() }); writeln!(console, "Insert: {:.1}ms.", time.ms()).unwrap(); @@ -131,12 +129,12 @@ fn compute_latency( ); // Measure latency of boot. - let (mut store, time) = measure(&timer, || unsafe { boot_store(false) }); + let (mut store, time) = measure(timer, || unsafe { boot_store(false) }); writeln!(console, "Boot: {:.1}ms.", time.ms()).unwrap(); stat.boot_ms = time.ms(); // Measure latency of remove. - let ((), time) = measure(&timer, || store.remove(key).unwrap()); + let ((), time) = measure(timer, || store.remove(key).unwrap()); writeln!(console, "Remove: {:.1}ms.", time.ms()).unwrap(); stat.remove_ms = time.ms(); diff --git a/libraries/crypto/Cargo.toml b/libraries/crypto/Cargo.toml index 7c0a45f..13c7361 100644 --- a/libraries/crypto/Cargo.toml +++ b/libraries/crypto/Cargo.toml @@ -19,7 +19,7 @@ ring = { version = "0.16.11", optional = true } untrusted = { version = "0.7.0", optional = true } rand = { version = "0.6.5", optional = true } serde = { version = "1.0", optional = true, features = ["derive"] } -serde_json = { version = "1.0", optional = true } +serde_json = { version = "=1.0.69", optional = true } regex = { version = "1", optional = true } [features] diff --git a/src/ctap/client_pin.rs b/src/ctap/client_pin.rs index 8b6588e..e4b0a02 100644 --- a/src/ctap/client_pin.rs +++ b/src/ctap/client_pin.rs @@ -1553,16 +1553,16 @@ mod test { .get_pin_protocol(PinUvAuthProtocol::V1) .get_pin_uv_auth_token(); let pin_uv_auth_param_v1 = - authenticate_pin_uv_auth_token(&pin_uv_auth_token_v1, &message, PinUvAuthProtocol::V1); + authenticate_pin_uv_auth_token(pin_uv_auth_token_v1, &message, PinUvAuthProtocol::V1); let pin_uv_auth_token_v2 = client_pin .get_pin_protocol(PinUvAuthProtocol::V2) .get_pin_uv_auth_token(); let pin_uv_auth_param_v2 = - authenticate_pin_uv_auth_token(&pin_uv_auth_token_v2, &message, PinUvAuthProtocol::V2); + authenticate_pin_uv_auth_token(pin_uv_auth_token_v2, &message, PinUvAuthProtocol::V2); let pin_uv_auth_param_v1_from_v2_token = - authenticate_pin_uv_auth_token(&pin_uv_auth_token_v2, &message, PinUvAuthProtocol::V1); + authenticate_pin_uv_auth_token(pin_uv_auth_token_v2, &message, PinUvAuthProtocol::V1); let pin_uv_auth_param_v2_from_v1_token = - authenticate_pin_uv_auth_token(&pin_uv_auth_token_v1, &message, PinUvAuthProtocol::V2); + authenticate_pin_uv_auth_token(pin_uv_auth_token_v1, &message, PinUvAuthProtocol::V2); assert_eq!( client_pin.verify_pin_uv_auth_token( @@ -1624,7 +1624,7 @@ mod test { .get_pin_protocol(PinUvAuthProtocol::V1) .get_pin_uv_auth_token(); let pin_uv_auth_param_v1 = - authenticate_pin_uv_auth_token(&pin_uv_auth_token_v1, &message, PinUvAuthProtocol::V1); + authenticate_pin_uv_auth_token(pin_uv_auth_token_v1, &message, PinUvAuthProtocol::V1); assert_eq!( client_pin.verify_pin_uv_auth_token( diff --git a/src/ctap/command.rs b/src/ctap/command.rs index c5ed7c6..6c06205 100644 --- a/src/ctap/command.rs +++ b/src/ctap/command.rs @@ -37,6 +37,7 @@ const MIN_LARGE_BLOB_LEN: usize = 17; // CTAP specification (version 20190130) section 6.1 #[derive(Debug, PartialEq)] +#[allow(clippy::enum_variant_names)] pub enum Command { AuthenticatorMakeCredential(AuthenticatorMakeCredentialParameters), AuthenticatorGetAssertion(AuthenticatorGetAssertionParameters), diff --git a/src/ctap/data_formats.rs b/src/ctap/data_formats.rs index b91b1cc..fc0df1a 100644 --- a/src/ctap/data_formats.rs +++ b/src/ctap/data_formats.rs @@ -515,6 +515,7 @@ impl TryFrom for SignatureAlgorithm { /// The credProtect extension's policies for resident credentials. #[derive(Clone, Copy, Debug, PartialEq, PartialOrd)] #[cfg_attr(test, derive(IntoEnumIterator))] +#[allow(clippy::enum_variant_names)] pub enum CredentialProtectionPolicy { /// The credential is always discoverable, as if it had no protection level. UserVerificationOptional = 0x01, @@ -1983,7 +1984,7 @@ mod test { assert_eq!(created_cbor, cbor_sub_command); for command in ConfigSubCommand::into_enum_iter() { - let created_cbor: cbor::Value = command.clone().into(); + let created_cbor: cbor::Value = command.into(); let reconstructed = ConfigSubCommand::try_from(created_cbor).unwrap(); assert_eq!(command, reconstructed); } @@ -2053,7 +2054,7 @@ mod test { assert_eq!(created_cbor, cbor_sub_command); for command in CredentialManagementSubCommand::into_enum_iter() { - let created_cbor: cbor::Value = command.clone().into(); + let created_cbor: cbor::Value = command.into(); let reconstructed = CredentialManagementSubCommand::try_from(created_cbor).unwrap(); assert_eq!(command, reconstructed); } diff --git a/src/ctap/hid/mod.rs b/src/ctap/hid/mod.rs index c6fc418..57f2875 100644 --- a/src/ctap/hid/mod.rs +++ b/src/ctap/hid/mod.rs @@ -607,7 +607,7 @@ mod test { let mut assembler_reply = MessageAssembler::new(); for pkt_request in &[packet1, packet2] { for pkt_reply in - ctap_hid.process_hid_packet(&pkt_request, DUMMY_CLOCK_VALUE, &mut ctap_state) + ctap_hid.process_hid_packet(pkt_request, DUMMY_CLOCK_VALUE, &mut ctap_state) { if let Some(message) = assembler_reply .parse_packet(&pkt_reply, DUMMY_TIMESTAMP) diff --git a/src/ctap/hid/receive.rs b/src/ctap/hid/receive.rs index caf9ffc..08929b0 100644 --- a/src/ctap/hid/receive.rs +++ b/src/ctap/hid/receive.rs @@ -91,7 +91,7 @@ impl MessageAssembler { ) -> Result, (ChannelID, Error)> { // TODO: Support non-full-speed devices (i.e. packet len != 64)? This isn't recommended by // section 8.8.1 - let (cid, processed_packet) = CtapHid::process_single_packet(&packet); + let (cid, processed_packet) = CtapHid::process_single_packet(packet); if !self.idle && timestamp - self.last_timestamp >= CtapHid::TIMEOUT_DURATION { // The current channel timed out. diff --git a/src/ctap/mod.rs b/src/ctap/mod.rs index c6e0fe8..120feae 100644 --- a/src/ctap/mod.rs +++ b/src/ctap/mod.rs @@ -131,8 +131,8 @@ pub fn cbor_read(encoded_cbor: &[u8]) -> Result { .map_err(|_e| Ctap2StatusCode::CTAP2_ERR_INVALID_CBOR) } -fn cbor_write(value: cbor::Value, mut encoded_cbor: &mut Vec) -> Result<(), Ctap2StatusCode> { - cbor::writer::write_nested(value, &mut encoded_cbor, Some(MAX_CBOR_NESTING_DEPTH)) +fn cbor_write(value: cbor::Value, encoded_cbor: &mut Vec) -> Result<(), Ctap2StatusCode> { + cbor::writer::write_nested(value, encoded_cbor, Some(MAX_CBOR_NESTING_DEPTH)) .map_err(|_e| Ctap2StatusCode::CTAP2_ERR_VENDOR_INTERNAL_ERROR) } @@ -939,7 +939,7 @@ where return Ok(credential); } let credential = - self.decrypt_credential_source(allowed_credential.key_id, &rp_id_hash)?; + self.decrypt_credential_source(allowed_credential.key_id, rp_id_hash)?; if credential.is_some() { return Ok(credential); } diff --git a/src/ctap/response.rs b/src/ctap/response.rs index 709518e..efff848 100644 --- a/src/ctap/response.rs +++ b/src/ctap/response.rs @@ -25,6 +25,7 @@ use sk_cbor::{ }; #[derive(Debug, PartialEq)] +#[allow(clippy::enum_variant_names)] pub enum ResponseData { AuthenticatorMakeCredential(AuthenticatorMakeCredentialResponse), AuthenticatorGetAssertion(AuthenticatorGetAssertionResponse), diff --git a/src/ctap/storage.rs b/src/ctap/storage.rs index 2ee0356..b84856f 100644 --- a/src/ctap/storage.rs +++ b/src/ctap/storage.rs @@ -709,7 +709,7 @@ impl<'a> Iterator for IterCredentials<'a> { if !key::CREDENTIALS.contains(&key) { continue; } - let value = self.unwrap(handle.get_value(&self.store).ok())?; + let value = self.unwrap(handle.get_value(self.store).ok())?; let credential = self.unwrap(deserialize_credential(&value))?; return Some((key, credential)); }