Skip to content

Blake2: add missing types of common digest sizes - #564

Merged
newpavlov merged 1 commit into
RustCrypto:masterfrom
HeCorr:blake2-common
May 2, 2024
Merged

Blake2: add missing types of common digest sizes#564
newpavlov merged 1 commit into
RustCrypto:masterfrom
HeCorr:blake2-common

Conversation

@HeCorr

@HeCorr HeCorr commented Feb 10, 2024

Copy link
Copy Markdown
Contributor

See comment #67.

This PR adds the following common fixed digest sizes:

  • BLAKE2s-128
  • BLAKE2b-128
  • BLAKE2b-256

Unsure if I should also add the Mac variants, please let me know!

BLAKE2s-128
BLAKE2b-128
BLAKE2b-256
@HeCorr

HeCorr commented Feb 10, 2024

Copy link
Copy Markdown
Contributor Author

Also, I've noticed that only the BLAKE2b-512 fixed variant is tested, but I've just recently started learning Rust so I'm not sure how to write tests for the other variants (specifically how to generate the .blb files).

Any guidance on this would be very welcome!

@newpavlov

Copy link
Copy Markdown
Member

Could you please link cases where those variations are used in practice?

only the BLAKE2b-512 fixed variant is tested

We could add tests for other variants, but we would have to generate tests ourselves. Ideally, we would use "official" test vectors, but we probably couldn't find them at the time.

@HeCorr

HeCorr commented Apr 27, 2024

Copy link
Copy Markdown
Contributor Author

Could you please link cases where those variations are used in practice?

I can't, but I personally always use either 256 or 128 if I need the hash to be shorter. What I can link you though are other projects which do include them and even other less common sizes (160, 384..):

CyberChef
Go standard lib

@StackOverflowExcept1on

Copy link
Copy Markdown

I have similar problem that I need hash of 256 bit size, but this crate does not provide BLAKE2b-256.

@HeCorr

HeCorr commented Apr 30, 2024

Copy link
Copy Markdown
Contributor Author

this crate does not provide BLAKE2b-256.

@StackOverflowExcept1on this is how you can currently generate a Blake2b-256 hash:

use blake2::{Blake2b, Digest, digest::consts::U32};

type Blake2b256 = Blake2b<U32>;

let mut hasher = Blake2b256::new();
hasher.update(b"my_input");
let res = hasher.finalize();

@newpavlov
newpavlov merged commit 470c789 into RustCrypto:master May 2, 2024
@tarcieri tarcieri 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 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.

3 participants