# crypto.hmac: set the recommended key size to the block size \(\#15031\) · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/84b89d7cfe452f91fa22f2646ef53a3a7e990456)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 84b89d7cfe452f91fa22f2646ef53a3a7e990456

Requested commit: 84b89d7cfe452f91fa22f2646ef53a3a7e990456

Commit: 84b89d7cfe452f91fa22f2646ef53a3a7e990456

Tree: f3ead35a68c20339cdaf42ec7753e5e85c001fad

Author: Frank Denis

Committer: GitHub

## Message

```
crypto.hmac: set the recommended key size to the block size (#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.
```

## Parents

- [87e07d8671b469431340c615dcdd5a5332d198ec](https://git.cafe/gitcafe/zig/commit/87e07d8671b469431340c615dcdd5a5332d198ec?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/84b89d7cfe452f91fa22f2646ef53a3a7e990456?format=markdown)
