Skip to content

blake2: add unkeyed hashing - #612

Merged
newpavlov merged 1 commit into
RustCrypto:masterfrom
threema-theo:blake2b-keyless
Jan 17, 2025
Merged

blake2: add unkeyed hashing#612
newpavlov merged 1 commit into
RustCrypto:masterfrom
threema-theo:blake2b-keyless

Conversation

@threema-theo

Copy link
Copy Markdown
Contributor

This introduces unkeyed hashing for blake2 as specified in Section 2.5 of RFC 7693 states the following:

The second (little-endian) byte of the parameter block, "kk", specifies the key size in bytes. Set kk = 00 for unkeyed hashing.

I propose to make the key an Option<&[u8]>:

pubfnnew_with_salt_and_personal(key:Option<&[u8]>,salt:&[u8],persona:&[u8],) -> Result<Self,InvalidLength>

By making the key an Option<&[u8]> - rather than opting for the unkeyed usage in case of an empty key - we make the unkeyed usage explicit and avoid inadvertent usages.

This closes#482.
See also #509.

@newpavlovnewpavlov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@newpavlov
newpavlov merged commit 01e79f7 into RustCrypto:masterJan 17, 2025
@tarcieritarcieri mentioned this pull request Aug 25, 2026
tarcieri added a commit that referenced this pull request Aug 26, 2026
## Added
- `zeroize` support (#545)
- `Blake2b128`, `Blake2b256`, `Blake2s128` type aliases (#564)
- `CustomizedInit` support (#664)
- `alloc` crate feature (#678)
## Changed
- Edition changed to 2024 and MSRV bumped to 1.85 (#652)
- Relax MSRV policy and allow MSRV bumps in patch releases
- Update to `digest` v0.11
- Replace type aliases with newtypes (#678)
## Removed
- `std` crate feature (#678)
- `Blake2bVar` and `Blake2sVar` types (#744)
- SIMD support (#898)
## Fixed
- Handling of unkeyed hashes in keyed mode (#510, #612)
Sign up for freeto 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.

Blake2 parameters cannot be used without a key

2 participants

@threema-theo@newpavlov