Skip to content

Conversation

@skmcgrail
Copy link
Member

Description of changes:

Remove the salt length restriction for HKDF operations by moving the salt bytes field to be a Box'd value.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.53%. Comparing base (c358484) to head (e9f3653).
⚠️ Report is 287 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #951      +/-   ##
==========================================
- Coverage   95.80%   92.53%   -3.27%     
==========================================
  Files          61       74      +13     
  Lines        8143     9855    +1712     
  Branches        0     9855    +9855     
==========================================
+ Hits         7801     9119    +1318     
- Misses        342      449     +107     
- Partials        0      287     +287     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@skmcgrail skmcgrail marked this pull request as ready for review November 15, 2025 00:59
@skmcgrail skmcgrail requested a review from a team as a code owner November 15, 2025 00:59
Comment on lines 129 to +136
pub fn new(algorithm: Algorithm, value: &[u8]) -> Self {
Salt::try_new(algorithm, value).expect("Salt length limit exceeded.")
Salt::try_new(algorithm, value).expect("Failed to create Salt")
}

#[allow(clippy::unnecessary_wraps)]
fn try_new(algorithm: Algorithm, value: &[u8]) -> Result<Salt, Unspecified> {
let salt_len = value.len();
if salt_len > MAX_HKDF_SALT_LEN {
return Err(Unspecified);
}
let mut salt_bytes = [0u8; MAX_HKDF_SALT_LEN];
salt_bytes[0..salt_len].copy_from_slice(value);
Ok(Self {
algorithm,
bytes: salt_bytes,
len: salt_len,
})
let bytes = value.to_vec().into_boxed_slice();
Ok(Self { algorithm, bytes })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think try_new is needed now that we have no effective limit, we can just move this implementation into new.

Comment on lines +105 to 106
// Box<[u8]> implements Zeroize, so we can call it directly
self.bytes.zeroize();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP: I think the Salt is a public value, so I'm not sure this is necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants