val SHA256hash : forall ('part1 : Bool).
(bits(128), bits(128), bits(128), bool('part1)) -> bits(128)
function SHA256hash (x_in, y_in, w, part1) = {
chs : bits(32) = undefined;
maj : bits(32) = undefined;
t : bits(32) = undefined;
x : bits(128) = x_in;
y : bits(128) = y_in;
foreach (e from 0 to 3 by 1 in inc) {
chs = SHAchoose(y[31 .. 0], y[63 .. 32], y[95 .. 64]);
maj = SHAmajority(x[31 .. 0], x[63 .. 32], x[95 .. 64]);
t = y[127 .. 96] + SHAhashSIGMA1(y[31 .. 0]) + chs + Elem_read(w, e, 32);
x[127 .. 96] = t + x[127 .. 96];
y[127 .. 96] = t + SHAhashSIGMA0(x[31 .. 0]) + maj;
(y @ x) = ROL(y @ x, 32)
};
return(if part1 then x else y)
}
Made from ScarletNX's Sail at 166ad3910f80. sail-arm's definitions are Arm's ASL in Sail (BSD 3-Clause Clear, license); ScarletNX's fixups are GPL-3.0-or-later.