Skip to content

Commit

Permalink
Fix RustRover insight (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth authored Jan 23, 2025
1 parent 734f8de commit 76bcc06
Show file tree
Hide file tree
Showing 37 changed files with 99 additions and 97 deletions.
8 changes: 4 additions & 4 deletions aws-lc-rs/src/aead/aead_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ use core::ptr::null_mut;

use crate::cipher::chacha;

use crate::cipher::aes::{AES_128_KEY_LEN, AES_192_KEY_LEN, AES_256_KEY_LEN};
use crate::error::Unspecified;
use crate::ptr::LcPtr;
use aws_lc::{
use crate::aws_lc::{
evp_aead_direction_t, evp_aead_direction_t_evp_aead_open, evp_aead_direction_t_evp_aead_seal,
EVP_AEAD_CTX_init, EVP_AEAD_CTX_init_with_direction, EVP_AEAD_CTX_zero, EVP_aead_aes_128_gcm,
EVP_aead_aes_128_gcm_randnonce, EVP_aead_aes_128_gcm_siv, EVP_aead_aes_128_gcm_tls12,
EVP_aead_aes_128_gcm_tls13, EVP_aead_aes_192_gcm, EVP_aead_aes_256_gcm,
EVP_aead_aes_256_gcm_randnonce, EVP_aead_aes_256_gcm_siv, EVP_aead_aes_256_gcm_tls12,
EVP_aead_aes_256_gcm_tls13, EVP_aead_chacha20_poly1305, OPENSSL_malloc, EVP_AEAD_CTX,
};
use crate::cipher::aes::{AES_128_KEY_LEN, AES_192_KEY_LEN, AES_256_KEY_LEN};
use crate::error::Unspecified;
use crate::ptr::LcPtr;

pub(crate) enum AeadDirection {
Open,
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/aead/poly1305.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// TODO: enforce maximum input length.

use super::{Tag, TAG_LEN};
use crate::aws_lc::{CRYPTO_poly1305_finish, CRYPTO_poly1305_init, CRYPTO_poly1305_update};
use crate::cipher::block::BLOCK_LEN;
use aws_lc::{CRYPTO_poly1305_finish, CRYPTO_poly1305_init, CRYPTO_poly1305_update};
use core::mem::MaybeUninit;

/// A Poly1305 key.
Expand Down
6 changes: 3 additions & 3 deletions aws-lc-rs/src/aead/unbound_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use super::{aead_ctx::AeadCtx, Algorithm, Nonce, MAX_KEY_LEN, MAX_TAG_LEN, NONCE
use super::{
Tag, AES_128_GCM, AES_128_GCM_SIV, AES_192_GCM, AES_256_GCM, AES_256_GCM_SIV, CHACHA20_POLY1305,
};
use crate::iv::FixedLength;
use crate::{error::Unspecified, fips::indicator_check, hkdf};
use aws_lc::{
use crate::aws_lc::{
EVP_AEAD_CTX_open, EVP_AEAD_CTX_open_gather, EVP_AEAD_CTX_seal, EVP_AEAD_CTX_seal_scatter,
};
use crate::iv::FixedLength;
use crate::{error::Unspecified, fips::indicator_check, hkdf};
use core::fmt::Debug;
use core::{mem::MaybeUninit, ops::RangeFrom, ptr::null};

Expand Down
14 changes: 7 additions & 7 deletions aws-lc-rs/src/agreement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ mod ephemeral;

pub use ephemeral::{agree_ephemeral, EphemeralPrivateKey};

use crate::cbb::LcCBB;
use crate::ec::{ec_group_from_nid, evp_key_generate};
use crate::error::{KeyRejected, Unspecified};
use crate::fips::indicator_check;
use crate::ptr::{ConstPointer, LcPtr};
use crate::{ec, hex};
use aws_lc::{
use crate::aws_lc::{
CBS_init, EVP_PKEY_CTX_new_id, EVP_PKEY_bits, EVP_PKEY_derive, EVP_PKEY_derive_init,
EVP_PKEY_derive_set_peer, EVP_PKEY_get0_EC_KEY, EVP_PKEY_get_raw_private_key,
EVP_PKEY_get_raw_public_key, EVP_PKEY_id, EVP_PKEY_keygen, EVP_PKEY_keygen_init,
EVP_PKEY_new_raw_private_key, EVP_PKEY_new_raw_public_key, EVP_marshal_public_key,
EVP_parse_public_key, NID_X9_62_prime256v1, NID_secp384r1, NID_secp521r1, BIGNUM, CBS,
EVP_PKEY, EVP_PKEY_X25519, NID_X25519,
};
use crate::cbb::LcCBB;
use crate::ec::{ec_group_from_nid, evp_key_generate};
use crate::error::{KeyRejected, Unspecified};
use crate::fips::indicator_check;
use crate::ptr::{ConstPointer, LcPtr};
use crate::{ec, hex};

use crate::encoding::{
AsBigEndian, AsDer, Curve25519SeedBin, EcPrivateKeyBin, EcPrivateKeyRfc5915Der,
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/bn.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR ISC

use crate::aws_lc::{BN_bin2bn, BN_bn2bin, BN_new, BN_num_bits, BN_num_bytes, BN_set_u64, BIGNUM};
use crate::ptr::{ConstPointer, DetachableLcPtr, LcPtr};
use aws_lc::{BN_bin2bn, BN_bn2bin, BN_new, BN_num_bits, BN_num_bytes, BN_set_u64, BIGNUM};
use core::ptr::null_mut;

impl TryFrom<&[u8]> for LcPtr<BIGNUM> {
Expand Down
4 changes: 2 additions & 2 deletions aws-lc-rs/src/cbb.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR ISC

use crate::aws_lc::{CBB_cleanup, CBB_finish, CBB_init, CBB_init_fixed, CBB};
use crate::buffer::Buffer;
use crate::error::Unspecified;
use crate::ptr::LcPtr;
use aws_lc::{CBB_cleanup, CBB_finish, CBB_init, CBB_init_fixed, CBB};
use core::marker::PhantomData;
use core::mem::MaybeUninit;
use core::ptr::null_mut;
Expand Down Expand Up @@ -76,7 +76,7 @@ impl Drop for LcCBB<'_> {
#[cfg(test)]
mod tests {
use super::LcCBB;
use aws_lc::CBB_add_asn1_bool;
use crate::aws_lc::CBB_add_asn1_bool;

#[test]
fn dynamic_buffer() {
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/cbs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR ISC

use aws_lc::{CBS_init, CBS};
use crate::aws_lc::{CBS_init, CBS};
use core::mem::MaybeUninit;

#[inline]
Expand Down
10 changes: 5 additions & 5 deletions aws-lc-rs/src/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,17 @@ mod streaming;
pub use padded::{PaddedBlockDecryptingKey, PaddedBlockEncryptingKey};
pub use streaming::{BufferUpdate, StreamingDecryptingKey, StreamingEncryptingKey};

use crate::aws_lc::{
EVP_aes_128_cbc, EVP_aes_128_cfb128, EVP_aes_128_ctr, EVP_aes_128_ecb, EVP_aes_192_cbc,
EVP_aes_192_cfb128, EVP_aes_192_ctr, EVP_aes_192_ecb, EVP_aes_256_cbc, EVP_aes_256_cfb128,
EVP_aes_256_ctr, EVP_aes_256_ecb, EVP_CIPHER,
};
use crate::buffer::Buffer;
use crate::error::Unspecified;
use crate::hkdf;
use crate::hkdf::KeyType;
use crate::iv::{FixedLength, IV_LEN_128_BIT};
use crate::ptr::ConstPointer;
use aws_lc::{
EVP_aes_128_cbc, EVP_aes_128_cfb128, EVP_aes_128_ctr, EVP_aes_128_ecb, EVP_aes_192_cbc,
EVP_aes_192_cfb128, EVP_aes_192_ctr, EVP_aes_192_ecb, EVP_aes_256_cbc, EVP_aes_256_cfb128,
EVP_aes_256_ctr, EVP_aes_256_ecb, EVP_CIPHER,
};
use core::fmt::Debug;
use key::SymmetricCipherKey;

Expand Down
4 changes: 2 additions & 2 deletions aws-lc-rs/src/cipher/aes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// Modifications copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR ISC

use crate::{cipher::block::Block, error::Unspecified, fips::indicator_check};
use aws_lc::{
use crate::aws_lc::{
AES_cbc_encrypt, AES_cfb128_encrypt, AES_ctr128_encrypt, AES_ecb_encrypt, AES_DECRYPT,
AES_ENCRYPT, AES_KEY,
};
use crate::{cipher::block::Block, error::Unspecified, fips::indicator_check};
use zeroize::Zeroize;

use super::{DecryptionContext, EncryptionContext, OperatingMode, SymmetricCipherKey};
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/cipher/chacha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// Modifications copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR ISC

use crate::aws_lc::CRYPTO_chacha_20;
use crate::cipher::block::{Block, BLOCK_LEN};
use aws_lc::CRYPTO_chacha_20;
use zeroize::Zeroize;

use crate::error;
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/cipher/key.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR ISC

use crate::aws_lc::{AES_set_decrypt_key, AES_set_encrypt_key, AES_KEY};
use crate::cipher::block::Block;
use crate::cipher::chacha::ChaCha20Key;
use crate::cipher::{AES_128_KEY_LEN, AES_192_KEY_LEN, AES_256_KEY_LEN};
use crate::error::Unspecified;
use aws_lc::{AES_set_decrypt_key, AES_set_encrypt_key, AES_KEY};
use core::mem::{size_of, MaybeUninit};
use core::ptr::copy_nonoverlapping;
// TODO: Uncomment when MSRV >= 1.64
Expand Down
10 changes: 5 additions & 5 deletions aws-lc-rs/src/cipher/streaming.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR ISC

use crate::aws_lc::{
EVP_CIPHER_CTX_new, EVP_CIPHER_iv_length, EVP_CIPHER_key_length, EVP_DecryptFinal_ex,
EVP_DecryptInit_ex, EVP_DecryptUpdate, EVP_EncryptFinal_ex, EVP_EncryptInit_ex,
EVP_EncryptUpdate, EVP_CIPHER, EVP_CIPHER_CTX,
};
use crate::cipher::{
Algorithm, DecryptionContext, EncryptionContext, OperatingMode, UnboundCipherKey,
};
use crate::error::Unspecified;
use crate::fips::indicator_check;
use crate::ptr::LcPtr;
use aws_lc::{
EVP_CIPHER_CTX_new, EVP_CIPHER_iv_length, EVP_CIPHER_key_length, EVP_DecryptFinal_ex,
EVP_DecryptInit_ex, EVP_DecryptUpdate, EVP_EncryptFinal_ex, EVP_EncryptInit_ex,
EVP_EncryptUpdate, EVP_CIPHER, EVP_CIPHER_CTX,
};
use std::ptr::{null, null_mut};

use super::ConstPointer;
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/constant_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

//! Constant-time operations.
use crate::aws_lc::CRYPTO_memcmp;
use crate::error;
use aws_lc::CRYPTO_memcmp;

/// Returns `Ok(())` if `a == b` and `Err(error::Unspecified)` otherwise.
///
Expand Down
6 changes: 3 additions & 3 deletions aws-lc-rs/src/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ use crate::{debug, derive_debug_via_id};

pub(crate) mod digest_ctx;
mod sha;
use crate::error::Unspecified;
use crate::ptr::ConstPointer;
use aws_lc::{
use crate::aws_lc::{
EVP_DigestFinal, EVP_DigestUpdate, EVP_sha1, EVP_sha224, EVP_sha256, EVP_sha384, EVP_sha3_256,
EVP_sha3_384, EVP_sha3_512, EVP_sha512, EVP_sha512_256, EVP_MD,
};
use crate::error::Unspecified;
use crate::ptr::ConstPointer;
use core::mem::MaybeUninit;
use digest_ctx::DigestContext;
pub use sha::{
Expand Down
4 changes: 3 additions & 1 deletion aws-lc-rs/src/digest/digest_ctx.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR ISC

use crate::aws_lc::{
EVP_DigestInit_ex, EVP_MD_CTX_cleanup, EVP_MD_CTX_copy, EVP_MD_CTX_init, EVP_MD_CTX,
};
use crate::digest::{match_digest_type, Algorithm};
use crate::error::Unspecified;
use aws_lc::{EVP_DigestInit_ex, EVP_MD_CTX_cleanup, EVP_MD_CTX_copy, EVP_MD_CTX_init, EVP_MD_CTX};
use core::mem::MaybeUninit;
use core::ptr::null_mut;

Expand Down
6 changes: 3 additions & 3 deletions aws-lc-rs/src/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use core::ptr::null_mut;
use std::os::raw::c_int;

#[cfg(feature = "fips")]
use aws_lc::EC_KEY_check_fips;
use crate::aws_lc::EC_KEY_check_fips;
#[cfg(not(feature = "fips"))]
use aws_lc::EC_KEY_check_key;
use aws_lc::{
use crate::aws_lc::EC_KEY_check_key;
use crate::aws_lc::{
d2i_PrivateKey, point_conversion_form_t, BN_bn2bin_padded, BN_num_bytes, CBS_init,
ECDSA_SIG_from_bytes, ECDSA_SIG_get0_r, ECDSA_SIG_get0_s, EC_GROUP_get_curve_name,
EC_GROUP_new_by_curve_name, EC_KEY_get0_group, EC_KEY_get0_private_key, EC_KEY_get0_public_key,
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/ec/key_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use core::fmt::{Debug, Formatter};
use core::mem::MaybeUninit;
use core::ptr::{null, null_mut};

use aws_lc::{EVP_DigestSign, EVP_DigestSignInit, EVP_PKEY_get0_EC_KEY, EVP_PKEY};
use crate::aws_lc::{EVP_DigestSign, EVP_DigestSignInit, EVP_PKEY_get0_EC_KEY, EVP_PKEY};

use crate::digest::digest_ctx::DigestContext;
use crate::ec::evp_key_generate;
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/ec/signature.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR ISC

use aws_lc::{
use crate::aws_lc::{
i2d_EC_PUBKEY, ECDSA_SIG_new, ECDSA_SIG_set0, ECDSA_SIG_to_bytes, EC_GROUP_new_by_curve_name,
EC_KEY_new, EC_KEY_set_group, EC_KEY_set_public_key, EVP_DigestVerify, EVP_DigestVerifyInit,
EVP_PKEY_get0_EC_KEY, NID_X9_62_prime256v1, NID_secp256k1, NID_secp384r1, NID_secp521r1,
Expand Down
2 changes: 1 addition & 1 deletion aws-lc-rs/src/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::marker::PhantomData;
#[cfg(feature = "ring-sig-verify")]
use untrusted::Input;

use aws_lc::{
use crate::aws_lc::{
CBS_init, EVP_DigestSign, EVP_DigestSignInit, EVP_DigestVerify, EVP_DigestVerifyInit,
EVP_PKEY_CTX_new_id, EVP_PKEY_get_raw_private_key, EVP_PKEY_get_raw_public_key, EVP_PKEY_id,
EVP_PKEY_keygen, EVP_PKEY_keygen_init, EVP_PKEY_new_raw_private_key,
Expand Down
10 changes: 5 additions & 5 deletions aws-lc-rs/src/evp_pkey.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR ISC

use crate::aws_lc::{
EVP_PKEY_CTX_new, EVP_PKEY_bits, EVP_PKEY_get1_EC_KEY, EVP_PKEY_get1_RSA, EVP_PKEY_id,
EVP_PKEY_up_ref, EVP_marshal_private_key, EVP_marshal_private_key_v2, EVP_parse_private_key,
EC_KEY, EVP_PKEY, EVP_PKEY_CTX, RSA,
};
use crate::cbb::LcCBB;
use crate::cbs;
use crate::ec::PKCS8_DOCUMENT_MAX_LEN;
use crate::error::{KeyRejected, Unspecified};
use crate::pkcs8::Version;
use crate::ptr::LcPtr;
use aws_lc::{
EVP_PKEY_CTX_new, EVP_PKEY_bits, EVP_PKEY_get1_EC_KEY, EVP_PKEY_get1_RSA, EVP_PKEY_id,
EVP_PKEY_up_ref, EVP_marshal_private_key, EVP_marshal_private_key_v2, EVP_parse_private_key,
EC_KEY, EVP_PKEY, EVP_PKEY_CTX, RSA,
};
// TODO: Uncomment when MSRV >= 1.64
// use core::ffi::c_int;
use std::os::raw::c_int;
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 @@ -37,11 +37,11 @@
//! let aead_unbound_key = aead::UnboundKey::from(aes_keying_material);
//! ```
use crate::aws_lc::{HKDF_expand, HKDF};
use crate::error::Unspecified;
use crate::fips::indicator_check;
use crate::{digest, hmac};
use alloc::sync::Arc;
use aws_lc::{HKDF_expand, HKDF};
use core::fmt;
use zeroize::Zeroize;

Expand Down
8 changes: 4 additions & 4 deletions aws-lc-rs/src/hmac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@
//! ```
//! [RFC 2104]: https://tools.ietf.org/html/rfc2104
use crate::error::Unspecified;
use crate::fips::indicator_check;
use crate::{constant_time, digest, hkdf};
use aws_lc::{
use crate::aws_lc::{
HMAC_CTX_cleanup, HMAC_CTX_copy_ex, HMAC_CTX_init, HMAC_Final, HMAC_Init_ex, HMAC_Update,
HMAC_CTX,
};
use crate::error::Unspecified;
use crate::fips::indicator_check;
use crate::{constant_time, digest, hkdf};
use core::mem::MaybeUninit;
use core::ptr::null_mut;
// TODO: Uncomment when MSRV >= 1.64
Expand Down
4 changes: 2 additions & 2 deletions aws-lc-rs/src/kdf/kbkdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#![allow(clippy::module_name_repetitions)]

use aws_lc::KBKDF_ctr_hmac;
use aws_lc::EVP_MD;
use crate::aws_lc::KBKDF_ctr_hmac;
use crate::aws_lc::EVP_MD;

use crate::{
digest::{match_digest_type, AlgorithmID},
Expand Down
4 changes: 2 additions & 2 deletions aws-lc-rs/src/kdf/sskdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#![allow(clippy::module_name_repetitions)]

use aws_lc::EVP_MD;
use aws_lc::{SSKDF_digest, SSKDF_hmac};
use crate::aws_lc::EVP_MD;
use crate::aws_lc::{SSKDF_digest, SSKDF_hmac};

use crate::{
digest::{match_digest_type, AlgorithmID},
Expand Down
12 changes: 6 additions & 6 deletions aws-lc-rs/src/kem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@
//!
//! # Ok::<(), aws_lc_rs::error::Unspecified>(())
//! ```
use crate::aws_lc::{
EVP_PKEY_CTX_kem_set_params, EVP_PKEY_CTX_new_id, EVP_PKEY_decapsulate, EVP_PKEY_encapsulate,
EVP_PKEY_get_raw_private_key, EVP_PKEY_get_raw_public_key, EVP_PKEY_kem_new_raw_public_key,
EVP_PKEY_keygen, EVP_PKEY_keygen_init, EVP_PKEY, EVP_PKEY_KEM,
};
use crate::{
buffer::Buffer,
encoding::generated_encodings,
error::{KeyRejected, Unspecified},
ptr::LcPtr,
};
use alloc::borrow::Cow;
use aws_lc::{
EVP_PKEY_CTX_kem_set_params, EVP_PKEY_CTX_new_id, EVP_PKEY_decapsulate, EVP_PKEY_encapsulate,
EVP_PKEY_get_raw_private_key, EVP_PKEY_get_raw_public_key, EVP_PKEY_kem_new_raw_public_key,
EVP_PKEY_keygen, EVP_PKEY_keygen_init, EVP_PKEY, EVP_PKEY_KEM,
};
use core::{cmp::Ordering, ptr::null_mut};
use zeroize::Zeroize;

Expand Down Expand Up @@ -102,7 +102,7 @@ pub const ML_KEM_1024: Algorithm<AlgorithmId> = Algorithm {
shared_secret_size: ML_KEM_1024_SHARED_SECRET_LENGTH,
};

use aws_lc::{NID_MLKEM1024, NID_MLKEM512, NID_MLKEM768};
use crate::aws_lc::{NID_MLKEM1024, NID_MLKEM512, NID_MLKEM768};

/// An identifier for a KEM algorithm.
pub trait AlgorithmIdentifier:
Expand Down
Loading

0 comments on commit 76bcc06

Please sign in to comment.