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 standard library.
std › crypto › tls › hkdfExpandLabel Public Function hkdfExpandLabel Doc Source Public Function std.crypto.tls.hkdfExpandLabel
pub fn hkdfExpandLabel (
comptime Hkdf : type ,
key : [Hkdf .prk_length ]u8 ,
label : []const u8 ,
context : []const u8 ,
comptime len : usize ,
) [len ]u8 Params Hkdf : type key : [Hkdf .prk_length ]u8 label : []const u8 context : []const u8 len : usize File crypto/tls.zig: 558
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583 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 ;
}