authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2020-09-29 14:01:08+02:00
committergravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2020-09-29 14:01:08+02:00
log56d820087d712c3b3e93e8aeed8d556509050479
tree78e5f3ac76ec178b8ffc2b0ed5aac8b542cdb8e6
parent4194714965a8080e6faa87d9859cc90aab07fe54

gimli: make permute a constant, remove leading underscore


1 files changed, 3 insertions(+), 9 deletions(-)

lib/std/crypto/gimli.zig+3-9
...@@ -38,7 +38,7 @@ pub const State = struct {...@@ -38,7 +38,7 @@ pub const State = struct {
38 return mem.sliceAsBytes(self.data[0..]);38 return mem.sliceAsBytes(self.data[0..]);
39 }39 }
4040
41 fn _permute_unrolled(self: *Self) void {41 fn permute_unrolled(self: *Self) void {
42 const state = &self.data;42 const state = &self.data;
43 comptime var round = @as(u32, 24);43 comptime var round = @as(u32, 24);
44 inline while (round > 0) : (round -= 1) {44 inline while (round > 0) : (round -= 1) {
...@@ -66,7 +66,7 @@ pub const State = struct {...@@ -66,7 +66,7 @@ pub const State = struct {
66 }66 }
67 }67 }
6868
69 fn _permute_small(self: *Self) void {69 fn permute_small(self: *Self) void {
70 const state = &self.data;70 const state = &self.data;
71 var round = @as(u32, 24);71 var round = @as(u32, 24);
72 while (round > 0) : (round -= 1) {72 while (round > 0) : (round -= 1) {
...@@ -94,13 +94,7 @@ pub const State = struct {...@@ -94,13 +94,7 @@ pub const State = struct {
94 }94 }
95 }95 }
9696
97 pub fn permute(self: *Self) void {97 pub const permute = if (std.builtin.mode == .ReleaseSmall) permute_small else permute_unrolled;
98 if (std.builtin.mode == .ReleaseSmall) {
99 self._permute_small();
100 } else {
101 self._permute_unrolled();
102 }
103 }
10498
105 pub fn squeeze(self: *Self, out: []u8) void {99 pub fn squeeze(self: *Self, out: []u8) void {
106 var i = @as(usize, 0);100 var i = @as(usize, 0);