ref: 9a83081ebe28cc5d5e52718f3d0ef2d0a6df21b7
parent: 4ab9c0f5b96c84329a887f7fdbba92066c8ad7a7
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Jun 3 14:58:15 EDT 2014
Remove a reliance on the sha256 type from step()
--- a/libcryptohash/sha256.myr
+++ b/libcryptohash/sha256.myr
@@ -44,11 +44,11 @@
n = 64 - ntail
std.slcp(st.tail[n:], data[:n])
data = data[n:]
- step(st, st.tail[:])
+ step(st.x[:], st.tail[:])
;;
while data.len >= 64
- step(st, data[:64])
+ step(st.x[:], data[:64])
data = data[64:]
;;
@@ -80,7 +80,7 @@
st.tail[ntail++] = 0x80
std.slfill(st.tail[ntail:], 0)
if 64 - ntail < 8
- step(st, st.tail[:])
+ step(st.x[:], st.tail[:])
std.slfill(st.tail[:], 0)
;;
@@ -93,10 +93,10 @@
st.tail[61] = ((st.msglen * 8) >> 16) castto(byte)
st.tail[62] = ((st.msglen * 8) >> 8) castto(byte)
st.tail[63] = ((st.msglen * 8) >> 0) castto(byte)
- step(st, st.tail[:])
+ step(st.x[:], st.tail[:])
}
-const step = {st, msg
+const step = {x, msg
var a, b, c, d, e, f, g, h
var s00, s01, s02, s03, s04, s05, s06, s07
var s08, s09, s10, s11, s12, s13, s14, s15
@@ -107,14 +107,14 @@
var s48, s49, s50, s51, s52, s53, s54, s55
var s56, s57, s58, s59, s60, s61, s62, s63
- a = st.x[0]
- b = st.x[1]
- c = st.x[2]
- d = st.x[3]
- e = st.x[4]
- f = st.x[5]
- g = st.x[6]
- h = st.x[7]
+ a = x[0]
+ b = x[1]
+ c = x[2]
+ d = x[3]
+ e = x[4]
+ f = x[5]
+ g = x[6]
+ h = x[7]
s00 = unpack(msg[ 0: 4])
s01 = unpack(msg[ 4: 8])
@@ -312,14 +312,14 @@
a += (((f << 26) | (f >> 6)) ^ ((f << 21) | (f >> 11)) ^ ((f << 7) | (f >> 25))) + (h ^ (f & (g ^ h))) + 0xc67178f2 + s63;
e += a; a += (((b << 30) | (b >> 2)) ^ ((b << 19) | (b >> 13)) ^ ((b << 10) | (b >> 22))) + ((b & (c | d)) | (c & d));
- st.x[0] += a
- st.x[1] += b
- st.x[2] += c
- st.x[3] += d
- st.x[4] += e
- st.x[5] += f
- st.x[6] += g
- st.x[7] += h
+ x[0] += a
+ x[1] += b
+ x[2] += c
+ x[3] += d
+ x[4] += e
+ x[5] += f
+ x[6] += g
+ x[7] += h
}
const unpack = {b