| ... | ... | @@ -72,8 +72,10 @@ pub const Ghash = struct { |
| 72 | 72 | return Ghash.initForBlockCount(key, math.maxInt(usize)); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | const Selector = enum { lo, hi }; |
| 76 | |
| 75 | 77 | // 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 { |
| 77 | 79 | if (half == .hi) { |
| 78 | 80 | const product = asm ( |
| 79 | 81 | \\ vpclmulqdq $0x11, %[x], %[y], %[out] |
| ... | ... | @@ -94,7 +96,7 @@ pub const Ghash = struct { |
| 94 | 96 | } |
| 95 | 97 | |
| 96 | 98 | // 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 { |
| 98 | 100 | if (half == .hi) { |
| 99 | 101 | const product = asm ( |
| 100 | 102 | \\ pmull2 %[out].1q, %[x].2d, %[y].2d |
| ... | ... | @@ -115,7 +117,7 @@ pub const Ghash = struct { |
| 115 | 117 | } |
| 116 | 118 | |
| 117 | 119 | // 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 { |
| 119 | 121 | const x = @truncate(u64, if (half == .hi) x_ >> 64 else x_); |
| 120 | 122 | const y = @truncate(u64, if (half == .hi) y_ >> 64 else y_); |
| 121 | 123 | |