Skip to content

Commit

Permalink
Fix new Clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddrysdale committed Jun 24, 2024
1 parent 7d1028f commit c79df12
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ include!("codegen/google.crypto.tink.rs");
#[cfg(feature = "json")]
include!("codegen/serde/google.crypto.tink.rs");

// Manual keyset serialization implementations that map enums onto strings rather than
// the `i32` values used by [prost](https://docs.rs/prost).
#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
pub mod json {
//! Manual keyset serialization implementations that map enums onto strings rather than
//! the `i32` values used by [prost](https://docs.rs/prost).
pub mod key_status_type {
//! Manual JSON serialization for [`KeyStatusType`](crate::KeyStatusType) enums.
use serde::Deserialize;
Expand Down
9 changes: 2 additions & 7 deletions signature/src/subtle/ecdsa_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use generic_array::typenum::Unsigned;
use p256::elliptic_curve;
use signature::RandomizedSigner;
use std::convert::TryInto;
use tink_core::{utils::wrap_err, TinkError};
use tink_proto::{EcdsaSignatureEncoding, EllipticCurveType, HashType};

Expand Down Expand Up @@ -63,12 +62,8 @@ impl EcdsaSigner {
return Err("EcdsaSigner: invalid private key len".into());
}
EcdsaPrivateKey::NistP256(
p256::ecdsa::SigningKey::from_bytes(
key_value
.try_into()
.map_err(|e| wrap_err("EcdsaSigner: invalid private key", e))?,
)
.map_err(|e| wrap_err("EcdsaSigner: invalid private key", e))?,
p256::ecdsa::SigningKey::from_bytes(key_value.into())
.map_err(|e| wrap_err("EcdsaSigner: invalid private key", e))?,
)
}
_ => return Err(format!("EcdsaSigner: unsupported curve {curve:?}").into()),
Expand Down
2 changes: 1 addition & 1 deletion testing/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ use log::info;
use structopt::StructOpt;
use tonic::transport::Server;

#[allow(clippy::wrong_self_convention)]
pub mod proto {
//! Auto-generated code from protocol buffer message and service definitions.
#![allow(clippy::wrong_self_convention)]
#![allow(clippy::large_enum_variant)]
#![allow(clippy::derive_partial_eq_without_eq)]
include!("codegen/tink_testing_api.rs");
Expand Down
2 changes: 1 addition & 1 deletion tests/src/testdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn key_template_proto(dir: &str, name: &str) -> Result<KeyTemplate, TinkErro
let value_re = Regex::new(r#"^\s*value\s*:\s*"(.+)"\s*$"#).unwrap();
let prefix_re = Regex::new(r#"^\s*output_prefix_type\s*:\s*(\S+)\s*$"#).unwrap();
let file = std::fs::File::open(&path).map_err(|e| wrap_err("Failed to open", e))?;
for line in std::io::BufReader::new(file).lines().flatten() {
for line in std::io::BufReader::new(file).lines().map_while(Result::ok) {
if comment_re.is_match(&line) {
continue;
}
Expand Down
1 change: 1 addition & 0 deletions tests/tests/aead/subtle/wycheproof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct TestData {
pub test_groups: Vec<TestGroup>,
}

#[allow(dead_code)]
#[derive(Debug, Deserialize)]
pub struct TestGroup {
#[serde(flatten)]
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/daead/factory_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ fn test_factory_raw_key_as_primary() {

// Return an `Err` if decryption fails, panic if something else goes wrong.
#[allow(clippy::borrowed_box)]
fn validate_daead_factory_cipher<T: ?Sized>(
fn validate_daead_factory_cipher<T>(
encrypt_cipher: &Box<T>,
decrypt_cipher: &Box<T>,
expected_prefix: &[u8],
) -> Result<(), TinkError>
where
T: tink_core::DeterministicAead,
T: tink_core::DeterministicAead + ?Sized,
{
let prefix_size = expected_prefix.len();
// regular plaintext.
Expand Down
2 changes: 2 additions & 0 deletions tests/tests/mac/subtle/cmac_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ lazy_static! {
};
}

#[allow(dead_code)]
#[derive(Debug, Deserialize)]
pub struct TestData {
#[serde(flatten)]
Expand All @@ -42,6 +43,7 @@ pub struct TestData {
pub test_groups: Vec<TestGroup>,
}

#[allow(dead_code)]
#[derive(Debug, Deserialize)]
pub struct TestGroup {
#[serde(flatten)]
Expand Down
2 changes: 2 additions & 0 deletions tests/tests/prf/subtle/aes_cmac_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fn test_vectors_rfc4493() {
}
}

#[allow(dead_code)]
#[derive(Debug, Deserialize)]
pub struct TestData {
#[serde(flatten)]
Expand All @@ -51,6 +52,7 @@ pub struct TestData {
pub test_groups: Vec<TestGroup>,
}

#[allow(dead_code)]
#[derive(Debug, Deserialize)]
pub struct TestGroup {
#[serde(flatten)]
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/signature/ecdsa_signer_key_manager_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn test_ecdsa_sign_new_key_with_invalid_input() {
let km = tink_core::registry::get_key_manager(tink_tests::ECDSA_SIGNER_TYPE_URL)
.expect("cannot obtain EcdsaSigner key manager");
// invalid hash and curve type
let test_params = vec![
let test_params = [
EcdsaParams {
hash_type: HashType::UnknownHash as i32,
curve: EllipticCurveType::NistP256 as i32,
Expand Down

0 comments on commit c79df12

Please sign in to comment.