DoxigAlpha

hmacExpandLabel

Function parameters

Parameters

#
Hmac:type
secret:[]const u8
label_then_seed:[]const []const u8
len:usize

Type definitions in this namespace

Types

#
ApplicationCipher
Encryption parameters for application traffic.
Decoder
An abstraction to ensure that protocol-parsing code does not perform an

Functions in this namespace

Functions

#

= 5

Values

#
max_ciphertext_len
= max_ciphertext_inner_record_len + 256
max_ciphertext_record_len
= max_ciphertext_len + record_header_len
hello_retry_request_sequence
= [32]u8{ 0xCF, 0x21, 0xAD, 0x74, 0xE5, 0x9A, 0x61, 0x11, 0xBE, 0x1D, 0x8C, 0x02, 0x1E, 0x65, 0xB8, 0x91, 0xC2, 0xA2, 0x11, 0x16, 0x7A, 0xBB, 0x8C, 0x5E, 0x07, 0x9E, 0x09, 0xE2, 0xC8, 0xA8, 0x33, 0x9C, }
close_notify_alert
= [_]u8{ @intFromEnum(Alert.Level.warning), @intFromEnum(Alert.Description.close_notify), }

Source

Implementation

#
pub fn hmacExpandLabel(
    comptime Hmac: type,
    secret: []const u8,
    label_then_seed: []const []const u8,
    comptime len: usize,
) [len]u8 {
    const initial_hmac: Hmac = .init(secret);
    var a: [Hmac.mac_length]u8 = undefined;
    var result: [std.mem.alignForwardAnyAlign(usize, len, Hmac.mac_length)]u8 = undefined;
    var index: usize = 0;
    while (index < result.len) : (index += Hmac.mac_length) {
        var a_hmac = initial_hmac;
        if (index > 0) a_hmac.update(&a) else for (label_then_seed) |part| a_hmac.update(part);
        a_hmac.final(&a);

        var result_hmac = initial_hmac;
        result_hmac.update(&a);
        for (label_then_seed) |part| result_hmac.update(part);
        result_hmac.final(result[index..][0..Hmac.mac_length]);
    }
    return result[0..len].*;
}