Skip to content

Commit

Permalink
Bump Clippy version and fix new lints
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Sep 23, 2024
1 parent 5080931 commit 1a57b53
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.72.0
toolchain: 1.81.0
components: clippy
- run: cargo clippy --all --all-features -- -D warnings
2 changes: 2 additions & 0 deletions aes-siv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ pub type Nonce<NonceSize = U16> = Array<u8, NonceSize>;
/// AES-SIV tags (i.e. the Synthetic Initialization Vector value)
pub type Tag = Array<u8, U16>;

/// Convinience wrapper around `Siv` interface.
///
/// The `SivAead` type wraps the more powerful `Siv` interface in a more
/// commonly used Authenticated Encryption with Associated Data (AEAD) API,
/// which accepts a key, nonce, and associated data when encrypting/decrypting.
Expand Down
14 changes: 7 additions & 7 deletions ccm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ impl<T: private::SealedNonce> NonceSize for T {}
/// Type parameters:
/// - `C`: block cipher.
/// - `M`: size of MAC tag in bytes, valid values:
/// [`U4`][consts::U4], [`U6`][consts::U6], [`U8`][consts::U8],
/// [`U10`][consts::U10], [`U12`][consts::U12], [`U14`][consts::U14],
/// [`U16`][consts::U16].
/// [`U4`][consts::U4], [`U6`][consts::U6], [`U8`][consts::U8],
/// [`U10`][consts::U10], [`U12`][consts::U12], [`U14`][consts::U14],
/// [`U16`][consts::U16].
/// - `N`: size of nonce, valid values:
/// [`U7`][consts::U7], [`U8`][consts::U8], [`U9`][consts::U9],
/// [`U10`][consts::U10], [`U11`][consts::U11], [`U12`][consts::U12],
/// [`U13`][consts::U13].
/// [`U7`][consts::U7], [`U8`][consts::U8], [`U9`][consts::U9],
/// [`U10`][consts::U10], [`U11`][consts::U11], [`U12`][consts::U12],
/// [`U13`][consts::U13].
#[derive(Clone)]
pub struct Ccm<C, M, N>
where
Expand Down Expand Up @@ -335,7 +335,7 @@ fn fill_aad_header(adata_len: usize) -> (usize, Array<u8, U16>) {
let n = if adata_len < 0xFF00 {
b[..2].copy_from_slice(&(adata_len as u16).to_be_bytes());
2
} else if adata_len <= core::u32::MAX as usize {
} else if adata_len <= u32::MAX as usize {
b[0] = 0xFF;
b[1] = 0xFE;
b[2..6].copy_from_slice(&(adata_len as u32).to_be_bytes());
Expand Down
2 changes: 1 addition & 1 deletion ccm/src/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub trait SealedNonce: Unsigned {
// compiler should be able to completely optimize it out
let l = Self::get_l() as u128;
let v = (1 << (8 * l)) - 1;
core::cmp::min(v, core::usize::MAX as u128) as usize
core::cmp::min(v, usize::MAX as u128) as usize
}
}

Expand Down
4 changes: 2 additions & 2 deletions ccm/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ fn test_data_len_check() {
let nonce = Array(nonce);
let c = Cipher::new(&key);

let mut buf1 = [1; core::u16::MAX as usize];
let mut buf1 = [1; u16::MAX as usize];
let res = c.encrypt_in_place_detached(&nonce, &[], &mut buf1);
assert!(res.is_ok());

let mut buf2 = [1; core::u16::MAX as usize + 1];
let mut buf2 = [1; u16::MAX as usize + 1];
let res = c.encrypt_in_place_detached(&nonce, &[], &mut buf2);
assert!(res.is_err());
}
Expand Down
2 changes: 1 addition & 1 deletion chacha20poly1305/src/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const BLOCK_SIZE: usize = 64;

/// Maximum number of blocks that can be encrypted with ChaCha20 before the
/// counter overflows.
const MAX_BLOCKS: usize = core::u32::MAX as usize;
const MAX_BLOCKS: usize = u32::MAX as usize;

/// ChaCha20Poly1305 instantiated with a particular nonce
pub(crate) struct Cipher<C>
Expand Down

0 comments on commit 1a57b53

Please sign in to comment.