| author | |
| committer | |
| log | cdd8e82f0ac7ace0a03653960fbf9ba3daa69dc4 |
| tree | f5cbcf96d8b7c9ed3c98a37d9843d4a9b6c421f0 |
| parent | 4c336705b9c27a7f7152ef51116121d6bf209ac4 |
| signature |
2 files changed, 10 insertions(+), 1 deletions(-)
lib/std/crypto/hkdf.zig+9| ... | @@ -88,3 +88,12 @@ test "Hkdf" { | ... | @@ -88,3 +88,12 @@ test "Hkdf" { |
| 88 | hkdf.final(&prk2); | 88 | hkdf.final(&prk2); |
| 89 | try htest.assertEqual("077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5", &prk2); | 89 | try htest.assertEqual("077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5", &prk2); |
| 90 | } | 90 | } |
| 91 | |||
| 92 | test "Hkdf Sha3-512" { | ||
| 93 | const sha3_512 = std.crypto.hash.sha3.Sha3_512; | ||
| 94 | const hmac_sha3_512 = hmac.Hmac(sha3_512); | ||
| 95 | const hkdf = Hkdf(hmac_sha3_512); | ||
| 96 | const prk = hkdf.extract("", ""); | ||
| 97 | var out = [1]u8{0}; | ||
| 98 | hkdf.expand(out[0..], "", prk); | ||
| 99 | } |
lib/std/crypto/sha3.zig+1-1| ... | @@ -52,7 +52,7 @@ pub fn Keccak(comptime f: u11, comptime output_bits: u11, comptime default_delim | ... | @@ -52,7 +52,7 @@ pub fn Keccak(comptime f: u11, comptime output_bits: u11, comptime default_delim |
| 52 | st: State, | 52 | st: State, |
| 53 | 53 | ||
| 54 | /// The output length, in bytes. | 54 | /// The output length, in bytes. |
| 55 | pub const digest_length = output_bits / 8; | 55 | pub const digest_length = std.math.divCeil(comptime_int, output_bits, 8) catch unreachable; |
| 56 | /// The block length, or rate, in bytes. | 56 | /// The block length, or rate, in bytes. |
| 57 | pub const block_length = State.rate; | 57 | pub const block_length = State.rate; |
| 58 | /// The delimiter can be overwritten in the options. | 58 | /// The delimiter can be overwritten in the options. |