mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
21 lines
548 B
Zig
21 lines
548 B
Zig
const bun = @import("bun");
|
|
|
|
const boring = bun.BoringSSL.c;
|
|
|
|
pub fn generate(key: []const u8, data: []const u8, algorithm: bun.JSC.API.Bun.Crypto.EVP.Algorithm, out: *[boring.EVP_MAX_MD_SIZE]u8) ?[]const u8 {
|
|
var outlen: c_uint = boring.EVP_MAX_MD_SIZE;
|
|
if (boring.HMAC(
|
|
algorithm.md() orelse bun.Output.panic("Expected BoringSSL algorithm for HMAC", .{}),
|
|
key.ptr,
|
|
key.len,
|
|
data.ptr,
|
|
data.len,
|
|
out,
|
|
&outlen,
|
|
) == null) {
|
|
return null;
|
|
}
|
|
|
|
return out[0..outlen];
|
|
}
|