summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-06-03 18:29:52 -0400
committerOri Bernstein <ori@eigenstate.org>2015-08-24 22:10:06 -0700
commit22e01c4fafb7adc6a88370d5ec918a15038cd761 (patch)
tree05d88619723a0a0e381696f27915ec04175f31f8
parentb081295621b7bbd528416f900d7cb60632bc1b02 (diff)
downloadmc-22e01c4fafb7adc6a88370d5ec918a15038cd761.tar.gz
Split out sha256 tail function.
-rw-r--r--libcryptohash/sha256.myr25
1 files changed, 15 insertions, 10 deletions
diff --git a/libcryptohash/sha256.myr b/libcryptohash/sha256.myr
index 62c4bc6..bad28b4 100644
--- a/libcryptohash/sha256.myr
+++ b/libcryptohash/sha256.myr
@@ -65,6 +65,21 @@ const sha256add = {st, data
const sha256fin = {st
var r : byte[32]
+
+ tail(st)
+
+ pack(r[0:4], st.a)
+ pack(r[4:8], st.b)
+ pack(r[8:12], st.c)
+ pack(r[12:16], st.d)
+ pack(r[16:20], st.e)
+ pack(r[20:24], st.f)
+ pack(r[24:28], st.g)
+ pack(r[28:32], st.h)
+ -> r
+}
+
+const tail = {st
var ntail
/* append first padding block */
@@ -86,16 +101,6 @@ const sha256fin = {st
st.tail[62] = ((st.msglen * 8) >> 8) castto(byte)
st.tail[63] = ((st.msglen * 8) >> 0) castto(byte)
step(st, st.tail[:])
-
- pack(r[0:4], st.a)
- pack(r[4:8], st.b)
- pack(r[8:12], st.c)
- pack(r[12:16], st.d)
- pack(r[16:20], st.e)
- pack(r[20:24], st.f)
- pack(r[24:28], st.g)
- pack(r[28:32], st.h)
- -> r
}
const step = {st, msg