summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-06-03 19:00:26 -0400
committerOri Bernstein <ori@eigenstate.org>2015-08-24 22:10:06 -0700
commit8f779f0802ffab46227e01c6ecd1a1187474d96f (patch)
tree5612a7bbfb1615835d6281d24904058b946ec644
parent9a83081ebe28cc5d5e52718f3d0ef2d0a6df21b7 (diff)
downloadmc-8f779f0802ffab46227e01c6ecd1a1187474d96f.tar.gz
Remove reliance on shaw56 type from tail() functon.
Again, share the common code with sha224
-rw-r--r--libcryptohash/sha256.myr32
1 files changed, 16 insertions, 16 deletions
diff --git a/libcryptohash/sha256.myr b/libcryptohash/sha256.myr
index ed66e3c..4389d65 100644
--- a/libcryptohash/sha256.myr
+++ b/libcryptohash/sha256.myr
@@ -59,7 +59,7 @@ const sha256add = {st, data
const sha256fin = {st
var r : byte[32]
- tail(st)
+ tail(st.x[:], st.msglen, st.tail[:])
pack(r[0:4], st.x[0])
pack(r[4:8], st.x[1])
@@ -72,28 +72,28 @@ const sha256fin = {st
-> r
}
-const tail = {st
+const tail = {x, msglen, tail
var ntail
/* append first padding block */
- ntail = st.msglen % 64
- st.tail[ntail++] = 0x80
- std.slfill(st.tail[ntail:], 0)
+ ntail = msglen % 64
+ tail[ntail++] = 0x80
+ std.slfill(tail[ntail:], 0)
if 64 - ntail < 8
- step(st.x[:], st.tail[:])
- std.slfill(st.tail[:], 0)
+ step(x, tail)
+ std.slfill(tail, 0)
;;
/* append size block */
- st.tail[56] = ((st.msglen * 8) >> 56) castto(byte)
- st.tail[57] = ((st.msglen * 8) >> 48) castto(byte)
- st.tail[58] = ((st.msglen * 8) >> 40) castto(byte)
- st.tail[59] = ((st.msglen * 8) >> 32) castto(byte)
- st.tail[60] = ((st.msglen * 8) >> 24) castto(byte)
- 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.x[:], st.tail[:])
+ tail[56] = ((msglen * 8) >> 56) castto(byte)
+ tail[57] = ((msglen * 8) >> 48) castto(byte)
+ tail[58] = ((msglen * 8) >> 40) castto(byte)
+ tail[59] = ((msglen * 8) >> 32) castto(byte)
+ tail[60] = ((msglen * 8) >> 24) castto(byte)
+ tail[61] = ((msglen * 8) >> 16) castto(byte)
+ tail[62] = ((msglen * 8) >> 8) castto(byte)
+ tail[63] = ((msglen * 8) >> 0) castto(byte)
+ step(x, tail)
}
const step = {x, msg