Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › crypto/ › tls.zig › hkdfExpandLabel
hkdfExpandLabel
tls.hkdfExpandLabel
pub fn hkdfExpandLabel (
comptime Hkdf : type ,
key : [Hkdf .prk_length ]u8 ,
label : []const u8 ,
context : []const u8 ,
comptime len : usize ,
) [len ]u8
File
Code
pub fn hkdfExpandLabel (
comptime Hkdf : type ,
key : [Hkdf .prk_length ]u8 ,
label : []const u8 ,
context : []const u8 ,
comptime len : usize ,
) [len ]u8 {
const max_label_len = 255 ;
const max_context_len = 255 ;
const tls13 = "tls13 " ;
var buf : [2 + 1 + tls13 .len + max_label_len + 1 + max_context_len ]u8 = undefined ;
mem .writeInt (u16 , buf [0 ..2 ], len , .big );
buf [2 ] = @as (u8 , @intCast (tls13 .len + label .len ));
buf [3 ..][0 ..tls13 .len ].* = tls13 .*;
var i : usize = 3 + tls13 .len ;
@memcpy (buf [i ..][0 ..label .len ], label );
i += label .len ;
buf [i ] = @as (u8 , @intCast (context .len ));
i += 1 ;
@memcpy (buf [i ..][0 ..context .len ], context );
i += context .len ;
var result : [len ]u8 = undefined ;
Hkdf .expand (&result , buf [0 ..i ], key );
return result ;
}