| ... | @@ -19,10 +19,10 @@ pub const Ghash = struct { | ... | @@ -19,10 +19,10 @@ pub const Ghash = struct { |
| 19 | pub const key_length = 16; | 19 | pub const key_length = 16; |
| 20 | | 20 | |
| 21 | const pc_count = if (builtin.mode != .ReleaseSmall) 16 else 2; | 21 | const pc_count = if (builtin.mode != .ReleaseSmall) 16 else 2; |
| 22 | const agg_2_treshold = 5 * block_length; | 22 | const agg_2_treshold = 5; |
| 23 | const agg_4_treshold = 22 * block_length; | 23 | const agg_4_treshold = 22; |
| 24 | const agg_8_treshold = 84 * block_length; | 24 | const agg_8_treshold = 84; |
| 25 | const agg_16_treshold = 328 * block_length; | 25 | const agg_16_treshold = 328; |
| 26 | | 26 | |
| 27 | hx: [pc_count]Precomp, | 27 | hx: [pc_count]Precomp, |
| 28 | acc: u128 = 0, | 28 | acc: u128 = 0, |
| ... | @@ -199,7 +199,7 @@ pub const Ghash = struct { | ... | @@ -199,7 +199,7 @@ pub const Ghash = struct { |
| 199 | | 199 | |
| 200 | var i: usize = 0; | 200 | var i: usize = 0; |
| 201 | | 201 | |
| 202 | if (builtin.mode != .ReleaseSmall and msg.len >= agg_16_treshold) { | 202 | if (builtin.mode != .ReleaseSmall and msg.len >= agg_16_treshold * block_length) { |
| 203 | // 16-blocks aggregated reduction | 203 | // 16-blocks aggregated reduction |
| 204 | while (i + 256 <= msg.len) : (i += 256) { | 204 | while (i + 256 <= msg.len) : (i += 256) { |
| 205 | var u = clmul128(acc ^ mem.readIntBig(u128, msg[i..][0..16]), st.hx[15 - 0]); | 205 | var u = clmul128(acc ^ mem.readIntBig(u128, msg[i..][0..16]), st.hx[15 - 0]); |
| ... | @@ -209,7 +209,7 @@ pub const Ghash = struct { | ... | @@ -209,7 +209,7 @@ pub const Ghash = struct { |
| 209 | } | 209 | } |
| 210 | acc = gcmReduce(u); | 210 | acc = gcmReduce(u); |
| 211 | } | 211 | } |
| 212 | } else if (builtin.mode != .ReleaseSmall and msg.len >= agg_8_treshold) { | 212 | } else if (builtin.mode != .ReleaseSmall and msg.len >= agg_8_treshold * block_length) { |
| 213 | // 8-blocks aggregated reduction | 213 | // 8-blocks aggregated reduction |
| 214 | while (i + 128 <= msg.len) : (i += 128) { | 214 | while (i + 128 <= msg.len) : (i += 128) { |
| 215 | var u = clmul128(acc ^ mem.readIntBig(u128, msg[i..][0..16]), st.hx[7 - 0]); | 215 | var u = clmul128(acc ^ mem.readIntBig(u128, msg[i..][0..16]), st.hx[7 - 0]); |
| ... | @@ -219,7 +219,7 @@ pub const Ghash = struct { | ... | @@ -219,7 +219,7 @@ pub const Ghash = struct { |
| 219 | } | 219 | } |
| 220 | acc = gcmReduce(u); | 220 | acc = gcmReduce(u); |
| 221 | } | 221 | } |
| 222 | } else if (builtin.mode != .ReleaseSmall and msg.len >= agg_4_treshold) { | 222 | } else if (builtin.mode != .ReleaseSmall and msg.len >= agg_4_treshold * block_length) { |
| 223 | // 4-blocks aggregated reduction | 223 | // 4-blocks aggregated reduction |
| 224 | while (i + 64 <= msg.len) : (i += 64) { | 224 | while (i + 64 <= msg.len) : (i += 64) { |
| 225 | var u = clmul128(acc ^ mem.readIntBig(u128, msg[i..][0..16]), st.hx[3 - 0]); | 225 | var u = clmul128(acc ^ mem.readIntBig(u128, msg[i..][0..16]), st.hx[3 - 0]); |
| ... | @@ -229,7 +229,7 @@ pub const Ghash = struct { | ... | @@ -229,7 +229,7 @@ pub const Ghash = struct { |
| 229 | } | 229 | } |
| 230 | acc = gcmReduce(u); | 230 | acc = gcmReduce(u); |
| 231 | } | 231 | } |
| 232 | } else if (msg.len >= agg_2_treshold) { | 232 | } else if (msg.len >= agg_2_treshold * block_length) { |
| 233 | // 2-blocks aggregated reduction | 233 | // 2-blocks aggregated reduction |
| 234 | while (i + 32 <= msg.len) : (i += 32) { | 234 | while (i + 32 <= msg.len) : (i += 32) { |
| 235 | var u = clmul128(acc ^ mem.readIntBig(u128, msg[i..][0..16]), st.hx[1 - 0]); | 235 | var u = clmul128(acc ^ mem.readIntBig(u128, msg[i..][0..16]), st.hx[1 - 0]); |