aboutsummaryrefslogtreecommitdiff
path: root/lib/std/crypto/sha2.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/crypto/sha2.zig')
-rw-r--r--lib/std/crypto/sha2.zig18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/std/crypto/sha2.zig b/lib/std/crypto/sha2.zig
index ad99079852..bd5a7cc5d4 100644
--- a/lib/std/crypto/sha2.zig
+++ b/lib/std/crypto/sha2.zig
@@ -118,7 +118,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
// Partial buffer exists from previous update. Copy into buffer then hash.
if (d.buf_len != 0 and d.buf_len + b.len >= 64) {
off += 64 - d.buf_len;
- mem.copy(u8, d.buf[d.buf_len..], b[0..off]);
+ @memcpy(d.buf[d.buf_len..][0..off], b[0..off]);
d.round(&d.buf);
d.buf_len = 0;
@@ -130,7 +130,8 @@ fn Sha2x32(comptime params: Sha2Params32) type {
}
// Copy any remainder for next pass.
- mem.copy(u8, d.buf[d.buf_len..], b[off..]);
+ const b_slice = b[off..];
+ @memcpy(d.buf[d.buf_len..][0..b_slice.len], b_slice);
d.buf_len += @intCast(u8, b[off..].len);
d.total_len += b.len;
@@ -143,7 +144,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
pub fn final(d: *Self, out: *[digest_length]u8) void {
// The buffer here will never be completely full.
- mem.set(u8, d.buf[d.buf_len..], 0);
+ @memset(d.buf[d.buf_len..], 0);
// Append padding bits.
d.buf[d.buf_len] = 0x80;
@@ -152,7 +153,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
// > 448 mod 512 so need to add an extra round to wrap around.
if (64 - d.buf_len < 8) {
d.round(&d.buf);
- mem.set(u8, d.buf[0..], 0);
+ @memset(d.buf[0..], 0);
}
// Append message length.
@@ -609,7 +610,7 @@ fn Sha2x64(comptime params: Sha2Params64) type {
// Partial buffer exists from previous update. Copy into buffer then hash.
if (d.buf_len != 0 and d.buf_len + b.len >= 128) {
off += 128 - d.buf_len;
- mem.copy(u8, d.buf[d.buf_len..], b[0..off]);
+ @memcpy(d.buf[d.buf_len..][0..off], b[0..off]);
d.round(&d.buf);
d.buf_len = 0;
@@ -621,7 +622,8 @@ fn Sha2x64(comptime params: Sha2Params64) type {
}
// Copy any remainder for next pass.
- mem.copy(u8, d.buf[d.buf_len..], b[off..]);
+ const b_slice = b[off..];
+ @memcpy(d.buf[d.buf_len..][0..b_slice.len], b_slice);
d.buf_len += @intCast(u8, b[off..].len);
d.total_len += b.len;
@@ -634,7 +636,7 @@ fn Sha2x64(comptime params: Sha2Params64) type {
pub fn final(d: *Self, out: *[digest_length]u8) void {
// The buffer here will never be completely full.
- mem.set(u8, d.buf[d.buf_len..], 0);
+ @memset(d.buf[d.buf_len..], 0);
// Append padding bits.
d.buf[d.buf_len] = 0x80;
@@ -643,7 +645,7 @@ fn Sha2x64(comptime params: Sha2Params64) type {
// > 896 mod 1024 so need to add an extra round to wrap around.
if (128 - d.buf_len < 16) {
d.round(d.buf[0..]);
- mem.set(u8, d.buf[0..], 0);
+ @memset(d.buf[0..], 0);
}
// Append message length.