-
-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
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
Add Blake2b signature algorithm #832
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO OK to introduce this - it is still important that:
- we document it (not sure which files need adjusting)
- we make sure it's documented as in "this is a more niche algorithm, so downstream systems may be unable to verify generated tokens, if they don't support it"
Threw it out to pull in some attention: https://twitter.com/Ocramius/status/1511338900043841537 |
I'm okay too (100% agree with the documentation comments). |
Looks okay to me, would you please add the docs? |
Sure, tomorrow |
Woah, this is great. |
One consideration to check here: is the generated hash longer or shorter, and how much? A longer hash would mean lower CPU load, but higher I/O load. I see Blake2B is supposed to produce 64 bytes? If that is the case, it is most likely a big win also for everything I/O related. EDIT: as for security guarantees, it seems like Blake2b is theorically a lot better than sha256 |
It can range between 16 and 64, but default implementation including |
For long-term tokens, a minimum of 24 bytes is required for collision resistance. 16 bytes are fine for short-lived tokens. 32 bytes are safe for all use cases, adds a security margin. Using 64 bytes would be useless in the case of JWT. Speed is the same regardless of the output size; what really matters is the block size (how many bytes are processed at one) and it is always 512 bits in BLAKE2b. So, like @Slamdunk I'd also recommend using 32 bytes output. |
BLAKE2b also accepts an optional "personalization" parameter (sometimes called "context" in other hash functions and constructions). The purpose is to produce a different output in case the same key is used in different contexts, in order to avoid cross-protocol attacks. Setting it to a constant such as the "JWT" string may not be a bad idea. |
I like the idea but I want to stick to a standard implementation as much as possible. |
I know, I'm libsodium's author :) It's available as The parameter is available in all other BLAKE2b implementations as well. |
Some interesting discussions in https://mailarchive.ietf.org/arch/msg/jose/YAQf8peqpqNTNpK2VJFFckbR1P4/. @jedisct1 maybe you can help out? |
From that mail thread:
Sounds like it may take a while, if it ever happens at all. |
Like all standards. It take years for a proposal to become accepted as a standard, if that ever happens, and by the time it finally happens, the algorithm is already obsolete. |
Yeap... looking at timelines as https://datatracker.ietf.org/doc/rfc8037/ makes me shiver... I don't have the capacity to create the draft (I'm even struggling to keep up with basic OSS). We must decide if we want to push this further (just remove references from HMAC as native Blake2b MAC is different from HMAC-Blake2) and accept the usage of a non-standard algorithm or hold this until someone creates the Internet Draft and submit it for review (following RFC7518's procedure).
That bit also came from the thread and makes me feel like the "Designated Experts" might reject BLAKE2b's submission, idk. I'm generally okay with adding a non-standard algorithm if you're all up to it. |
"de facto" standards work. If common implementations are compatible with each other, this is enough to make something a lot of people can use and take advantage of. |
ca4197d
to
4acb0b4
Compare
Hi, JWT has never formalized Blake2b as a signing algorithm, hence the
BLAKE2B
algorithm ID I chose in the code was made up by me and I don't know if this should be merged of not, maybe we could use the@experimental
tag on the class, I don't know.But if this is nowhere near a standard (in JWT I mean, Blake2b is a standard), why proposing it? Because of this: