fn Composition(comptime H1: type, comptime H2: type) type
[src]
The composition of two hash functions: H1 o H2, with the same API as regular hash functions.
The security level of a hash cascade doesn’t exceed the security level of the weakest function.
However, Merkle–Damgård constructions such as SHA-256 are vulnerable to length-extension attacks, where under some conditions, H(x||e)
can be efficiently computed without knowing x
. The composition of two hash functions is a common defense against such attacks.
This is not necessary with modern hash functions, such as SHA-3, BLAKE2 and BLAKE3.
Functions
fn final(d: *Self, out: *[digest_length]u8) void
Compute the final hash for the accumulated content: H1(H2(b)).
Values
block_length | undefined | The block length, in bytes. |
digest_length | undefined | The length of the hash output, in bytes. |