authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2022-12-06 00:47:04+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-05 19:25:10-05:00
log397881fefb9acd204b14ee56d703410b4b1fae9e
treef85c5f6e33dd84fe13e606a41b94f4ee078e1ba7
parentdc852f8226749eb8dd5e1e2496f18a4d102f60b1

treshold -> threshold


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

lib/std/crypto/ghash_polyval.zig+8-8
...@@ -32,9 +32,9 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {...@@ -32,9 +32,9 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
32 pub const key_length = 16;32 pub const key_length = 16;
3333
34 const pc_count = if (builtin.mode != .ReleaseSmall) 16 else 2;34 const pc_count = if (builtin.mode != .ReleaseSmall) 16 else 2;
35 const agg_4_treshold = 22;35 const agg_4_threshold = 22;
36 const agg_8_treshold = 84;36 const agg_8_threshold = 84;
37 const agg_16_treshold = 328;37 const agg_16_threshold = 328;
3838
39 // Before the Haswell architecture, the carryless multiplication instruction was39 // Before the Haswell architecture, the carryless multiplication instruction was
40 // extremely slow. Even with 128-bit operands, using Karatsuba multiplication was40 // extremely slow. Even with 128-bit operands, using Karatsuba multiplication was
...@@ -65,13 +65,13 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {...@@ -65,13 +65,13 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
65 if (builtin.mode != .ReleaseSmall) {65 if (builtin.mode != .ReleaseSmall) {
66 hx[2] = reduce(clmul128(hx[1], h)); // h^366 hx[2] = reduce(clmul128(hx[1], h)); // h^3
67 hx[3] = reduce(clsq128(hx[1])); // h^4 = h^2^267 hx[3] = reduce(clsq128(hx[1])); // h^4 = h^2^2
68 if (block_count >= agg_8_treshold) {68 if (block_count >= agg_8_threshold) {
69 hx[4] = reduce(clmul128(hx[3], h)); // h^569 hx[4] = reduce(clmul128(hx[3], h)); // h^5
70 hx[5] = reduce(clsq128(hx[2])); // h^6 = h^3^270 hx[5] = reduce(clsq128(hx[2])); // h^6 = h^3^2
71 hx[6] = reduce(clmul128(hx[5], h)); // h^771 hx[6] = reduce(clmul128(hx[5], h)); // h^7
72 hx[7] = reduce(clsq128(hx[3])); // h^8 = h^4^272 hx[7] = reduce(clsq128(hx[3])); // h^8 = h^4^2
73 }73 }
74 if (block_count >= agg_16_treshold) {74 if (block_count >= agg_16_threshold) {
75 var i: usize = 8;75 var i: usize = 8;
76 while (i < 16) : (i += 2) {76 while (i < 16) : (i += 2) {
77 hx[i] = reduce(clmul128(hx[i - 1], h));77 hx[i] = reduce(clmul128(hx[i - 1], h));
...@@ -263,7 +263,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {...@@ -263,7 +263,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
263263
264 var i: usize = 0;264 var i: usize = 0;
265265
266 if (builtin.mode != .ReleaseSmall and msg.len >= agg_16_treshold * block_length) {266 if (builtin.mode != .ReleaseSmall and msg.len >= agg_16_threshold * block_length) {
267 // 16-blocks aggregated reduction267 // 16-blocks aggregated reduction
268 while (i + 256 <= msg.len) : (i += 256) {268 while (i + 256 <= msg.len) : (i += 256) {
269 var u = clmul128(acc ^ mem.readInt(u128, msg[i..][0..16], endian), st.hx[15 - 0]);269 var u = clmul128(acc ^ mem.readInt(u128, msg[i..][0..16], endian), st.hx[15 - 0]);
...@@ -273,7 +273,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {...@@ -273,7 +273,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
273 }273 }
274 acc = reduce(u);274 acc = reduce(u);
275 }275 }
276 } else if (builtin.mode != .ReleaseSmall and msg.len >= agg_8_treshold * block_length) {276 } else if (builtin.mode != .ReleaseSmall and msg.len >= agg_8_threshold * block_length) {
277 // 8-blocks aggregated reduction277 // 8-blocks aggregated reduction
278 while (i + 128 <= msg.len) : (i += 128) {278 while (i + 128 <= msg.len) : (i += 128) {
279 var u = clmul128(acc ^ mem.readInt(u128, msg[i..][0..16], endian), st.hx[7 - 0]);279 var u = clmul128(acc ^ mem.readInt(u128, msg[i..][0..16], endian), st.hx[7 - 0]);
...@@ -283,7 +283,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {...@@ -283,7 +283,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
283 }283 }
284 acc = reduce(u);284 acc = reduce(u);
285 }285 }
286 } else if (builtin.mode != .ReleaseSmall and msg.len >= agg_4_treshold * block_length) {286 } else if (builtin.mode != .ReleaseSmall and msg.len >= agg_4_threshold * block_length) {
287 // 4-blocks aggregated reduction287 // 4-blocks aggregated reduction
288 while (i + 64 <= msg.len) : (i += 64) {288 while (i + 64 <= msg.len) : (i += 64) {
289 var u = clmul128(acc ^ mem.readInt(u128, msg[i..][0..16], endian), st.hx[3 - 0]);289 var u = clmul128(acc ^ mem.readInt(u128, msg[i..][0..16], endian), st.hx[3 - 0]);