authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-12 20:55:48-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-13 18:26:13+02:00
loge7b18a7ce69f30c85f21ec8ad6a70211abf5f24b
tree0206b7273a6f7516ae96d44f98afcf1912164c12
parentf97baca6f6288eb786fe3546292465ef76310810

std.crypto: remove `inline` from most functions

To quote the language reference, It is generally better to let the compiler decide when to inline a function, except for these scenarios: * To change how many stack frames are in the call stack, for debugging purposes. * To force comptime-ness of the arguments to propagate to the return value of the function, as in the above example. * Real world performance measurements demand it. Don't guess! Note that inline actually restricts what the compiler is allowed to do. This can harm binary size, compilation speed, and even runtime performance. `zig run lib/std/crypto/benchmark.zig -OReleaseFast` [-before-] vs {+after+} md5: [-990-] {+998+} MiB/s sha1: [-1144-] {+1140+} MiB/s sha256: [-2267-] {+2275+} MiB/s sha512: [-762-] {+767+} MiB/s sha3-256: [-680-] {+683+} MiB/s sha3-512: [-362-] {+363+} MiB/s shake-128: [-835-] {+839+} MiB/s shake-256: [-680-] {+681+} MiB/s turboshake-128: [-1567-] {+1570+} MiB/s turboshake-256: [-1276-] {+1282+} MiB/s blake2s: [-778-] {+789+} MiB/s blake2b: [-1071-] {+1086+} MiB/s blake3: [-1148-] {+1137+} MiB/s ghash: [-10044-] {+10033+} MiB/s polyval: [-9726-] {+10033+} MiB/s poly1305: [-2486-] {+2703+} MiB/s hmac-md5: [-991-] {+998+} MiB/s hmac-sha1: [-1134-] {+1137+} MiB/s hmac-sha256: [-2265-] {+2288+} MiB/s hmac-sha512: [-765-] {+764+} MiB/s siphash-2-4: [-4410-] {+4438+} MiB/s siphash-1-3: [-7144-] {+7225+} MiB/s siphash128-2-4: [-4397-] {+4449+} MiB/s siphash128-1-3: [-7281-] {+7374+} MiB/s aegis-128x4 mac: [-73385-] {+74523+} MiB/s aegis-256x4 mac: [-30160-] {+30539+} MiB/s aegis-128x2 mac: [-66662-] {+67267+} MiB/s aegis-256x2 mac: [-16812-] {+16806+} MiB/s aegis-128l mac: [-33876-] {+34055+} MiB/s aegis-256 mac: [-8993-] {+9087+} MiB/s aes-cmac: 2036 MiB/s x25519: [-20670-] {+16844+} exchanges/s ed25519: [-29763-] {+29576+} signatures/s ecdsa-p256: [-4762-] {+4900+} signatures/s ecdsa-p384: [-1465-] {+1500+} signatures/s ecdsa-secp256k1: [-5643-] {+5769+} signatures/s ed25519: [-21926-] {+21721+} verifications/s ed25519: [-51200-] {+50880+} verifications/s (batch) chacha20Poly1305: [-1189-] {+1109+} MiB/s xchacha20Poly1305: [-1196-] {+1107+} MiB/s xchacha8Poly1305: [-1466-] {+1555+} MiB/s xsalsa20Poly1305: [-660-] {+620+} MiB/s aegis-128x4: [-76389-] {+78181+} MiB/s aegis-128x2: [-53946-] {+53495+} MiB/s aegis-128l: [-27219-] {+25621+} MiB/s aegis-256x4: [-49351-] {+49542+} MiB/s aegis-256x2: [-32390-] {+32366+} MiB/s aegis-256: [-8881-] {+8944+} MiB/s aes128-gcm: [-6095-] {+6205+} MiB/s aes256-gcm: [-5306-] {+5427+} MiB/s aes128-ocb: [-8529-] {+13974+} MiB/s aes256-ocb: [-7241-] {+9442+} MiB/s isapa128a: [-204-] {+214+} MiB/s aes128-single: [-133857882-] {+134170944+} ops/s aes256-single: [-96306962-] {+96408639+} ops/s aes128-8: [-1083210101-] {+1073727253+} ops/s aes256-8: [-762042466-] {+767091778+} ops/s bcrypt: 0.009 s/ops scrypt: [-0.018-] {+0.017+} s/ops argon2: [-0.037-] {+0.060+} s/ops kyber512d00: [-206057-] {+205779+} encaps/s kyber768d00: [-156074-] {+150711+} encaps/s kyber1024d00: [-116626-] {+115469+} encaps/s kyber512d00: [-181149-] {+182046+} decaps/s kyber768d00: [-136965-] {+135676+} decaps/s kyber1024d00: [-101307-] {+100643+} decaps/s kyber512d00: [-123624-] {+123375+} keygen/s kyber768d00: [-69465-] {+70828+} keygen/s kyber1024d00: [-43117-] {+43208+} keygen/s

26 files changed, 161 insertions(+), 161 deletions(-)

lib/std/crypto.zig+1-1
......@@ -386,7 +386,7 @@ test "issue #4532: no index out of bounds" {
386386
387387/// Sets a slice to zeroes.
388388/// Prevents the store from being optimized out.
389pub inline fn secureZero(comptime T: type, s: []volatile T) void {
389pub fn secureZero(comptime T: type, s: []volatile T) void {
390390 @memset(s, 0);
391391}
392392
lib/std/crypto/25519/curve25519.zig+2-2
......@@ -15,12 +15,12 @@ pub const Curve25519 = struct {
1515 x: Fe,
1616
1717 /// Decode a Curve25519 point from its compressed (X) coordinates.
18 pub inline fn fromBytes(s: [32]u8) Curve25519 {
18 pub fn fromBytes(s: [32]u8) Curve25519 {
1919 return .{ .x = Fe.fromBytes(s) };
2020 }
2121
2222 /// Encode a Curve25519 point.
23 pub inline fn toBytes(p: Curve25519) [32]u8 {
23 pub fn toBytes(p: Curve25519) [32]u8 {
2424 return p.x.toBytes();
2525 }
2626
lib/std/crypto/25519/edwards25519.zig+3-3
......@@ -138,7 +138,7 @@ pub const Edwards25519 = struct {
138138 }
139139
140140 /// Flip the sign of the X coordinate.
141 pub inline fn neg(p: Edwards25519) Edwards25519 {
141 pub fn neg(p: Edwards25519) Edwards25519 {
142142 return .{ .x = p.x.neg(), .y = p.y, .z = p.z, .t = p.t.neg() };
143143 }
144144
......@@ -190,14 +190,14 @@ pub const Edwards25519 = struct {
190190 return q;
191191 }
192192
193 inline fn cMov(p: *Edwards25519, a: Edwards25519, c: u64) void {
193 fn cMov(p: *Edwards25519, a: Edwards25519, c: u64) void {
194194 p.x.cMov(a.x, c);
195195 p.y.cMov(a.y, c);
196196 p.z.cMov(a.z, c);
197197 p.t.cMov(a.t, c);
198198 }
199199
200 inline fn pcSelect(comptime n: usize, pc: *const [n]Edwards25519, b: u8) Edwards25519 {
200 fn pcSelect(comptime n: usize, pc: *const [n]Edwards25519, b: u8) Edwards25519 {
201201 var t = Edwards25519.identityElement;
202202 comptime var i: u8 = 1;
203203 inline while (i < pc.len) : (i += 1) {
lib/std/crypto/25519/field.zig+11-11
......@@ -56,7 +56,7 @@ pub const Fe = struct {
5656 pub const edwards25519sqrtam2 = Fe{ .limbs = .{ 1693982333959686, 608509411481997, 2235573344831311, 947681270984193, 266558006233600 } };
5757
5858 /// Return true if the field element is zero
59 pub inline fn isZero(fe: Fe) bool {
59 pub fn isZero(fe: Fe) bool {
6060 var reduced = fe;
6161 reduced.reduce();
6262 const limbs = reduced.limbs;
......@@ -64,7 +64,7 @@ pub const Fe = struct {
6464 }
6565
6666 /// Return true if both field elements are equivalent
67 pub inline fn equivalent(a: Fe, b: Fe) bool {
67 pub fn equivalent(a: Fe, b: Fe) bool {
6868 return a.sub(b).isZero();
6969 }
7070
......@@ -168,7 +168,7 @@ pub const Fe = struct {
168168 }
169169
170170 /// Add a field element
171 pub inline fn add(a: Fe, b: Fe) Fe {
171 pub fn add(a: Fe, b: Fe) Fe {
172172 var fe: Fe = undefined;
173173 comptime var i = 0;
174174 inline while (i < 5) : (i += 1) {
......@@ -178,7 +178,7 @@ pub const Fe = struct {
178178 }
179179
180180 /// Subtract a field element
181 pub inline fn sub(a: Fe, b: Fe) Fe {
181 pub fn sub(a: Fe, b: Fe) Fe {
182182 var fe = b;
183183 comptime var i = 0;
184184 inline while (i < 4) : (i += 1) {
......@@ -197,17 +197,17 @@ pub const Fe = struct {
197197 }
198198
199199 /// Negate a field element
200 pub inline fn neg(a: Fe) Fe {
200 pub fn neg(a: Fe) Fe {
201201 return zero.sub(a);
202202 }
203203
204204 /// Return true if a field element is negative
205 pub inline fn isNegative(a: Fe) bool {
205 pub fn isNegative(a: Fe) bool {
206206 return (a.toBytes()[0] & 1) != 0;
207207 }
208208
209209 /// Conditonally replace a field element with `a` if `c` is positive
210 pub inline fn cMov(fe: *Fe, a: Fe, c: u64) void {
210 pub fn cMov(fe: *Fe, a: Fe, c: u64) void {
211211 const mask: u64 = 0 -% c;
212212 var x = fe.*;
213213 comptime var i = 0;
......@@ -248,7 +248,7 @@ pub const Fe = struct {
248248 }
249249 }
250250
251 inline fn _carry128(r: *[5]u128) Fe {
251 fn _carry128(r: *[5]u128) Fe {
252252 var rs: [5]u64 = undefined;
253253 comptime var i = 0;
254254 inline while (i < 4) : (i += 1) {
......@@ -321,17 +321,17 @@ pub const Fe = struct {
321321 }
322322
323323 /// Square a field element
324 pub inline fn sq(a: Fe) Fe {
324 pub fn sq(a: Fe) Fe {
325325 return _sq(a, false);
326326 }
327327
328328 /// Square and double a field element
329 pub inline fn sq2(a: Fe) Fe {
329 pub fn sq2(a: Fe) Fe {
330330 return _sq(a, true);
331331 }
332332
333333 /// Multiply a field element with a small (32-bit) integer
334 pub inline fn mul32(a: Fe, comptime n: u32) Fe {
334 pub fn mul32(a: Fe, comptime n: u32) Fe {
335335 const sn = @as(u128, @intCast(n));
336336 var fe: Fe = undefined;
337337 var x: u128 = 0;
lib/std/crypto/25519/ristretto255.zig+5-5
......@@ -42,7 +42,7 @@ pub const Ristretto255 = struct {
4242 }
4343
4444 /// Reject the neutral element.
45 pub inline fn rejectIdentity(p: Ristretto255) IdentityElementError!void {
45 pub fn rejectIdentity(p: Ristretto255) IdentityElementError!void {
4646 return p.p.rejectIdentity();
4747 }
4848
......@@ -141,24 +141,24 @@ pub const Ristretto255 = struct {
141141 }
142142
143143 /// Double a Ristretto255 element.
144 pub inline fn dbl(p: Ristretto255) Ristretto255 {
144 pub fn dbl(p: Ristretto255) Ristretto255 {
145145 return .{ .p = p.p.dbl() };
146146 }
147147
148148 /// Add two Ristretto255 elements.
149 pub inline fn add(p: Ristretto255, q: Ristretto255) Ristretto255 {
149 pub fn add(p: Ristretto255, q: Ristretto255) Ristretto255 {
150150 return .{ .p = p.p.add(q.p) };
151151 }
152152
153153 /// Subtract two Ristretto255 elements.
154 pub inline fn sub(p: Ristretto255, q: Ristretto255) Ristretto255 {
154 pub fn sub(p: Ristretto255, q: Ristretto255) Ristretto255 {
155155 return .{ .p = p.p.sub(q.p) };
156156 }
157157
158158 /// Multiply a Ristretto255 element with a scalar.
159159 /// Return error.WeakPublicKey if the resulting element is
160160 /// the identity element.
161 pub inline fn mul(p: Ristretto255, s: [encoded_length]u8) (IdentityElementError || WeakPublicKeyError)!Ristretto255 {
161 pub fn mul(p: Ristretto255, s: [encoded_length]u8) (IdentityElementError || WeakPublicKeyError)!Ristretto255 {
162162 return .{ .p = try p.p.mul(s) };
163163 }
164164
lib/std/crypto/25519/scalar.zig+2-2
......@@ -50,7 +50,7 @@ pub fn reduce64(s: [64]u8) CompressedScalar {
5050
5151/// Perform the X25519 "clamping" operation.
5252/// The scalar is then guaranteed to be a multiple of the cofactor.
53pub inline fn clamp(s: *CompressedScalar) void {
53pub fn clamp(s: *CompressedScalar) void {
5454 s[0] &= 248;
5555 s[31] = (s[31] & 127) | 64;
5656}
......@@ -514,7 +514,7 @@ pub const Scalar = struct {
514514 }
515515
516516 /// Square a scalar `n` times
517 inline fn sqn(x: Scalar, comptime n: comptime_int) Scalar {
517 fn sqn(x: Scalar, comptime n: comptime_int) Scalar {
518518 var i: usize = 0;
519519 var t = x;
520520 while (i < n) : (i += 1) {
lib/std/crypto/aegis.zig+2-2
......@@ -104,7 +104,7 @@ fn State128X(comptime degree: u7) type {
104104 return state;
105105 }
106106
107 inline fn update(state: *State, d1: AesBlockVec, d2: AesBlockVec) void {
107 fn update(state: *State, d1: AesBlockVec, d2: AesBlockVec) void {
108108 const blocks = &state.blocks;
109109 const tmp = blocks[7];
110110 comptime var i: usize = 7;
......@@ -413,7 +413,7 @@ fn State256X(comptime degree: u7) type {
413413 return state;
414414 }
415415
416 inline fn update(state: *State, d: AesBlockVec) void {
416 fn update(state: *State, d: AesBlockVec) void {
417417 const blocks = &state.blocks;
418418 const tmp = blocks[5].encrypt(blocks[0]);
419419 comptime var i: usize = 5;
lib/std/crypto/aes/aesni.zig+26-26
......@@ -17,24 +17,24 @@ pub const Block = struct {
1717 repr: Repr,
1818
1919 /// Convert a byte sequence into an internal representation.
20 pub inline fn fromBytes(bytes: *const [16]u8) Block {
20 pub fn fromBytes(bytes: *const [16]u8) Block {
2121 const repr = mem.bytesToValue(Repr, bytes);
2222 return Block{ .repr = repr };
2323 }
2424
2525 /// Convert the internal representation of a block into a byte sequence.
26 pub inline fn toBytes(block: Block) [16]u8 {
26 pub fn toBytes(block: Block) [16]u8 {
2727 return mem.toBytes(block.repr);
2828 }
2929
3030 /// XOR the block with a byte sequence.
31 pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 {
31 pub fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 {
3232 const x = block.repr ^ fromBytes(bytes).repr;
3333 return mem.toBytes(x);
3434 }
3535
3636 /// Encrypt a block with a round key.
37 pub inline fn encrypt(block: Block, round_key: Block) Block {
37 pub fn encrypt(block: Block, round_key: Block) Block {
3838 return Block{
3939 .repr = asm (
4040 \\ vaesenc %[rk], %[in], %[out]
......@@ -46,7 +46,7 @@ pub const Block = struct {
4646 }
4747
4848 /// Encrypt a block with the last round key.
49 pub inline fn encryptLast(block: Block, round_key: Block) Block {
49 pub fn encryptLast(block: Block, round_key: Block) Block {
5050 return Block{
5151 .repr = asm (
5252 \\ vaesenclast %[rk], %[in], %[out]
......@@ -58,7 +58,7 @@ pub const Block = struct {
5858 }
5959
6060 /// Decrypt a block with a round key.
61 pub inline fn decrypt(block: Block, inv_round_key: Block) Block {
61 pub fn decrypt(block: Block, inv_round_key: Block) Block {
6262 return Block{
6363 .repr = asm (
6464 \\ vaesdec %[rk], %[in], %[out]
......@@ -70,7 +70,7 @@ pub const Block = struct {
7070 }
7171
7272 /// Decrypt a block with the last round key.
73 pub inline fn decryptLast(block: Block, inv_round_key: Block) Block {
73 pub fn decryptLast(block: Block, inv_round_key: Block) Block {
7474 return Block{
7575 .repr = asm (
7676 \\ vaesdeclast %[rk], %[in], %[out]
......@@ -82,17 +82,17 @@ pub const Block = struct {
8282 }
8383
8484 /// Apply the bitwise XOR operation to the content of two blocks.
85 pub inline fn xorBlocks(block1: Block, block2: Block) Block {
85 pub fn xorBlocks(block1: Block, block2: Block) Block {
8686 return Block{ .repr = block1.repr ^ block2.repr };
8787 }
8888
8989 /// Apply the bitwise AND operation to the content of two blocks.
90 pub inline fn andBlocks(block1: Block, block2: Block) Block {
90 pub fn andBlocks(block1: Block, block2: Block) Block {
9191 return Block{ .repr = block1.repr & block2.repr };
9292 }
9393
9494 /// Apply the bitwise OR operation to the content of two blocks.
95 pub inline fn orBlocks(block1: Block, block2: Block) Block {
95 pub fn orBlocks(block1: Block, block2: Block) Block {
9696 return Block{ .repr = block1.repr | block2.repr };
9797 }
9898
......@@ -112,7 +112,7 @@ pub const Block = struct {
112112 };
113113
114114 /// Encrypt multiple blocks in parallel, each their own round key.
115 pub inline fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block {
115 pub fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block {
116116 comptime var i = 0;
117117 var out: [count]Block = undefined;
118118 inline while (i < count) : (i += 1) {
......@@ -122,7 +122,7 @@ pub const Block = struct {
122122 }
123123
124124 /// Decrypt multiple blocks in parallel, each their own round key.
125 pub inline fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block {
125 pub fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block {
126126 comptime var i = 0;
127127 var out: [count]Block = undefined;
128128 inline while (i < count) : (i += 1) {
......@@ -132,7 +132,7 @@ pub const Block = struct {
132132 }
133133
134134 /// Encrypt multiple blocks in parallel with the same round key.
135 pub inline fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
135 pub fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
136136 comptime var i = 0;
137137 var out: [count]Block = undefined;
138138 inline while (i < count) : (i += 1) {
......@@ -142,7 +142,7 @@ pub const Block = struct {
142142 }
143143
144144 /// Decrypt multiple blocks in parallel with the same round key.
145 pub inline fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
145 pub fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
146146 comptime var i = 0;
147147 var out: [count]Block = undefined;
148148 inline while (i < count) : (i += 1) {
......@@ -152,7 +152,7 @@ pub const Block = struct {
152152 }
153153
154154 /// Encrypt multiple blocks in parallel with the same last round key.
155 pub inline fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
155 pub fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
156156 comptime var i = 0;
157157 var out: [count]Block = undefined;
158158 inline while (i < count) : (i += 1) {
......@@ -162,7 +162,7 @@ pub const Block = struct {
162162 }
163163
164164 /// Decrypt multiple blocks in parallel with the same last round key.
165 pub inline fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
165 pub fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
166166 comptime var i = 0;
167167 var out: [count]Block = undefined;
168168 inline while (i < count) : (i += 1) {
......@@ -200,7 +200,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
200200 pub const block_length: usize = blocks_count * 16;
201201
202202 /// Convert a byte sequence into an internal representation.
203 pub inline fn fromBytes(bytes: *const [blocks_count * 16]u8) Self {
203 pub fn fromBytes(bytes: *const [blocks_count * 16]u8) Self {
204204 var out: Self = undefined;
205205 inline for (0..native_words) |i| {
206206 out.repr[i] = mem.bytesToValue(Repr, bytes[i * native_word_size ..][0..native_word_size]);
......@@ -209,7 +209,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
209209 }
210210
211211 /// Convert the internal representation of a block vector into a byte sequence.
212 pub inline fn toBytes(block_vec: Self) [blocks_count * 16]u8 {
212 pub fn toBytes(block_vec: Self) [blocks_count * 16]u8 {
213213 var out: [blocks_count * 16]u8 = undefined;
214214 inline for (0..native_words) |i| {
215215 out[i * native_word_size ..][0..native_word_size].* = mem.toBytes(block_vec.repr[i]);
......@@ -218,7 +218,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
218218 }
219219
220220 /// XOR the block vector with a byte sequence.
221 pub inline fn xorBytes(block_vec: Self, bytes: *const [blocks_count * 16]u8) [blocks_count * 16]u8 {
221 pub fn xorBytes(block_vec: Self, bytes: *const [blocks_count * 16]u8) [blocks_count * 16]u8 {
222222 var x: Self = undefined;
223223 inline for (0..native_words) |i| {
224224 x.repr[i] = block_vec.repr[i] ^ mem.bytesToValue(Repr, bytes[i * native_word_size ..][0..native_word_size]);
......@@ -227,7 +227,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
227227 }
228228
229229 /// Apply the forward AES operation to the block vector with a vector of round keys.
230 pub inline fn encrypt(block_vec: Self, round_key_vec: Self) Self {
230 pub fn encrypt(block_vec: Self, round_key_vec: Self) Self {
231231 var out: Self = undefined;
232232 inline for (0..native_words) |i| {
233233 out.repr[i] = asm (
......@@ -241,7 +241,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
241241 }
242242
243243 /// Apply the forward AES operation to the block vector with a vector of last round keys.
244 pub inline fn encryptLast(block_vec: Self, round_key_vec: Self) Self {
244 pub fn encryptLast(block_vec: Self, round_key_vec: Self) Self {
245245 var out: Self = undefined;
246246 inline for (0..native_words) |i| {
247247 out.repr[i] = asm (
......@@ -255,7 +255,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
255255 }
256256
257257 /// Apply the inverse AES operation to the block vector with a vector of round keys.
258 pub inline fn decrypt(block_vec: Self, inv_round_key_vec: Self) Self {
258 pub fn decrypt(block_vec: Self, inv_round_key_vec: Self) Self {
259259 var out: Self = undefined;
260260 inline for (0..native_words) |i| {
261261 out.repr[i] = asm (
......@@ -269,7 +269,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
269269 }
270270
271271 /// Apply the inverse AES operation to the block vector with a vector of last round keys.
272 pub inline fn decryptLast(block_vec: Self, inv_round_key_vec: Self) Self {
272 pub fn decryptLast(block_vec: Self, inv_round_key_vec: Self) Self {
273273 var out: Self = undefined;
274274 inline for (0..native_words) |i| {
275275 out.repr[i] = asm (
......@@ -283,7 +283,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
283283 }
284284
285285 /// Apply the bitwise XOR operation to the content of two block vectors.
286 pub inline fn xorBlocks(block_vec1: Self, block_vec2: Self) Self {
286 pub fn xorBlocks(block_vec1: Self, block_vec2: Self) Self {
287287 var out: Self = undefined;
288288 inline for (0..native_words) |i| {
289289 out.repr[i] = block_vec1.repr[i] ^ block_vec2.repr[i];
......@@ -292,7 +292,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
292292 }
293293
294294 /// Apply the bitwise AND operation to the content of two block vectors.
295 pub inline fn andBlocks(block_vec1: Self, block_vec2: Self) Self {
295 pub fn andBlocks(block_vec1: Self, block_vec2: Self) Self {
296296 var out: Self = undefined;
297297 inline for (0..native_words) |i| {
298298 out.repr[i] = block_vec1.repr[i] & block_vec2.repr[i];
......@@ -301,7 +301,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
301301 }
302302
303303 /// Apply the bitwise OR operation to the content of two block vectors.
304 pub inline fn orBlocks(block_vec1: Self, block_vec2: Block) Self {
304 pub fn orBlocks(block_vec1: Self, block_vec2: Block) Self {
305305 var out: Self = undefined;
306306 inline for (0..native_words) |i| {
307307 out.repr[i] = block_vec1.repr[i] | block_vec2.repr[i];
lib/std/crypto/aes/armcrypto.zig+26-26
......@@ -12,18 +12,18 @@ pub const Block = struct {
1212 repr: Repr,
1313
1414 /// Convert a byte sequence into an internal representation.
15 pub inline fn fromBytes(bytes: *const [16]u8) Block {
15 pub fn fromBytes(bytes: *const [16]u8) Block {
1616 const repr = mem.bytesToValue(Repr, bytes);
1717 return Block{ .repr = repr };
1818 }
1919
2020 /// Convert the internal representation of a block into a byte sequence.
21 pub inline fn toBytes(block: Block) [16]u8 {
21 pub fn toBytes(block: Block) [16]u8 {
2222 return mem.toBytes(block.repr);
2323 }
2424
2525 /// XOR the block with a byte sequence.
26 pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 {
26 pub fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 {
2727 const x = block.repr ^ fromBytes(bytes).repr;
2828 return mem.toBytes(x);
2929 }
......@@ -31,7 +31,7 @@ pub const Block = struct {
3131 const zero = @Vector(2, u64){ 0, 0 };
3232
3333 /// Encrypt a block with a round key.
34 pub inline fn encrypt(block: Block, round_key: Block) Block {
34 pub fn encrypt(block: Block, round_key: Block) Block {
3535 return Block{
3636 .repr = (asm (
3737 \\ mov %[out].16b, %[in].16b
......@@ -45,7 +45,7 @@ pub const Block = struct {
4545 }
4646
4747 /// Encrypt a block with the last round key.
48 pub inline fn encryptLast(block: Block, round_key: Block) Block {
48 pub fn encryptLast(block: Block, round_key: Block) Block {
4949 return Block{
5050 .repr = (asm (
5151 \\ mov %[out].16b, %[in].16b
......@@ -58,7 +58,7 @@ pub const Block = struct {
5858 }
5959
6060 /// Decrypt a block with a round key.
61 pub inline fn decrypt(block: Block, inv_round_key: Block) Block {
61 pub fn decrypt(block: Block, inv_round_key: Block) Block {
6262 return Block{
6363 .repr = (asm (
6464 \\ mov %[out].16b, %[in].16b
......@@ -72,7 +72,7 @@ pub const Block = struct {
7272 }
7373
7474 /// Decrypt a block with the last round key.
75 pub inline fn decryptLast(block: Block, inv_round_key: Block) Block {
75 pub fn decryptLast(block: Block, inv_round_key: Block) Block {
7676 return Block{
7777 .repr = (asm (
7878 \\ mov %[out].16b, %[in].16b
......@@ -85,17 +85,17 @@ pub const Block = struct {
8585 }
8686
8787 /// Apply the bitwise XOR operation to the content of two blocks.
88 pub inline fn xorBlocks(block1: Block, block2: Block) Block {
88 pub fn xorBlocks(block1: Block, block2: Block) Block {
8989 return Block{ .repr = block1.repr ^ block2.repr };
9090 }
9191
9292 /// Apply the bitwise AND operation to the content of two blocks.
93 pub inline fn andBlocks(block1: Block, block2: Block) Block {
93 pub fn andBlocks(block1: Block, block2: Block) Block {
9494 return Block{ .repr = block1.repr & block2.repr };
9595 }
9696
9797 /// Apply the bitwise OR operation to the content of two blocks.
98 pub inline fn orBlocks(block1: Block, block2: Block) Block {
98 pub fn orBlocks(block1: Block, block2: Block) Block {
9999 return Block{ .repr = block1.repr | block2.repr };
100100 }
101101
......@@ -105,7 +105,7 @@ pub const Block = struct {
105105 pub const optimal_parallel_blocks = 6;
106106
107107 /// Encrypt multiple blocks in parallel, each their own round key.
108 pub inline fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block {
108 pub fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block {
109109 comptime var i = 0;
110110 var out: [count]Block = undefined;
111111 inline while (i < count) : (i += 1) {
......@@ -115,7 +115,7 @@ pub const Block = struct {
115115 }
116116
117117 /// Decrypt multiple blocks in parallel, each their own round key.
118 pub inline fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block {
118 pub fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block {
119119 comptime var i = 0;
120120 var out: [count]Block = undefined;
121121 inline while (i < count) : (i += 1) {
......@@ -125,7 +125,7 @@ pub const Block = struct {
125125 }
126126
127127 /// Encrypt multiple blocks in parallel with the same round key.
128 pub inline fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
128 pub fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
129129 comptime var i = 0;
130130 var out: [count]Block = undefined;
131131 inline while (i < count) : (i += 1) {
......@@ -135,7 +135,7 @@ pub const Block = struct {
135135 }
136136
137137 /// Decrypt multiple blocks in parallel with the same round key.
138 pub inline fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
138 pub fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
139139 comptime var i = 0;
140140 var out: [count]Block = undefined;
141141 inline while (i < count) : (i += 1) {
......@@ -145,7 +145,7 @@ pub const Block = struct {
145145 }
146146
147147 /// Encrypt multiple blocks in parallel with the same last round key.
148 pub inline fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
148 pub fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
149149 comptime var i = 0;
150150 var out: [count]Block = undefined;
151151 inline while (i < count) : (i += 1) {
......@@ -155,7 +155,7 @@ pub const Block = struct {
155155 }
156156
157157 /// Decrypt multiple blocks in parallel with the same last round key.
158 pub inline fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
158 pub fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block {
159159 comptime var i = 0;
160160 var out: [count]Block = undefined;
161161 inline while (i < count) : (i += 1) {
......@@ -187,7 +187,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
187187 pub const block_length: usize = blocks_count * 16;
188188
189189 /// Convert a byte sequence into an internal representation.
190 pub inline fn fromBytes(bytes: *const [blocks_count * 16]u8) Self {
190 pub fn fromBytes(bytes: *const [blocks_count * 16]u8) Self {
191191 var out: Self = undefined;
192192 inline for (0..native_words) |i| {
193193 out.repr[i] = Block.fromBytes(bytes[i * native_word_size ..][0..native_word_size]);
......@@ -196,7 +196,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
196196 }
197197
198198 /// Convert the internal representation of a block vector into a byte sequence.
199 pub inline fn toBytes(block_vec: Self) [blocks_count * 16]u8 {
199 pub fn toBytes(block_vec: Self) [blocks_count * 16]u8 {
200200 var out: [blocks_count * 16]u8 = undefined;
201201 inline for (0..native_words) |i| {
202202 out[i * native_word_size ..][0..native_word_size].* = block_vec.repr[i].toBytes();
......@@ -205,7 +205,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
205205 }
206206
207207 /// XOR the block vector with a byte sequence.
208 pub inline fn xorBytes(block_vec: Self, bytes: *const [blocks_count * 16]u8) [32]u8 {
208 pub fn xorBytes(block_vec: Self, bytes: *const [blocks_count * 16]u8) [32]u8 {
209209 var out: Self = undefined;
210210 inline for (0..native_words) |i| {
211211 out.repr[i] = block_vec.repr[i].xorBytes(bytes[i * native_word_size ..][0..native_word_size]);
......@@ -214,7 +214,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
214214 }
215215
216216 /// Apply the forward AES operation to the block vector with a vector of round keys.
217 pub inline fn encrypt(block_vec: Self, round_key_vec: Self) Self {
217 pub fn encrypt(block_vec: Self, round_key_vec: Self) Self {
218218 var out: Self = undefined;
219219 inline for (0..native_words) |i| {
220220 out.repr[i] = block_vec.repr[i].encrypt(round_key_vec.repr[i]);
......@@ -223,7 +223,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
223223 }
224224
225225 /// Apply the forward AES operation to the block vector with a vector of last round keys.
226 pub inline fn encryptLast(block_vec: Self, round_key_vec: Self) Self {
226 pub fn encryptLast(block_vec: Self, round_key_vec: Self) Self {
227227 var out: Self = undefined;
228228 inline for (0..native_words) |i| {
229229 out.repr[i] = block_vec.repr[i].encryptLast(round_key_vec.repr[i]);
......@@ -232,7 +232,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
232232 }
233233
234234 /// Apply the inverse AES operation to the block vector with a vector of round keys.
235 pub inline fn decrypt(block_vec: Self, inv_round_key_vec: Self) Self {
235 pub fn decrypt(block_vec: Self, inv_round_key_vec: Self) Self {
236236 var out: Self = undefined;
237237 inline for (0..native_words) |i| {
238238 out.repr[i] = block_vec.repr[i].decrypt(inv_round_key_vec.repr[i]);
......@@ -241,7 +241,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
241241 }
242242
243243 /// Apply the inverse AES operation to the block vector with a vector of last round keys.
244 pub inline fn decryptLast(block_vec: Self, inv_round_key_vec: Self) Self {
244 pub fn decryptLast(block_vec: Self, inv_round_key_vec: Self) Self {
245245 var out: Self = undefined;
246246 inline for (0..native_words) |i| {
247247 out.repr[i] = block_vec.repr[i].decryptLast(inv_round_key_vec.repr[i]);
......@@ -250,7 +250,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
250250 }
251251
252252 /// Apply the bitwise XOR operation to the content of two block vectors.
253 pub inline fn xorBlocks(block_vec1: Self, block_vec2: Self) Self {
253 pub fn xorBlocks(block_vec1: Self, block_vec2: Self) Self {
254254 var out: Self = undefined;
255255 inline for (0..native_words) |i| {
256256 out.repr[i] = block_vec1.repr[i].xorBlocks(block_vec2.repr[i]);
......@@ -259,7 +259,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
259259 }
260260
261261 /// Apply the bitwise AND operation to the content of two block vectors.
262 pub inline fn andBlocks(block_vec1: Self, block_vec2: Self) Self {
262 pub fn andBlocks(block_vec1: Self, block_vec2: Self) Self {
263263 var out: Self = undefined;
264264 inline for (0..native_words) |i| {
265265 out.repr[i] = block_vec1.repr[i].andBlocks(block_vec2.repr[i]);
......@@ -268,7 +268,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
268268 }
269269
270270 /// Apply the bitwise OR operation to the content of two block vectors.
271 pub inline fn orBlocks(block_vec1: Self, block_vec2: Block) Self {
271 pub fn orBlocks(block_vec1: Self, block_vec2: Block) Self {
272272 var out: Self = undefined;
273273 inline for (0..native_words) |i| {
274274 out.repr[i] = block_vec1.repr[i].orBlocks(block_vec2.repr[i]);
lib/std/crypto/aes/soft.zig+22-22
......@@ -14,7 +14,7 @@ pub const Block = struct {
1414 repr: Repr align(16),
1515
1616 /// Convert a byte sequence into an internal representation.
17 pub inline fn fromBytes(bytes: *const [16]u8) Block {
17 pub fn fromBytes(bytes: *const [16]u8) Block {
1818 const s0 = mem.readInt(u32, bytes[0..4], .little);
1919 const s1 = mem.readInt(u32, bytes[4..8], .little);
2020 const s2 = mem.readInt(u32, bytes[8..12], .little);
......@@ -23,7 +23,7 @@ pub const Block = struct {
2323 }
2424
2525 /// Convert the internal representation of a block into a byte sequence.
26 pub inline fn toBytes(block: Block) [16]u8 {
26 pub fn toBytes(block: Block) [16]u8 {
2727 var bytes: [16]u8 = undefined;
2828 mem.writeInt(u32, bytes[0..4], block.repr[0], .little);
2929 mem.writeInt(u32, bytes[4..8], block.repr[1], .little);
......@@ -33,7 +33,7 @@ pub const Block = struct {
3333 }
3434
3535 /// XOR the block with a byte sequence.
36 pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 {
36 pub fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 {
3737 const block_bytes = block.toBytes();
3838 var x: [16]u8 = undefined;
3939 comptime var i: usize = 0;
......@@ -44,7 +44,7 @@ pub const Block = struct {
4444 }
4545
4646 /// Encrypt a block with a round key.
47 pub inline fn encrypt(block: Block, round_key: Block) Block {
47 pub fn encrypt(block: Block, round_key: Block) Block {
4848 const s0 = block.repr[0];
4949 const s1 = block.repr[1];
5050 const s2 = block.repr[2];
......@@ -69,7 +69,7 @@ pub const Block = struct {
6969 }
7070
7171 /// Encrypt a block with a round key *WITHOUT ANY PROTECTION AGAINST SIDE CHANNELS*
72 pub inline fn encryptUnprotected(block: Block, round_key: Block) Block {
72 pub fn encryptUnprotected(block: Block, round_key: Block) Block {
7373 const s0 = block.repr[0];
7474 const s1 = block.repr[1];
7575 const s2 = block.repr[2];
......@@ -114,7 +114,7 @@ pub const Block = struct {
114114 }
115115
116116 /// Encrypt a block with the last round key.
117 pub inline fn encryptLast(block: Block, round_key: Block) Block {
117 pub fn encryptLast(block: Block, round_key: Block) Block {
118118 const s0 = block.repr[0];
119119 const s1 = block.repr[1];
120120 const s2 = block.repr[2];
......@@ -140,7 +140,7 @@ pub const Block = struct {
140140 }
141141
142142 /// Decrypt a block with a round key.
143 pub inline fn decrypt(block: Block, round_key: Block) Block {
143 pub fn decrypt(block: Block, round_key: Block) Block {
144144 const s0 = block.repr[0];
145145 const s1 = block.repr[1];
146146 const s2 = block.repr[2];
......@@ -165,7 +165,7 @@ pub const Block = struct {
165165 }
166166
167167 /// Decrypt a block with a round key *WITHOUT ANY PROTECTION AGAINST SIDE CHANNELS*
168 pub inline fn decryptUnprotected(block: Block, round_key: Block) Block {
168 pub fn decryptUnprotected(block: Block, round_key: Block) Block {
169169 const s0 = block.repr[0];
170170 const s1 = block.repr[1];
171171 const s2 = block.repr[2];
......@@ -210,7 +210,7 @@ pub const Block = struct {
210210 }
211211
212212 /// Decrypt a block with the last round key.
213 pub inline fn decryptLast(block: Block, round_key: Block) Block {
213 pub fn decryptLast(block: Block, round_key: Block) Block {
214214 const s0 = block.repr[0];
215215 const s1 = block.repr[1];
216216 const s2 = block.repr[2];
......@@ -236,7 +236,7 @@ pub const Block = struct {
236236 }
237237
238238 /// Apply the bitwise XOR operation to the content of two blocks.
239 pub inline fn xorBlocks(block1: Block, block2: Block) Block {
239 pub fn xorBlocks(block1: Block, block2: Block) Block {
240240 var x: Repr = undefined;
241241 comptime var i = 0;
242242 inline while (i < 4) : (i += 1) {
......@@ -246,7 +246,7 @@ pub const Block = struct {
246246 }
247247
248248 /// Apply the bitwise AND operation to the content of two blocks.
249 pub inline fn andBlocks(block1: Block, block2: Block) Block {
249 pub fn andBlocks(block1: Block, block2: Block) Block {
250250 var x: Repr = undefined;
251251 comptime var i = 0;
252252 inline while (i < 4) : (i += 1) {
......@@ -256,7 +256,7 @@ pub const Block = struct {
256256 }
257257
258258 /// Apply the bitwise OR operation to the content of two blocks.
259 pub inline fn orBlocks(block1: Block, block2: Block) Block {
259 pub fn orBlocks(block1: Block, block2: Block) Block {
260260 var x: Repr = undefined;
261261 comptime var i = 0;
262262 inline while (i < 4) : (i += 1) {
......@@ -353,7 +353,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
353353 pub const block_length: usize = blocks_count * 16;
354354
355355 /// Convert a byte sequence into an internal representation.
356 pub inline fn fromBytes(bytes: *const [blocks_count * 16]u8) Self {
356 pub fn fromBytes(bytes: *const [blocks_count * 16]u8) Self {
357357 var out: Self = undefined;
358358 for (0..native_words) |i| {
359359 out.repr[i] = Block.fromBytes(bytes[i * native_word_size ..][0..native_word_size]);
......@@ -362,7 +362,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
362362 }
363363
364364 /// Convert the internal representation of a block vector into a byte sequence.
365 pub inline fn toBytes(block_vec: Self) [blocks_count * 16]u8 {
365 pub fn toBytes(block_vec: Self) [blocks_count * 16]u8 {
366366 var out: [blocks_count * 16]u8 = undefined;
367367 for (0..native_words) |i| {
368368 out[i * native_word_size ..][0..native_word_size].* = block_vec.repr[i].toBytes();
......@@ -371,7 +371,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
371371 }
372372
373373 /// XOR the block vector with a byte sequence.
374 pub inline fn xorBytes(block_vec: Self, bytes: *const [blocks_count * 16]u8) [32]u8 {
374 pub fn xorBytes(block_vec: Self, bytes: *const [blocks_count * 16]u8) [32]u8 {
375375 var out: Self = undefined;
376376 for (0..native_words) |i| {
377377 out.repr[i] = block_vec.repr[i].xorBytes(bytes[i * native_word_size ..][0..native_word_size]);
......@@ -380,7 +380,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
380380 }
381381
382382 /// Apply the forward AES operation to the block vector with a vector of round keys.
383 pub inline fn encrypt(block_vec: Self, round_key_vec: Self) Self {
383 pub fn encrypt(block_vec: Self, round_key_vec: Self) Self {
384384 var out: Self = undefined;
385385 for (0..native_words) |i| {
386386 out.repr[i] = block_vec.repr[i].encrypt(round_key_vec.repr[i]);
......@@ -389,7 +389,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
389389 }
390390
391391 /// Apply the forward AES operation to the block vector with a vector of last round keys.
392 pub inline fn encryptLast(block_vec: Self, round_key_vec: Self) Self {
392 pub fn encryptLast(block_vec: Self, round_key_vec: Self) Self {
393393 var out: Self = undefined;
394394 for (0..native_words) |i| {
395395 out.repr[i] = block_vec.repr[i].encryptLast(round_key_vec.repr[i]);
......@@ -398,7 +398,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
398398 }
399399
400400 /// Apply the inverse AES operation to the block vector with a vector of round keys.
401 pub inline fn decrypt(block_vec: Self, inv_round_key_vec: Self) Self {
401 pub fn decrypt(block_vec: Self, inv_round_key_vec: Self) Self {
402402 var out: Self = undefined;
403403 for (0..native_words) |i| {
404404 out.repr[i] = block_vec.repr[i].decrypt(inv_round_key_vec.repr[i]);
......@@ -407,7 +407,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
407407 }
408408
409409 /// Apply the inverse AES operation to the block vector with a vector of last round keys.
410 pub inline fn decryptLast(block_vec: Self, inv_round_key_vec: Self) Self {
410 pub fn decryptLast(block_vec: Self, inv_round_key_vec: Self) Self {
411411 var out: Self = undefined;
412412 for (0..native_words) |i| {
413413 out.repr[i] = block_vec.repr[i].decryptLast(inv_round_key_vec.repr[i]);
......@@ -416,7 +416,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
416416 }
417417
418418 /// Apply the bitwise XOR operation to the content of two block vectors.
419 pub inline fn xorBlocks(block_vec1: Self, block_vec2: Self) Self {
419 pub fn xorBlocks(block_vec1: Self, block_vec2: Self) Self {
420420 var out: Self = undefined;
421421 for (0..native_words) |i| {
422422 out.repr[i] = block_vec1.repr[i].xorBlocks(block_vec2.repr[i]);
......@@ -425,7 +425,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
425425 }
426426
427427 /// Apply the bitwise AND operation to the content of two block vectors.
428 pub inline fn andBlocks(block_vec1: Self, block_vec2: Self) Self {
428 pub fn andBlocks(block_vec1: Self, block_vec2: Self) Self {
429429 var out: Self = undefined;
430430 for (0..native_words) |i| {
431431 out.repr[i] = block_vec1.repr[i].andBlocks(block_vec2.repr[i]);
......@@ -434,7 +434,7 @@ pub fn BlockVec(comptime blocks_count: comptime_int) type {
434434 }
435435
436436 /// Apply the bitwise OR operation to the content of two block vectors.
437 pub inline fn orBlocks(block_vec1: Self, block_vec2: Block) Self {
437 pub fn orBlocks(block_vec1: Self, block_vec2: Block) Self {
438438 var out: Self = undefined;
439439 for (0..native_words) |i| {
440440 out.repr[i] = block_vec1.repr[i].orBlocks(block_vec2.repr[i]);
lib/std/crypto/aes_ocb.zig+3-3
......@@ -28,7 +28,7 @@ fn AesOcb(comptime Aes: anytype) type {
2828 table: [56]Block align(16) = undefined,
2929 upto: usize,
3030
31 inline fn double(l: Block) Block {
31 fn double(l: Block) Block {
3232 const l_ = mem.readInt(u128, &l, .big);
3333 const l_2 = (l_ << 1) ^ (0x87 & -%(l_ >> 127));
3434 var l2: Block = undefined;
......@@ -244,7 +244,7 @@ fn AesOcb(comptime Aes: anytype) type {
244244 };
245245}
246246
247inline fn xorBlocks(x: Block, y: Block) Block {
247fn xorBlocks(x: Block, y: Block) Block {
248248 var z: Block = x;
249249 for (&z, 0..) |*v, i| {
250250 v.* = x[i] ^ y[i];
......@@ -252,7 +252,7 @@ inline fn xorBlocks(x: Block, y: Block) Block {
252252 return z;
253253}
254254
255inline fn xorWith(x: *Block, y: Block) void {
255fn xorWith(x: *Block, y: Block) void {
256256 for (x, 0..) |*v, i| {
257257 v.* ^= y[i];
258258 }
lib/std/crypto/ascon.zig+4-4
......@@ -157,7 +157,7 @@ pub fn State(comptime endian: std.builtin.Endian) type {
157157 }
158158
159159 /// Apply a reduced-round permutation to the state.
160 pub inline fn permuteR(state: *Self, comptime rounds: u4) void {
160 pub fn permuteR(state: *Self, comptime rounds: u4) void {
161161 const rks = [16]u64{ 0x3c, 0x2d, 0x1e, 0x0f, 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87, 0x78, 0x69, 0x5a, 0x4b };
162162 inline for (rks[rks.len - rounds ..]) |rk| {
163163 state.round(rk);
......@@ -165,13 +165,13 @@ pub fn State(comptime endian: std.builtin.Endian) type {
165165 }
166166
167167 /// Apply a full-round permutation to the state.
168 pub inline fn permute(state: *Self) void {
168 pub fn permute(state: *Self) void {
169169 state.permuteR(12);
170170 }
171171
172172 /// Apply a permutation to the state and prevent backtracking.
173173 /// The rate is expressed in bytes and must be a multiple of the word size (8).
174 pub inline fn permuteRatchet(state: *Self, comptime rounds: u4, comptime rate: u6) void {
174 pub fn permuteRatchet(state: *Self, comptime rounds: u4, comptime rate: u6) void {
175175 const capacity = block_bytes - rate;
176176 debug.assert(capacity > 0 and capacity % 8 == 0); // capacity must be a multiple of 64 bits
177177 var mask: [capacity / 8]u64 = undefined;
......@@ -181,7 +181,7 @@ pub fn State(comptime endian: std.builtin.Endian) type {
181181 }
182182
183183 // Core Ascon permutation.
184 inline fn round(state: *Self, rk: u64) void {
184 fn round(state: *Self, rk: u64) void {
185185 const x = &state.st;
186186 x[2] ^= rk;
187187
lib/std/crypto/blake3.zig+3-3
......@@ -61,7 +61,7 @@ const CompressVectorized = struct {
6161 const Lane = @Vector(4, u32);
6262 const Rows = [4]Lane;
6363
64 inline fn g(comptime even: bool, rows: *Rows, m: Lane) void {
64 fn g(comptime even: bool, rows: *Rows, m: Lane) void {
6565 rows[0] +%= rows[1] +% m;
6666 rows[3] ^= rows[0];
6767 rows[3] = math.rotr(Lane, rows[3], if (even) 8 else 16);
......@@ -70,13 +70,13 @@ const CompressVectorized = struct {
7070 rows[1] = math.rotr(Lane, rows[1], if (even) 7 else 12);
7171 }
7272
73 inline fn diagonalize(rows: *Rows) void {
73 fn diagonalize(rows: *Rows) void {
7474 rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 3, 0, 1, 2 });
7575 rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 });
7676 rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 1, 2, 3, 0 });
7777 }
7878
79 inline fn undiagonalize(rows: *Rows) void {
79 fn undiagonalize(rows: *Rows) void {
8080 rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 1, 2, 3, 0 });
8181 rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 });
8282 rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 3, 0, 1, 2 });
lib/std/crypto/chacha20.zig+6-6
......@@ -151,7 +151,7 @@ fn ChaChaVecImpl(comptime rounds_nb: usize, comptime degree: comptime_int) type
151151 }
152152 }
153153
154 inline fn chacha20Core(x: *BlockVec, input: BlockVec) void {
154 fn chacha20Core(x: *BlockVec, input: BlockVec) void {
155155 x.* = input;
156156
157157 const m0 = switch (degree) {
......@@ -215,7 +215,7 @@ fn ChaChaVecImpl(comptime rounds_nb: usize, comptime degree: comptime_int) type
215215 }
216216 }
217217
218 inline fn hashToBytes(comptime dm: usize, out: *[64 * dm]u8, x: BlockVec) void {
218 fn hashToBytes(comptime dm: usize, out: *[64 * dm]u8, x: BlockVec) void {
219219 for (0..dm) |d| {
220220 for (0..4) |i| {
221221 mem.writeInt(u32, out[64 * d + 16 * i + 0 ..][0..4], x[i][0 + 4 * d], .little);
......@@ -226,7 +226,7 @@ fn ChaChaVecImpl(comptime rounds_nb: usize, comptime degree: comptime_int) type
226226 }
227227 }
228228
229 inline fn contextFeedback(x: *BlockVec, ctx: BlockVec) void {
229 fn contextFeedback(x: *BlockVec, ctx: BlockVec) void {
230230 x[0] +%= ctx[0];
231231 x[1] +%= ctx[1];
232232 x[2] +%= ctx[2];
......@@ -365,7 +365,7 @@ fn ChaChaNonVecImpl(comptime rounds_nb: usize) type {
365365 };
366366 }
367367
368 inline fn chacha20Core(x: *BlockVec, input: BlockVec) void {
368 fn chacha20Core(x: *BlockVec, input: BlockVec) void {
369369 x.* = input;
370370
371371 const rounds = comptime [_]QuarterRound{
......@@ -394,7 +394,7 @@ fn ChaChaNonVecImpl(comptime rounds_nb: usize) type {
394394 }
395395 }
396396
397 inline fn hashToBytes(out: *[64]u8, x: BlockVec) void {
397 fn hashToBytes(out: *[64]u8, x: BlockVec) void {
398398 for (0..4) |i| {
399399 mem.writeInt(u32, out[16 * i + 0 ..][0..4], x[i * 4 + 0], .little);
400400 mem.writeInt(u32, out[16 * i + 4 ..][0..4], x[i * 4 + 1], .little);
......@@ -403,7 +403,7 @@ fn ChaChaNonVecImpl(comptime rounds_nb: usize) type {
403403 }
404404 }
405405
406 inline fn contextFeedback(x: *BlockVec, ctx: BlockVec) void {
406 fn contextFeedback(x: *BlockVec, ctx: BlockVec) void {
407407 for (0..16) |i| {
408408 x[i] +%= ctx[i];
409409 }
lib/std/crypto/codecs/base64_hex_ct.zig+7-7
......@@ -280,34 +280,34 @@ pub const base64 = struct {
280280 return DecoderWithIgnore{ .ignored_chars = ignored_chars };
281281 }
282282
283 inline fn eq(x: u8, y: u8) u8 {
283 fn eq(x: u8, y: u8) u8 {
284284 return ~@as(u8, @truncate((0 -% (@as(u16, x) ^ @as(u16, y))) >> 8));
285285 }
286286
287 inline fn gt(x: u8, y: u8) u8 {
287 fn gt(x: u8, y: u8) u8 {
288288 return @truncate((@as(u16, y) -% @as(u16, x)) >> 8);
289289 }
290290
291 inline fn ge(x: u8, y: u8) u8 {
291 fn ge(x: u8, y: u8) u8 {
292292 return ~gt(y, x);
293293 }
294294
295 inline fn lt(x: u8, y: u8) u8 {
295 fn lt(x: u8, y: u8) u8 {
296296 return gt(y, x);
297297 }
298298
299 inline fn le(x: u8, y: u8) u8 {
299 fn le(x: u8, y: u8) u8 {
300300 return ge(y, x);
301301 }
302302
303 inline fn charFromByte(x: u8, comptime urlsafe: bool) u8 {
303 fn charFromByte(x: u8, comptime urlsafe: bool) u8 {
304304 return (lt(x, 26) & (x +% 'A')) |
305305 (ge(x, 26) & lt(x, 52) & (x +% 'a' -% 26)) |
306306 (ge(x, 52) & lt(x, 62) & (x +% '0' -% 52)) |
307307 (eq(x, 62) & '+') | (eq(x, 63) & if (urlsafe) '_' else '/');
308308 }
309309
310 inline fn byteFromChar(c: u8, comptime urlsafe: bool) u8 {
310 fn byteFromChar(c: u8, comptime urlsafe: bool) u8 {
311311 const x =
312312 (ge(c, 'A') & le(c, 'Z') & (c -% 'A')) |
313313 (ge(c, 'a') & le(c, 'z') & (c -% 'a' +% 26)) |
lib/std/crypto/ghash_polyval.zig+5-5
......@@ -89,7 +89,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
8989 const Selector = enum { lo, hi, hi_lo };
9090
9191 // Carryless multiplication of two 64-bit integers for x86_64.
92 inline fn clmulPclmul(x: u128, y: u128, comptime half: Selector) u128 {
92 fn clmulPclmul(x: u128, y: u128, comptime half: Selector) u128 {
9393 switch (half) {
9494 .hi => {
9595 const product = asm (
......@@ -122,7 +122,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
122122 }
123123
124124 // Carryless multiplication of two 64-bit integers for ARM crypto.
125 inline fn clmulPmull(x: u128, y: u128, comptime half: Selector) u128 {
125 fn clmulPmull(x: u128, y: u128, comptime half: Selector) u128 {
126126 switch (half) {
127127 .hi => {
128128 const product = asm (
......@@ -231,7 +231,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
231231 mid: u128,
232232 };
233233
234 inline fn xor256(x: *I256, y: I256) void {
234 fn xor256(x: *I256, y: I256) void {
235235 x.* = I256{
236236 .hi = x.hi ^ y.hi,
237237 .lo = x.lo ^ y.lo,
......@@ -249,7 +249,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
249249 }
250250
251251 // Multiply two 128-bit integers in GF(2^128).
252 inline fn clmul128(x: u128, y: u128) I256 {
252 fn clmul128(x: u128, y: u128) I256 {
253253 if (mul_algorithm == .karatsuba) {
254254 const x_hi = @as(u64, @truncate(x >> 64));
255255 const y_hi = @as(u64, @truncate(y >> 64));
......@@ -273,7 +273,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
273273 // Reduce a 256-bit representative of a polynomial modulo the irreducible polynomial x^128 + x^127 + x^126 + x^121 + 1.
274274 // This is done using Shay Gueron's black magic demysticated here:
275275 // https://blog.quarkslab.com/reversing-a-finite-field-multiplication-optimization.html
276 inline fn reduce(x: I256) u128 {
276 fn reduce(x: I256) u128 {
277277 const hi = x.hi ^ (x.mid >> 64);
278278 const lo = x.lo ^ (x.mid << 64);
279279 const p64 = (((1 << 121) | (1 << 126) | (1 << 127)) >> 64);
lib/std/crypto/pcurves/p256/p256_64.zig+4-4
......@@ -72,7 +72,7 @@ pub const NonMontgomeryDomainFieldElement = [4]u64;
7272/// Output Bounds:
7373/// out1: [0x0 ~> 0xffffffffffffffff]
7474/// out2: [0x0 ~> 0x1]
75inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
75fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
7676 const x = @as(u128, arg2) +% arg3 +% arg1;
7777 out1.* = @truncate(x);
7878 out2.* = @truncate(x >> 64);
......@@ -91,7 +91,7 @@ inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) vo
9191/// Output Bounds:
9292/// out1: [0x0 ~> 0xffffffffffffffff]
9393/// out2: [0x0 ~> 0x1]
94inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
94fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
9595 const x = @as(u128, arg2) -% arg3 -% arg1;
9696 out1.* = @truncate(x);
9797 out2.* = @truncate(x >> 64);
......@@ -109,7 +109,7 @@ inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) v
109109/// Output Bounds:
110110/// out1: [0x0 ~> 0xffffffffffffffff]
111111/// out2: [0x0 ~> 0xffffffffffffffff]
112inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
112fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
113113 @setRuntimeSafety(mode == .Debug);
114114
115115 const x = @as(u128, arg1) * @as(u128, arg2);
......@@ -128,7 +128,7 @@ inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
128128/// arg3: [0x0 ~> 0xffffffffffffffff]
129129/// Output Bounds:
130130/// out1: [0x0 ~> 0xffffffffffffffff]
131inline fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
131fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
132132 @setRuntimeSafety(mode == .Debug);
133133
134134 const mask = 0 -% @as(u64, arg1);
lib/std/crypto/pcurves/p256/p256_scalar_64.zig+4-4
......@@ -72,7 +72,7 @@ pub const NonMontgomeryDomainFieldElement = [4]u64;
7272/// Output Bounds:
7373/// out1: [0x0 ~> 0xffffffffffffffff]
7474/// out2: [0x0 ~> 0x1]
75inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
75fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
7676 const x = @as(u128, arg2) +% arg3 +% arg1;
7777 out1.* = @truncate(x);
7878 out2.* = @truncate(x >> 64);
......@@ -91,7 +91,7 @@ inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) vo
9191/// Output Bounds:
9292/// out1: [0x0 ~> 0xffffffffffffffff]
9393/// out2: [0x0 ~> 0x1]
94inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
94fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
9595 const x = @as(u128, arg2) -% arg3 -% arg1;
9696 out1.* = @truncate(x);
9797 out2.* = @truncate(x >> 64);
......@@ -109,7 +109,7 @@ inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) v
109109/// Output Bounds:
110110/// out1: [0x0 ~> 0xffffffffffffffff]
111111/// out2: [0x0 ~> 0xffffffffffffffff]
112inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
112fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
113113 @setRuntimeSafety(mode == .Debug);
114114
115115 const x = @as(u128, arg1) * @as(u128, arg2);
......@@ -128,7 +128,7 @@ inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
128128/// arg3: [0x0 ~> 0xffffffffffffffff]
129129/// Output Bounds:
130130/// out1: [0x0 ~> 0xffffffffffffffff]
131inline fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
131fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
132132 @setRuntimeSafety(mode == .Debug);
133133
134134 const mask = 0 -% @as(u64, arg1);
lib/std/crypto/pcurves/p384/p384_64.zig+4-4
......@@ -41,7 +41,7 @@ pub const NonMontgomeryDomainFieldElement = [6]u64;
4141/// Output Bounds:
4242/// out1: [0x0 ~> 0xffffffffffffffff]
4343/// out2: [0x0 ~> 0x1]
44inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
44fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
4545 const x = @as(u128, arg2) +% arg3 +% arg1;
4646 out1.* = @truncate(x);
4747 out2.* = @truncate(x >> 64);
......@@ -60,7 +60,7 @@ inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) vo
6060/// Output Bounds:
6161/// out1: [0x0 ~> 0xffffffffffffffff]
6262/// out2: [0x0 ~> 0x1]
63inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
63fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
6464 const x = @as(u128, arg2) -% arg3 -% arg1;
6565 out1.* = @truncate(x);
6666 out2.* = @truncate(x >> 64);
......@@ -78,7 +78,7 @@ inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) v
7878/// Output Bounds:
7979/// out1: [0x0 ~> 0xffffffffffffffff]
8080/// out2: [0x0 ~> 0xffffffffffffffff]
81inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
81fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
8282 @setRuntimeSafety(mode == .Debug);
8383
8484 const x = @as(u128, arg1) * @as(u128, arg2);
......@@ -97,7 +97,7 @@ inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
9797/// arg3: [0x0 ~> 0xffffffffffffffff]
9898/// Output Bounds:
9999/// out1: [0x0 ~> 0xffffffffffffffff]
100inline fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
100fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
101101 @setRuntimeSafety(mode == .Debug);
102102
103103 const mask = 0 -% @as(u64, arg1);
lib/std/crypto/pcurves/p384/p384_scalar_64.zig+4-4
......@@ -41,7 +41,7 @@ pub const NonMontgomeryDomainFieldElement = [6]u64;
4141/// Output Bounds:
4242/// out1: [0x0 ~> 0xffffffffffffffff]
4343/// out2: [0x0 ~> 0x1]
44inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
44fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
4545 const x = @as(u128, arg2) +% arg3 +% arg1;
4646 out1.* = @truncate(x);
4747 out2.* = @truncate(x >> 64);
......@@ -60,7 +60,7 @@ inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) vo
6060/// Output Bounds:
6161/// out1: [0x0 ~> 0xffffffffffffffff]
6262/// out2: [0x0 ~> 0x1]
63inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
63fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
6464 const x = @as(u128, arg2) -% arg3 -% arg1;
6565 out1.* = @truncate(x);
6666 out2.* = @truncate(x >> 64);
......@@ -78,7 +78,7 @@ inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) v
7878/// Output Bounds:
7979/// out1: [0x0 ~> 0xffffffffffffffff]
8080/// out2: [0x0 ~> 0xffffffffffffffff]
81inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
81fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
8282 @setRuntimeSafety(mode == .Debug);
8383
8484 const x = @as(u128, arg1) * @as(u128, arg2);
......@@ -97,7 +97,7 @@ inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
9797/// arg3: [0x0 ~> 0xffffffffffffffff]
9898/// Output Bounds:
9999/// out1: [0x0 ~> 0xffffffffffffffff]
100inline fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
100fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
101101 @setRuntimeSafety(mode == .Debug);
102102
103103 const mask = 0 -% @as(u64, arg1);
lib/std/crypto/pcurves/secp256k1/secp256k1_64.zig+4-4
......@@ -41,7 +41,7 @@ pub const NonMontgomeryDomainFieldElement = [4]u64;
4141/// Output Bounds:
4242/// out1: [0x0 ~> 0xffffffffffffffff]
4343/// out2: [0x0 ~> 0x1]
44inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
44fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
4545 const x = @as(u128, arg2) +% arg3 +% arg1;
4646 out1.* = @truncate(x);
4747 out2.* = @truncate(x >> 64);
......@@ -60,7 +60,7 @@ inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) vo
6060/// Output Bounds:
6161/// out1: [0x0 ~> 0xffffffffffffffff]
6262/// out2: [0x0 ~> 0x1]
63inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
63fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
6464 const x = @as(u128, arg2) -% arg3 -% arg1;
6565 out1.* = @truncate(x);
6666 out2.* = @truncate(x >> 64);
......@@ -78,7 +78,7 @@ inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) v
7878/// Output Bounds:
7979/// out1: [0x0 ~> 0xffffffffffffffff]
8080/// out2: [0x0 ~> 0xffffffffffffffff]
81inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
81fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
8282 @setRuntimeSafety(mode == .Debug);
8383
8484 const x = @as(u128, arg1) * @as(u128, arg2);
......@@ -97,7 +97,7 @@ inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
9797/// arg3: [0x0 ~> 0xffffffffffffffff]
9898/// Output Bounds:
9999/// out1: [0x0 ~> 0xffffffffffffffff]
100inline fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
100fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
101101 @setRuntimeSafety(mode == .Debug);
102102
103103 const mask = 0 -% @as(u64, arg1);
lib/std/crypto/pcurves/secp256k1/secp256k1_scalar_64.zig+4-4
......@@ -41,7 +41,7 @@ pub const NonMontgomeryDomainFieldElement = [4]u64;
4141/// Output Bounds:
4242/// out1: [0x0 ~> 0xffffffffffffffff]
4343/// out2: [0x0 ~> 0x1]
44inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
44fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
4545 const x = @as(u128, arg2) +% arg3 +% arg1;
4646 out1.* = @truncate(x);
4747 out2.* = @truncate(x >> 64);
......@@ -60,7 +60,7 @@ inline fn addcarryxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) vo
6060/// Output Bounds:
6161/// out1: [0x0 ~> 0xffffffffffffffff]
6262/// out2: [0x0 ~> 0x1]
63inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
63fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void {
6464 const x = @as(u128, arg2) -% arg3 -% arg1;
6565 out1.* = @truncate(x);
6666 out2.* = @truncate(x >> 64);
......@@ -78,7 +78,7 @@ inline fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) v
7878/// Output Bounds:
7979/// out1: [0x0 ~> 0xffffffffffffffff]
8080/// out2: [0x0 ~> 0xffffffffffffffff]
81inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
81fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
8282 @setRuntimeSafety(mode == .Debug);
8383
8484 const x = @as(u128, arg1) * @as(u128, arg2);
......@@ -97,7 +97,7 @@ inline fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void {
9797/// arg3: [0x0 ~> 0xffffffffffffffff]
9898/// Output Bounds:
9999/// out1: [0x0 ~> 0xffffffffffffffff]
100inline fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
100fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void {
101101 @setRuntimeSafety(mode == .Debug);
102102
103103 const mask = 0 -% @as(u64, arg1);
lib/std/crypto/poly1305.zig+2-2
......@@ -31,13 +31,13 @@ pub const Poly1305 = struct {
3131 };
3232 }
3333
34 inline fn add(a: u64, b: u64, c: u1) struct { u64, u1 } {
34 fn add(a: u64, b: u64, c: u1) struct { u64, u1 } {
3535 const v1 = @addWithOverflow(a, b);
3636 const v2 = @addWithOverflow(v1[0], c);
3737 return .{ v2[0], v1[1] | v2[1] };
3838 }
3939
40 inline fn sub(a: u64, b: u64, c: u1) struct { u64, u1 } {
40 fn sub(a: u64, b: u64, c: u1) struct { u64, u1 } {
4141 const v1 = @subWithOverflow(a, b);
4242 const v2 = @subWithOverflow(v1[0], c);
4343 return .{ v2[0], v1[1] | v2[1] };
lib/std/crypto/salsa20.zig+3-3
......@@ -41,7 +41,7 @@ fn SalsaVecImpl(comptime rounds: comptime_int) type {
4141 };
4242 }
4343
44 inline fn salsaCore(x: *BlockVec, input: BlockVec, comptime feedback: bool) void {
44 fn salsaCore(x: *BlockVec, input: BlockVec, comptime feedback: bool) void {
4545 const n1n2n3n0 = Lane{ input[3][1], input[3][2], input[3][3], input[3][0] };
4646 const n1n2 = Half{ n1n2n3n0[0], n1n2n3n0[1] };
4747 const n3n0 = Half{ n1n2n3n0[2], n1n2n3n0[3] };
......@@ -203,7 +203,7 @@ fn SalsaNonVecImpl(comptime rounds: comptime_int) type {
203203 d: u6,
204204 };
205205
206 inline fn Rp(a: usize, b: usize, c: usize, d: u6) QuarterRound {
206 fn Rp(a: usize, b: usize, c: usize, d: u6) QuarterRound {
207207 return QuarterRound{
208208 .a = a,
209209 .b = b,
......@@ -212,7 +212,7 @@ fn SalsaNonVecImpl(comptime rounds: comptime_int) type {
212212 };
213213 }
214214
215 inline fn salsaCore(x: *BlockVec, input: BlockVec, comptime feedback: bool) void {
215 fn salsaCore(x: *BlockVec, input: BlockVec, comptime feedback: bool) void {
216216 const arx_steps = comptime [_]QuarterRound{
217217 Rp(4, 0, 12, 7), Rp(8, 4, 0, 9), Rp(12, 8, 4, 13), Rp(0, 12, 8, 18),
218218 Rp(9, 5, 1, 7), Rp(13, 9, 5, 9), Rp(1, 13, 9, 13), Rp(5, 1, 13, 18),
lib/std/crypto/tls.zig+3-3
......@@ -588,11 +588,11 @@ pub fn hmac(comptime Hmac: type, message: []const u8, key: [Hmac.key_length]u8)
588588 return result;
589589}
590590
591pub inline fn extension(et: ExtensionType, bytes: anytype) [2 + 2 + bytes.len]u8 {
591pub fn extension(et: ExtensionType, bytes: anytype) [2 + 2 + bytes.len]u8 {
592592 return int(u16, @intFromEnum(et)) ++ array(u16, u8, bytes);
593593}
594594
595pub inline fn array(
595pub fn array(
596596 comptime Len: type,
597597 comptime Elem: type,
598598 elems: anytype,
......@@ -617,7 +617,7 @@ pub inline fn array(
617617 return arr;
618618}
619619
620pub inline fn int(comptime Int: type, val: Int) [@divExact(@bitSizeOf(Int), 8)]u8 {
620pub fn int(comptime Int: type, val: Int) [@divExact(@bitSizeOf(Int), 8)]u8 {
621621 var arr: [@divExact(@bitSizeOf(Int), 8)]u8 = undefined;
622622 std.mem.writeInt(Int, &arr, val, .big);
623623 return arr;
lib/std/crypto/tls/Client.zig+1-1
......@@ -1576,7 +1576,7 @@ fn straddleByte(s1: []const u8, s2: []const u8, index: usize) u8 {
15761576const builtin = @import("builtin");
15771577const native_endian = builtin.cpu.arch.endian();
15781578
1579inline fn big(x: anytype) @TypeOf(x) {
1579fn big(x: anytype) @TypeOf(x) {
15801580 return switch (native_endian) {
15811581 .big => x,
15821582 .little => @byteSwap(x),