Skip to content

std/crypto: properly support arbitrary output sizes - #7660

Merged
andrewrk merged 1 commit into
ziglang:masterfrom
jedisct1:blake2-anylength
Jan 3, 2021
Merged

std/crypto: properly support arbitrary output sizes#7660
andrewrk merged 1 commit into
ziglang:masterfrom
jedisct1:blake2-anylength

Conversation

@jedisct1

Copy link
Copy Markdown
Contributor

Fixes#7657

@LemonBoy

Copy link
Copy Markdown
Contributor

According to RFC7693 the following output lengths are defined:


Algorithm | Target | Collision | Hash | Hash ASN.1 |
Identifier | Arch | Security | nn | OID Suffix |
---------------+--------+-----------+------+------------+
id-blake2b160 | 64-bit | 2**80 | 20 | x.1.5 |
id-blake2b256 | 64-bit | 2**128 | 32 | x.1.8 |
id-blake2b384 | 64-bit | 2**192 | 48 | x.1.12 |
id-blake2b512 | 64-bit | 2**256 | 64 | x.1.16 |
---------------+--------+-----------+------+------------+
id-blake2s128 | 32-bit | 2**64 | 16 | x.2.4 |
id-blake2s160 | 32-bit | 2**80 | 20 | x.2.5 |
id-blake2s224 | 32-bit | 2**112 | 28 | x.2.7 |
id-blake2s256 | 32-bit | 2**128 | 32 | x.2.8 |
---------------+--------+-----------+------+------------+

And we're not exporting/testing the nn=160 variant of both the blake2 hashes.

Shall we add the two missing definitions and a test?

@jedisct1

Copy link
Copy Markdown
ContributorAuthor

160 and 224 bits are uncommon settings, but sure, having it doesn't cost much and can be useful, if only to spot bug like these.

I'm going to add tests and types for nn=160.

@andrewrk
andrewrk merged commit 5aac2fc into ziglang:masterJan 3, 2021
@jedisct1
jedisct1 deleted the blake2-anylength branch January 3, 2021 07:44
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.

blake2b: final 4 bytes not written when expecting 160-bit output

3 participants

@jedisct1@LemonBoy@andrewrk