authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2022-11-08 16:59:53+01:00
committergravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2022-11-08 16:59:53+01:00
log36e618aef138e9c3612a74f144358cb9574e695f
tree8b864c9ec59c717375b648079982bff3dffd6919
parent7d48cb11389f5dfe73d25e59c1038398a8ba9ca9

crypto.ghash: compatibility with stage1

Defining the selector enum outside the function definition is required for stage1.

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

lib/std/crypto/ghash.zig+5-3
......@@ -72,8 +72,10 @@ pub const Ghash = struct {
7272 return Ghash.initForBlockCount(key, math.maxInt(usize));
7373 }
7474
75 const Selector = enum { lo, hi };
76
7577 // Carryless multiplication of two 64-bit integers for x86_64.
76 inline fn clmulPclmul(x: u128, y: u128, comptime half: enum { lo, hi }) u128 {
78 inline fn clmulPclmul(x: u128, y: u128, comptime half: Selector) u128 {
7779 if (half == .hi) {
7880 const product = asm (
7981 \\ vpclmulqdq $0x11, %[x], %[y], %[out]
......@@ -94,7 +96,7 @@ pub const Ghash = struct {
9496 }
9597
9698 // Carryless multiplication of two 64-bit integers for ARM crypto.
97 inline fn clmulPmull(x: u128, y: u128, comptime half: enum { lo, hi }) u128 {
99 inline fn clmulPmull(x: u128, y: u128, comptime half: Selector) u128 {
98100 if (half == .hi) {
99101 const product = asm (
100102 \\ pmull2 %[out].1q, %[x].2d, %[y].2d
......@@ -115,7 +117,7 @@ pub const Ghash = struct {
115117 }
116118
117119 // Software carryless multiplication of two 64-bit integers.
118 fn clmulSoft(x_: u128, y_: u128, comptime half: enum { lo, hi }) u128 {
120 fn clmulSoft(x_: u128, y_: u128, comptime half: Selector) u128 {
119121 const x = @truncate(u64, if (half == .hi) x_ >> 64 else x_);
120122 const y = @truncate(u64, if (half == .hi) y_ >> 64 else y_);
121123