summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-06-03 18:58:15 -0400
committerOri Bernstein <ori@eigenstate.org>2015-08-24 22:10:06 -0700
commit9a83081ebe28cc5d5e52718f3d0ef2d0a6df21b7 (patch)
treedc85e1f6c8754bd355795bb5a48b126cc78a2b59
parent4ab9c0f5b96c84329a887f7fdbba92066c8ad7a7 (diff)
downloadmc-9a83081ebe28cc5d5e52718f3d0ef2d0a6df21b7.tar.gz
Remove a reliance on the sha256 type from step()
-rw-r--r--libcryptohash/sha256.myr42
1 files changed, 21 insertions, 21 deletions
diff --git a/libcryptohash/sha256.myr b/libcryptohash/sha256.myr
index 6bf29fc..ed66e3c 100644
--- a/libcryptohash/sha256.myr
+++ b/libcryptohash/sha256.myr
@@ -44,11 +44,11 @@ const sha256add = {st, data
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 @@ const tail = {st
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 @@ const tail = {st
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 @@ const step = {st, msg
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 @@ const step = {st, msg
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