aboutsummaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-02-05 11:38:39 +0100
committerMattias Andrée <maandree@operamail.com>2013-02-05 11:38:39 +0100
commit6ff945f47fe5a894ac710c58de9a8350989e0fc9 (patch)
treee2c68cec56b7ea30a6d5d4d5c8d920006b557dce /c
parentmessage lenght parameter in tolane (diff)
downloadsha3sum-6ff945f47fe5a894ac710c58de9a8350989e0fc9.tar.gz
sha3sum-6ff945f47fe5a894ac710c58de9a8350989e0fc9.tar.bz2
sha3sum-6ff945f47fe5a894ac710c58de9a8350989e0fc9.tar.xz
port `M.length`
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'c')
-rw-r--r--c/sha3.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/c/sha3.c b/c/sha3.c
index 392da00..b3c06e6 100644
--- a/c/sha3.c
+++ b/c/sha3.c
@@ -112,10 +112,15 @@ static llong* S = null;
static byte* M = null;
/**
- * Polonger for {@link #M}
+ * Pointer for {@link #M}
*/
static long mptr = 0;
+/**
+ * Size of {@link #M}
+ */
+static long mlen = 0;
+
/**
@@ -373,7 +378,7 @@ extern void initialise(long r, long c, long n)
nr = 12 + (l << 1);
wmod = (1L << w) - 1L;
S = (llong*)malloc(25 * sizeof(llong));
- M = (byte*)malloc((r * b) >> 2);
+ M = (byte*)malloc(mlen = (r * b) >> 2);
mptr = 0;
}
@@ -390,8 +395,8 @@ extern void update(byte* msg, long msglen)
long ww = w >> 3;
long i;
- if (mptr + msglen > M.length)
- System.arraycopy(M, 0, M = new byte[(M.length + msglen) << 1], 0, mptr);
+ if (mptr + msglen > mlen)
+ System.arraycopy(M, 0, M = new byte[(mlen += msglen) << 1], 0, mptr);
arraycopy(msg, 0, M, mptr, msglen);
long len = mptr += msglen;
len -= len % ((r * b) >> 3);
@@ -485,8 +490,8 @@ extern byte* digest(byte* msg, long msglen)
message = pad10star1(M, mptr, r);
else
{
- if (mptr + msglen > M.length)
- System.arraycopy(M, 0, M = new byte[M.length + msglen], 0, mptr);
+ if (mptr + msglen > mlen)
+ System.arraycopy(M, 0, M = new byte[mlen += msglen], 0, mptr);
arraycopy(msg, 0, M, mptr, msglen);
message = pad10star1(M, mptr + msglen, r);
}