Skip to content

Commit

Permalink
fix(crypto): reset zig hashers on digest (#17539)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylan-conway authored Feb 22, 2025
1 parent fb6f7e4 commit 8c4d3ff
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/bun.js/api/BunObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2824,9 +2824,12 @@ pub const Crypto = struct {
}

fn final(self: *CryptoHasherZig, output_digest_slice: []u8) []u8 {
inline for (algo_map) |item| {
if (self.algorithm == @field(EVP.Algorithm, item[0])) {
item[1].final(@ptrCast(@alignCast(self.state)), @ptrCast(output_digest_slice));
inline for (algo_map) |pair| {
const name, const T = pair;
if (self.algorithm == @field(EVP.Algorithm, name)) {
T.final(@ptrCast(@alignCast(self.state)), @ptrCast(output_digest_slice));
const reset: *T = @ptrCast(@alignCast(self.state));
reset.* = T.init(.{});
return output_digest_slice[0..self.digest_length];
}
}
Expand Down

0 comments on commit 8c4d3ff

Please sign in to comment.