What changed, and why it matters
This commit only adds documentation comments describing when three functions can panic. No code behavior was changed, so it cannot introduce or fix a security vulnerability on its own.
No security action needed; treat as routine documentation improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit adds ‘# Panics’ doc sections to HKDF::new, HmacEngine::new, and Hash::hash_64_many. It clarifies existing panic conditions (block size > 128 bytes, mismatched output/input lengths) but does not alter any logic. It is a documentation-only change.
Changed components
hashes/src/hkdf/mod.rshashes/src/hmac/mod.rshashes/src/sha256d/mod.rsInspect captured patch +9 / −1
diff --git a/hashes/src/hkdf/mod.rs b/hashes/src/hkdf/mod.rs
index 12be32b9..aa9434e4 100644
--- a/hashes/src/hkdf/mod.rs
+++ b/hashes/src/hkdf/mod.rs
@@ -46,6 +46,10 @@ where
T: Default,
{
/// Initializes a HKDF by performing the extract step.
+ ///
+ /// # Panics
+ ///
+ /// Panics if `T::BLOCK_SIZE` exceeds 128 bytes.
pub fn new(salt: &[u8], ikm: &[u8]) -> Self {
let mut engine: HmacEngine<T> = HmacEngine::new(salt);
engine.input(ikm);
diff --git a/hashes/src/hmac/mod.rs b/hashes/src/hmac/mod.rs
index 1745d466..ffeefb03 100644
--- a/hashes/src/hmac/mod.rs
+++ b/hashes/src/hmac/mod.rs
@@ -87,7 +87,7 @@ impl<T: HashEngine> HmacEngine<T> {
///
/// # Panics
///
- /// Larger hashes will result in a panic.
+ /// Panics if `T::BLOCK_SIZE` exceeds 128 bytes.
pub fn new(key: &[u8]) -> Self
where
T: Default,
diff --git a/hashes/src/sha256d/mod.rs b/hashes/src/sha256d/mod.rs
index d0f38f41..cb36f5c7 100644
--- a/hashes/src/sha256d/mod.rs
+++ b/hashes/src/sha256d/mod.rs
@@ -13,6 +13,10 @@ crate::internal_macros::general_hash_type! {
impl Hash {
/// Computes double-SHA256 of multiple 64-byte blocks in parallel.
+ ///
+ /// # Panics
+ ///
+ /// Panics if `outputs.len() != inputs.len()`.
pub fn hash_64_many(outputs: &mut [[u8; 32]], inputs: &[[u8; 64]]) {
sha256::HashEngine::sha256d_64(outputs, inputs);
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.