# crypto.hash.sha3: make permutation generic and public, add SHAKE \(\#14756\) · gitcafe/zig

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

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

Visibility: public

Requested revision: 28364166e83ed52a7053029d5d7b33ad956d804d

Requested commit: 28364166e83ed52a7053029d5d7b33ad956d804d

Commit: 28364166e83ed52a7053029d5d7b33ad956d804d

Tree: b377f5a0b9967f81faa1e2c9f35a56977b9fc05a

Author: Frank Denis

Committer: GitHub

## Message

```
crypto.hash.sha3: make permutation generic and public, add SHAKE (#14756)

Make the Keccak permutation public, as it's useful for more than
SHA-3 (kMAC, SHAKE, TurboSHAKE, TupleHash, etc).

Our Keccak implementation was accepting f as a comptime parameter,
but always used 64-bit words and 200 byte states, so it actually
didn't work with anything besides f=1600.

That has been fixed. The ability to use reduced-round versions
was also added in order to support M14 and K12.

The state was constantly converted back and forth between bytes
and words, even though only a part of the state is actually used
for absorbing and squeezing bytes. It was changed to something
similar to the other permutations we have, so we can avoid extra
copies, and eventually add vectorized implementations.

In addition, the SHAKE extendable output function (XOF) was
added (SHAKE128, SHAKE256). It is required by newer schemes,
such as the Kyber post-quantum key exchange mechanism, whose
implementation is currently blocked by SHAKE missing from our
standard library.

Breaking change: `Keccak_256` and `Keccak_512` were renamed to
`Keccak256` and `Keccak512` for consistency with all other
hash functions.
```

## Parents

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

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