diff options
| author | Bruno Franca dos Reis <261623+bfreis@users.noreply.github.com> | 2024-10-28 07:54:02 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-28 14:54:02 +0000 |
| commit | cdd8e82f0ac7ace0a03653960fbf9ba3daa69dc4 (patch) | |
| tree | f5cbcf96d8b7c9ed3c98a37d9843d4a9b6c421f0 | |
| parent | 4c336705b9c27a7f7152ef51116121d6bf209ac4 (diff) | |
| download | zig-cdd8e82f0ac7ace0a03653960fbf9ba3daa69dc4.tar.gz zig-cdd8e82f0ac7ace0a03653960fbf9ba3daa69dc4.zip | |
closes #21824 (#21832)
| -rw-r--r-- | lib/std/crypto/hkdf.zig | 9 | ||||
| -rw-r--r-- | lib/std/crypto/sha3.zig | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/std/crypto/hkdf.zig b/lib/std/crypto/hkdf.zig index 9163ba9d15..d8270f984c 100644 --- a/lib/std/crypto/hkdf.zig +++ b/lib/std/crypto/hkdf.zig @@ -88,3 +88,12 @@ test "Hkdf" { hkdf.final(&prk2); try htest.assertEqual("077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5", &prk2); } + +test "Hkdf Sha3-512" { + const sha3_512 = std.crypto.hash.sha3.Sha3_512; + const hmac_sha3_512 = hmac.Hmac(sha3_512); + const hkdf = Hkdf(hmac_sha3_512); + const prk = hkdf.extract("", ""); + var out = [1]u8{0}; + hkdf.expand(out[0..], "", prk); +} diff --git a/lib/std/crypto/sha3.zig b/lib/std/crypto/sha3.zig index 4ea09e0f93..a001538c1d 100644 --- a/lib/std/crypto/sha3.zig +++ b/lib/std/crypto/sha3.zig @@ -52,7 +52,7 @@ pub fn Keccak(comptime f: u11, comptime output_bits: u11, comptime default_delim st: State, /// The output length, in bytes. - pub const digest_length = output_bits / 8; + pub const digest_length = std.math.divCeil(comptime_int, output_bits, 8) catch unreachable; /// The block length, or rate, in bytes. pub const block_length = State.rate; /// The delimiter can be overwritten in the options. |
