Skip to content

Commit

Permalink
Update Clippy and fix lints (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Aug 7, 2023
1 parent 7753c7e commit 9df5ac1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.56.0 # MSRV
toolchain: 1.71.0
components: clippy
- run: cargo clippy --all -- -D warnings

Expand Down
21 changes: 15 additions & 6 deletions concat-kdf/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,19 @@ fn test_errors() {
);

// key has a length that causes counter overflow.
assert_eq!(
concat_kdf::derive_key_into::<Sha224>(&[0u8; 42], &[], unsafe {
std::slice::from_raw_parts_mut(0 as *mut u8, Sha224::output_size() * u32::MAX as usize)
}),
Err(concat_kdf::Error::CounterOverflow)
);
#[cfg(target_pointer_width = "64")]
{
let size = Sha224::output_size() * u32::MAX as usize;
let layout = std::alloc::Layout::from_size_align(size, 1).unwrap();
unsafe {
// We assume that OS will not allocate physicall memory for this buffer
let p = std::alloc::alloc_zeroed(layout);
let buf = std::slice::from_raw_parts_mut(p, size);
assert_eq!(
concat_kdf::derive_key_into::<Sha224>(&[0u8; 42], &[], buf),
Err(concat_kdf::Error::CounterOverflow)
);
std::alloc::dealloc(p, layout)
};
}
}
4 changes: 2 additions & 2 deletions hkdf/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ fn test_lengths() {
// Runtime is O(length), so exhaustively testing all legal lengths
// would take too long (at least without --release). Only test a
// subset: the first 500, the last 10, and every 100th in between.
let lengths = (0..MAX_SHA256_LENGTH + 1)
.filter(|&len| len < 500 || len > MAX_SHA256_LENGTH - 10 || len % 100 == 0);
let range = 500..MAX_SHA256_LENGTH - 10;
let lengths = (0..MAX_SHA256_LENGTH + 1).filter(|len| !range.contains(len) || *len % 100 == 0);

for length in lengths {
let mut okm = vec![0u8; length];
Expand Down

0 comments on commit 9df5ac1

Please sign in to comment.