Skip to content

Conversation

@fleximus
Copy link
Member

@fleximus fleximus commented Jan 6, 2026

Add two new public functions to support flexible hash output lengths:

  • sum(data, outlen): produces Blake2b hash with configurable output length (1-64 bytes), useful when standard sizes don't fit the use case

  • blake2b_long(data, outlen): implements the Blake2b extension mechanism for arbitrary-length output (>64 bytes) as specified in the Argon2 RFC, enabling future Argon2 password hashing implementation

Both functions include comprehensive regression tests covering output length validation, determinism, consistency with existing functions, and the specific 1024-byte output case required by Argon2.

…output

Add two new public functions to support flexible hash output lengths:

- `sum(data, outlen)`: produces Blake2b hash with configurable output
  length (1-64 bytes), useful when standard sizes don't fit the use case

- `blake2b_long(data, outlen)`: implements the Blake2b extension mechanism
  for arbitrary-length output (>64 bytes) as specified in the Argon2 RFC,
  enabling future Argon2 password hashing implementation

Both functions include comprehensive regression tests covering output
length validation, determinism, consistency with existing functions,
and the specific 1024-byte output case required by Argon2.
@spytheman
Copy link
Member

@kimshrier please take a look when you have time 🙇🏻

@tankf33der
Copy link
Contributor

Since one PR contains so many changes, I won't do the same and will split my response into two parts.

sum() part:
I implemented my tests for sum(data, outlen) and they passed. Let's say we can do the merge and this slightly improves the functionality. But I'm pointing out that users may possibly need to get a non-incremental hash when a key is needed too. Currently there is only incremental functionality. There's still my feeling that the blake2[b,s] family is still incomplete.

@blackshirt
Copy link
Contributor

Add two new public functions to support flexible hash output lengths:

  • sum(data, outlen): produces Blake2b hash with configurable output length (1-64 bytes), useful when standard sizes don't fit the use case
  • blake2b_long(data, outlen): implements the Blake2b extension mechanism for arbitrary-length output (>64 bytes) as specified in the Argon2 RFC, enabling future Argon2 password hashing implementation

Both functions include comprehensive regression tests covering output length validation, determinism, consistency with existing functions, and the specific 1024-byte output case required by Argon2.

Is it possible to make this blake2b fully implements interface Hash from hash module ?. I think its also good to adapt the go version of XOF interface into v, See XOF. Its added in go1.25.0. We have several extendable output function (xof) functionalities on the stock module.

@tankf33der
Copy link
Contributor

With the second part it's more complicated. Firstly, for argon2 you can get with default length, and if you're going to implement such functionality then it's called blake2x. I vote against merge.

@tankf33der
Copy link
Contributor

@fleximus how is doing? My test vectors for blake2x are ready and waiting for your great implementation.

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.

4 participants