feature. See also
. The project being documented here (as the example) is the Zig library itself.
argon2.processSegment
fn processSegment(
blocks: *Blocks,
passes: u32,
memory: u32,
threads: u24,
mode: Mode,
lanes: u32,
segments: u32,
n: u32,
slice: u32,
lane: u24,
) void
File
Code
fn processSegment(
blocks: *Blocks,
passes: u32,
memory: u32,
threads: u24,
mode: Mode,
lanes: u32,
segments: u32,
n: u32,
slice: u32,
lane: u24,
) void {
var addresses: [block_length]u64 align(16) = @splat(0);
var in: [block_length]u64 align(16) = @splat(0);
const zero: [block_length]u64 align(16) = @splat(0);
if (mode == .argon2i or (mode == .argon2id and n == 0 and slice < sync_points / 2)) {
in[0] = n;
in[1] = lane;
in[2] = slice;
in[3] = memory;
in[4] = passes;
in[5] = @backingInt(mode);
}
var index: u32 = 0;
if (n == 0 and slice == 0) {
index = 2;
if (mode == .argon2i or mode == .argon2id) {
in[6] += 1;
processBlock(&addresses, &in, &zero);
processBlock(&addresses, &addresses, &zero);
}
}
var offset = lane * lanes + slice * segments + index;
var random: u64 = 0;
while (index < segments) : ({
index += 1;
offset += 1;
}) {
var prev = offset -% 1;
if (index == 0 and slice == 0) {
prev +%= lanes;
}
if (mode == .argon2i or (mode == .argon2id and n == 0 and slice < sync_points / 2)) {
if (index % block_length == 0) {
in[6] += 1;
processBlock(&addresses, &in, &zero);
processBlock(&addresses, &addresses, &zero);
}
random = addresses[index % block_length];
} else {
random = blocks.items[prev][0];
}
const new_offset = indexAlpha(random, lanes, segments, threads, n, slice, lane, index);
processBlockXor(&blocks.items[offset], &blocks.items[prev], &blocks.items[new_offset]);
}
}