Skip to content

Commit ba09a7a

Browse files
committed
docs(pkcs12): explain Zeroizing wraps in decrypt
Add two explanatory comments in decrypt_rc2: - Zeroizing::new() wrappers on derive_key_utf8 return values are intentional on this branch (kdf returns Vec<u8>); note they will be removed once kdf PR #2283 (Zeroizing<Vec<u8>> return) lands. - Salt length is bounded by DER input size; no separate allocation cap is needed.
1 parent bce7eaf commit ba09a7a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkcs12/src/decrypt.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,19 @@ fn decrypt_rc2(
154154
let salt = params.salt.as_bytes();
155155

156156
// Defensive: a zero-length salt produces a trivially weak KDF input.
157+
// Salt length is bounded by the DER input size; no separate allocation
158+
// cap is needed here.
157159
if salt.is_empty() {
158160
return Err(der::ErrorKind::Failed.into());
159161
}
160162

161163
// Derive the RC2 key (ID=1, key_len bytes) and CBC IV (ID=2, 8 bytes)
162164
// using the RFC 7292 §B.2 KDF with SHA-1.
165+
//
166+
// Note: Zeroizing::new() wraps the Vec<u8> returned by derive_key_utf8 on
167+
// this branch. Once kdf PR #2283 lands (derive_key_utf8 returns
168+
// Zeroizing<Vec<u8>> directly), these Zeroizing::new() wrappers should be
169+
// removed to avoid redundant double-wrapping.
163170
let key = Zeroizing::new(derive_key_utf8::<sha1::Sha1>(
164171
password,
165172
salt,

0 commit comments

Comments
 (0)