We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Follow HKDF RFC: https://tools.ietf.org/html/rfc5869#section-2.2
HashLen denotes the length of the hash function output in octets
optional salt value (a non-secret random value); if not provided, it is set to a string of HashLen zeros.
The HashLen is OutputLen, not BlockLen.
HashLen
OutputLen
BlockLen
But for now, the hkdf code set to a string of BlockLen zeros when salt value not provided.
hkdf
See code:
KDFs/hkdf/src/hkdf.rs
Lines 71 to 75 in e413e0a
HMAC Code Line: https://github.com/RustCrypto/MACs/blob/4ab9f441fb08c754c22d65963fa948693c6e5116/hmac/src/lib.rs#L118-L128
impl<D> NewMac for Hmac<D> where D: Update + BlockInput + FixedOutput + Reset + Default + Clone, D::BlockSize: ArrayLength<u8>, D::OutputSize: ArrayLength<u8>, { type KeySize = D::BlockSize; fn new(key: &GenericArray<u8, Self::KeySize>) -> Self { Self::new_varkey(key.as_slice()).unwrap() }
Fix:
None => Hmac::<D>::new(&Default::default()), should be change to None => Hmac::<D>::new_varkey(&D::OutputSize::default()), .
None => Hmac::<D>::new(&Default::default()),
None => Hmac::<D>::new_varkey(&D::OutputSize::default()),
The text was updated successfully, but these errors were encountered:
Your reading appears to be correct and this does indeed look like a bug. Would you like to open a PR to fix it?
Sorry, something went wrong.
@tarcieri See PR #46
fix HKDF-Extract with empty salt #45 (#46)
77c221d
Successfully merging a pull request may close this issue.
Follow HKDF RFC: https://tools.ietf.org/html/rfc5869#section-2.2
The
HashLen
isOutputLen
, notBlockLen
.But for now, the
hkdf
code set to a string of BlockLen zeros when salt value not provided.See code:
KDFs/hkdf/src/hkdf.rs
Lines 71 to 75 in e413e0a
HMAC Code Line:
https://github.com/RustCrypto/MACs/blob/4ab9f441fb08c754c22d65963fa948693c6e5116/hmac/src/lib.rs#L118-L128
Fix:
None => Hmac::<D>::new(&Default::default()),
should be change toNone => Hmac::<D>::new_varkey(&D::OutputSize::default()),
.The text was updated successfully, but these errors were encountered: