fn Composition(comptime H1: type, comptime H2: type) type

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.

Parameters

H1: type,
H2: type,

Fields

H1: H1,
H2: H2,

Types

Functions

fn final(d: *Self, out: *[digest_length]u8) void

Compute the final hash for the accumulated content: H1(H2(b)).

fn hash(b: []const u8, out: *[digest_length]u8, options: Options) void

Compute H1(H2(b)).

fn init(options: Options) Self

Initialize the hash composition with the given options.

fn update(d: *Self, b: []const u8) void

Add content to the hash.

Values

block_length
undefined

The block length, in bytes.

digest_length
undefined

The length of the hash output, in bytes.