Skip to content
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

crypto.hmac: set the recommended key size to the block size #15031

Merged
merged 2 commits into from
Mar 22, 2023

Conversation

jedisct1
Copy link
Contributor

@jedisct1 jedisct1 commented Mar 21, 2023

HMAC supports arbitrary key sizes, and there are no practical reasons to use more than 256 bit keys.

It still make sense to match the security level, though, especially since a distinction between the block size and the key size can be confusing.

Using HMAC.key_size instead of HMAC.mac_size caused our TLS implementation to compute wrong shared secrets when SHA-384 was used. So, fix it directly in crypto.hmac in order to prevent other misuses.

HMAC supports arbitrary key sizes, and there are no practical reasons
to use more than 256 bit keys.

In still make sense to match the security level, though, especially
since a distinction between the block size and the key size can be
confusing.

Using HMAC.key_size instead of HMAC.mac_size caused our TLS
implementation to compute wrong shared secrets when SHA-384 was
used. So, fix it directly in `crypto.hmac` in order to prevent
other misuses.
@jedisct1 jedisct1 enabled auto-merge (squash) March 21, 2023 16:35
@jedisct1 jedisct1 added the standard library This issue involves writing Zig code for the standard library. label Mar 21, 2023
@jedisct1 jedisct1 merged commit 84b89d7 into ziglang:master Mar 22, 2023
truemedian pushed a commit to truemedian/zig that referenced this pull request Mar 30, 2023
…15031)

HMAC supports arbitrary key sizes, and there are no practical reasons
to use more than 256 bit keys.

It still makes sense to match the security level, though, especially
since a distinction between the block size and the key size can be
confusing.

Using HMAC.key_size instead of HMAC.mac_size caused our TLS
implementation to compute wrong shared secrets when SHA-384 was
used. So, fix it directly in `crypto.hmac` in order to prevent
other misuses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant