Skip to content

Commit b239a17

Browse files
jedisct1andrewrk
authored andcommitted
crypto.bcrypt: fix massive speed regression when using stage2 (#13518)
state: State -> state: *const State Suggested by @nektro Fixes #13510
1 parent 50fb7a4 commit b239a17

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/std/crypto/bcrypt.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,15 @@ pub const State = struct {
374374

375375
const Halves = struct { l: u32, r: u32 };
376376

377-
fn halfRound(state: State, i: u32, j: u32, n: usize) u32 {
377+
fn halfRound(state: *const State, i: u32, j: u32, n: usize) u32 {
378378
var r = state.sboxes[0][@truncate(u8, j >> 24)];
379379
r +%= state.sboxes[1][@truncate(u8, j >> 16)];
380380
r ^= state.sboxes[2][@truncate(u8, j >> 8)];
381381
r +%= state.sboxes[3][@truncate(u8, j)];
382382
return i ^ r ^ state.subkeys[n];
383383
}
384384

385-
fn encipher(state: State, halves: *Halves) void {
385+
fn encipher(state: *const State, halves: *Halves) void {
386386
halves.l ^= state.subkeys[0];
387387
comptime var i = 1;
388388
inline while (i < 16) : (i += 2) {
@@ -393,7 +393,7 @@ pub const State = struct {
393393
halves.* = halves_last;
394394
}
395395

396-
fn encrypt(state: State, data: []u32) void {
396+
fn encrypt(state: *const State, data: []u32) void {
397397
debug.assert(data.len % 2 == 0);
398398
var i: usize = 0;
399399
while (i < data.len) : (i += 2) {

0 commit comments

Comments
 (0)