authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2020-11-01 16:21:58+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-11-01 18:27:11+02:00
logc387f1340f645fe322010a80e44c9dbfeae1a7eb
treeac977999bc59a1db40b526f5fc0891a5901df496
parent9ca9819488db580241a93ded7b93a054de2db8af

std/crypto: make Hkdf functions public


1 files changed, 2 insertions(+), 2 deletions(-)

lib/std/crypto/hkdf.zig+2-2
...@@ -20,14 +20,14 @@ pub const HkdfSha512 = Hkdf(hmac.sha2.HmacSha512);...@@ -20,14 +20,14 @@ pub const HkdfSha512 = Hkdf(hmac.sha2.HmacSha512);
20pub fn Hkdf(comptime Hmac: type) type {20pub fn Hkdf(comptime Hmac: type) type {
21 return struct {21 return struct {
22 /// Return a master key from a salt and initial keying material.22 /// Return a master key from a salt and initial keying material.
23 fn extract(salt: []const u8, ikm: []const u8) [Hmac.mac_length]u8 {23 pub fn extract(salt: []const u8, ikm: []const u8) [Hmac.mac_length]u8 {
24 var prk: [Hmac.mac_length]u8 = undefined;24 var prk: [Hmac.mac_length]u8 = undefined;
25 Hmac.create(&prk, ikm, salt);25 Hmac.create(&prk, ikm, salt);
26 return prk;26 return prk;
27 }27 }
2828
29 /// Derive a subkey from a master key `prk` and a subkey description `ctx`.29 /// Derive a subkey from a master key `prk` and a subkey description `ctx`.
30 fn expand(out: []u8, ctx: []const u8, prk: [Hmac.mac_length]u8) void {30 pub fn expand(out: []u8, ctx: []const u8, prk: [Hmac.mac_length]u8) void {
31 assert(out.len < Hmac.mac_length * 255); // output size is too large for the Hkdf construction31 assert(out.len < Hmac.mac_length * 255); // output size is too large for the Hkdf construction
32 var i: usize = 0;32 var i: usize = 0;
33 var counter = [1]u8{1};33 var counter = [1]u8{1};