Refactored the crypto submodules to comply with the engine resolution method
This commit is contained in:
parent
c292832280
commit
891727d959
9 changed files with 132 additions and 133 deletions
|
|
@ -1,18 +1,19 @@
|
|||
const Sha512 = @import("std").crypto.sha2.Sha512;
|
||||
|
||||
pub const hash_len: comptime_int = Sha512.digest_length;
|
||||
|
||||
pub const Implementation = struct {
|
||||
|
||||
hash: *const fn (buffer: []const u8, out: []u8) void,
|
||||
};
|
||||
|
||||
pub const defaultImplementation = struct {
|
||||
|
||||
const Sha512 = @import("std").crypto.sha2.Sha512;
|
||||
|
||||
const HASH_LEN = 64; // In bytes
|
||||
|
||||
pub fn hash(buffer: []const u8, out: []u8) !void {
|
||||
if (out.len < HASH_LEN) {
|
||||
return error.BufferTooShort;
|
||||
}
|
||||
Sha512.hash(buffer, out, .{});
|
||||
fn hash(buffer: []const u8, out: []u8) !void {
|
||||
if (out.len < hash_len) {
|
||||
return error.BufferTooShort;
|
||||
}
|
||||
Sha512.hash(buffer, out, .{});
|
||||
}
|
||||
|
||||
pub const defaultImplementation: Implementation = .{
|
||||
.hash = hash,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue