Skip to content

Commit

Permalink
Satiate clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Jan 31, 2025
1 parent cc9f704 commit 84a21eb
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion aws-lc-fips-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl crate::Builder for CmakeBuilder {
} else {
eprintln!("Missing dependency: cmake");
missing_dependency = true;
};
}

if missing_dependency {
return Err("Required build dependency is missing. Halting build.".to_owned());
Expand Down
6 changes: 3 additions & 3 deletions aws-lc-rs/src/agreement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ impl AsDer<PublicKeyX509Der<'static>> for PublicKey {
let mut der = LcCBB::new(key_size_bytes * 5);
if 1 != unsafe { EVP_marshal_public_key(der.as_mut_ptr(), *evp_pkey.as_const()) } {
return Err(Unspecified);
};
}
Ok(PublicKeyX509Der::from(der.into_buffer()?))
}
}
Expand Down Expand Up @@ -794,7 +794,7 @@ fn ec_key_ecdh<'a>(

if 1 != unsafe { EVP_PKEY_derive_init(*pkey_ctx.as_mut()) } {
return Err(());
};
}

if 1 != unsafe { EVP_PKEY_derive_set_peer(*pkey_ctx.as_mut(), *pub_key.as_mut()) } {
return Err(());
Expand Down Expand Up @@ -825,7 +825,7 @@ fn x25519_diffie_hellman<'a>(

if 1 != unsafe { EVP_PKEY_derive_init(*pkey_ctx.as_mut()) } {
return Err(());
};
}

let mut pub_key = try_parse_x25519_public_key_bytes(peer_pub_key)?;

Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/cbb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl LcCBB<'static> {

if 1 != unsafe { CBB_finish(self.as_mut_ptr(), &mut out_data, &mut out_len) } {
return Err(Unspecified);
};
}

let mut out_data = LcPtr::new(out_data)?;

Expand Down
4 changes: 2 additions & 2 deletions aws-lc-rs/src/digest/digest_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl DigestContext {
unsafe {
if 1 != EVP_DigestInit_ex(dc.as_mut_ptr(), *evp_md_type, null_mut()) {
return Err(Unspecified);
};
}
Ok(dc)
}
}
Expand Down Expand Up @@ -65,7 +65,7 @@ impl DigestContext {
// https://github.com/aws/aws-lc/blob/98ccf4a316401112943bed604562102ad52efac6/include/openssl/digest.h#L280
if 1 != EVP_MD_CTX_copy(dc.as_mut_ptr(), self.as_ptr()) {
return Err("EVP_MD_CTX_copy failed");
};
}
Ok(Self(dc.assume_init()))
}
}
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/hkdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl PrkMode {
return Err(Unspecified);
}
}
};
}

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/hmac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ impl Key {
null_mut(),
) {
return Err(Unspecified);
};
}
let result = Self {
algorithm,
ctx: LcHmacCtx(ctx.assume_init()),
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/key_wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ impl KeyWrapPadded for KeyEncryptionKey<AesBlockCipher> {
)
}) {
return Err(Unspecified);
};
}

Ok(&mut output[..out_len])
}
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/rsa/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub(in crate::rsa) mod rfc5280 {

if 1 != unsafe { EVP_marshal_public_key(der.as_mut_ptr(), *key.as_const()) } {
return Err(Unspecified);
};
}

Ok(PublicKeyX509Der::from(der.into_buffer()?))
}
Expand Down
4 changes: 2 additions & 2 deletions aws-lc-rs/src/rsa/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl PrivateDecryptingKey {
fn validate_key(key: &LcPtr<EVP_PKEY>) -> Result<(), Unspecified> {
if !is_rsa_key(key) {
return Err(Unspecified);
};
}
match key_size_bits(key) {
2048..=8192 => Ok(()),
_ => Err(Unspecified),
Expand Down Expand Up @@ -149,7 +149,7 @@ impl PublicEncryptingKey {
fn validate_key(key: &LcPtr<EVP_PKEY>) -> Result<(), Unspecified> {
if !is_rsa_key(key) {
return Err(Unspecified);
};
}
match key_size_bits(key) {
2048..=8192 => Ok(()),
_ => Err(Unspecified),
Expand Down
12 changes: 6 additions & 6 deletions aws-lc-rs/src/rsa/encryption/oaep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl OaepPublicEncryptingKey {
)
}) {
return Err(Unspecified);
};
}

Ok(&mut ciphertext[..out_len])
}
Expand Down Expand Up @@ -240,7 +240,7 @@ impl OaepPrivateDecryptingKey {
)
}) {
return Err(Unspecified);
};
}

Ok(&mut plaintext[..out_len])
}
Expand Down Expand Up @@ -280,15 +280,15 @@ fn configure_oaep_crypto_operation(
if 1 != unsafe { EVP_PKEY_CTX_set_rsa_padding(*evp_pkey_ctx.as_mut(), RSA_PKCS1_OAEP_PADDING) }
{
return Err(Unspecified);
};
}

if 1 != unsafe { EVP_PKEY_CTX_set_rsa_oaep_md(*evp_pkey_ctx.as_mut(), oaep_hash_fn()) } {
return Err(Unspecified);
};
}

if 1 != unsafe { EVP_PKEY_CTX_set_rsa_mgf1_md(*evp_pkey_ctx.as_mut(), mgf1_hash_fn()) } {
return Err(Unspecified);
};
}

let label = label.unwrap_or(&[0u8; 0]);

Expand All @@ -315,7 +315,7 @@ fn configure_oaep_crypto_operation(
EVP_PKEY_CTX_set0_rsa_oaep_label(*evp_pkey_ctx.as_mut(), *label_ptr, label.len())
} {
return Err(Unspecified);
};
}

// AWS-LC owns the allocation now, so we detach it to avoid freeing it here when label_ptr goes out of scope.
label_ptr.detach();
Expand Down
6 changes: 3 additions & 3 deletions aws-lc-rs/src/rsa/encryption/pkcs1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Pkcs1PublicEncryptingKey {
)
}) {
return Err(Unspecified);
};
}

Ok(&mut ciphertext[..out_len])
}
Expand Down Expand Up @@ -149,7 +149,7 @@ impl Pkcs1PrivateDecryptingKey {
)
}) {
return Err(Unspecified);
};
}

Ok(&mut plaintext[..out_len])
}
Expand Down Expand Up @@ -185,7 +185,7 @@ fn configure_pkcs1_crypto_operation(
) -> Result<(), Unspecified> {
if 1 != unsafe { EVP_PKEY_CTX_set_rsa_padding(*evp_pkey_ctx.as_mut(), RSA_PKCS1_PADDING) } {
return Err(Unspecified);
};
}

Ok(())
}
4 changes: 2 additions & 2 deletions aws-lc-rs/src/rsa/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl KeyPair {
fn validate_private_key(key: &LcPtr<EVP_PKEY>) -> Result<(), KeyRejected> {
if !is_rsa_key(key) {
return Err(KeyRejected::unspecified());
};
}
match key_size_bits(key) {
2048..=8192 => Ok(()),
_ => Err(KeyRejected::unspecified()),
Expand Down Expand Up @@ -487,7 +487,7 @@ pub(super) fn generate_rsa_key(size: c_int, fips: bool) -> Result<LcPtr<EVP_PKEY

if 1 != unsafe { EVP_PKEY_assign_RSA(*evp_pkey.as_mut(), *rsa) } {
return Err(Unspecified);
};
}

rsa.detach();

Expand Down
4 changes: 2 additions & 2 deletions aws-lc-rs/src/rsa/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ pub(super) fn compute_rsa_signature<'a>(
pub(crate) fn configure_rsa_pkcs1_pss_padding(pctx: *mut EVP_PKEY_CTX) -> Result<(), ()> {
if 1 != unsafe { EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING) } {
return Err(());
};
}
if 1 != unsafe { EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, RSA_PSS_SALTLEN_DIGEST) } {
return Err(());
};
}
Ok(())
}

Expand Down
4 changes: 2 additions & 2 deletions aws-lc-rs/tests/aead_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ fn test_aead<Seal, Open>(
return Ok(());
}
_ => (),
};
}

let mut s_in_out = plaintext.clone();
let nonce = Nonce::try_assume_unique_for_key(&nonce_bytes).unwrap();
Expand Down Expand Up @@ -242,7 +242,7 @@ fn test_aead<Seal, Open>(
Some(error) => {
panic!("Unexpected error test case: {error}");
}
};
}
}

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions aws-lc-rs/tests/ecdsa_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn ecdsa_from_pkcs8_test() {
"Input: {}",
test::to_hex(&input)
),
};
}

match (EcdsaKeyPair::from_pkcs8(this_asn1, &input), error) {
(Ok(_), None) => (),
Expand All @@ -93,7 +93,7 @@ fn ecdsa_from_pkcs8_test() {
}
(Ok(_), Some(e)) => panic!("Succeeded, but expected error \"{e}\""),
(Err(actual), Some(expected)) => assert_eq!(format!("{actual}"), expected),
};
}

assert!(
EcdsaKeyPair::from_pkcs8(other_fixed, &input).is_err(),
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/tests/ed25519_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn test_ed25519_from_pkcs8() {
test::to_hex(input)
);
}
};
}
}

// Just test that we can parse the input.
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/tests/rsa_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn rsa_from_pkcs8_test() {
"Input: {}",
test::to_hex(input.as_slice())
),
};
}

Ok(())
},
Expand Down
4 changes: 2 additions & 2 deletions aws-lc-sys/builder/cc_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl CcBuilder {
cc_build.std("c99");
}
}
};
}

if let Some(cc) = option_env("CC") {
emit_warning(&format!("CC environment variable set: {}", cc.clone()));
Expand Down Expand Up @@ -399,7 +399,7 @@ impl crate::Builder for CcBuilder {
}

if Some(true) == env_var_to_bool("CARGO_FEATURE_SSL") {
return Err(format!("cc_builder for libssl not supported"));
return Err("cc_builder for libssl not supported".to_string());
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-sys/builder/cmake_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ impl crate::Builder for CmakeBuilder {
} else {
eprintln!("Missing dependency: cmake");
missing_dependency = true;
};
}

if missing_dependency {
return Err("Required build dependency is missing. Halting build.".to_owned());
Expand Down

0 comments on commit 84a21eb

Please sign in to comment.