From a6ed8e06b8b56a9646612f0f4db5f10dd5eeca0c Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Mon, 7 Jul 1997 01:11:00 +0000 Subject: [PATCH] might also handle unaligned data to *_finito git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1991 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/des/md4.c | 13 +++++++++++++ lib/des/sha.c | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/des/md4.c b/lib/des/md4.c index 220e21819..f5630d5f1 100644 --- a/lib/des/md4.c +++ b/lib/des/md4.c @@ -246,6 +246,18 @@ md4_finito (struct md4 *m, void *res) len = swap_u_int32_t (len); memcpy (zeros + dstart, &len, sizeof(len)); md4_update (m, zeros, dstart + 8); + { + int i; + u_char *r = (u_char *)res; + + for (i = 0; i < 4; ++i) { + r[4*i] = m->counter[i] & 0xFF; + r[4*i+1] = (m->counter[i] >> 8) & 0xFF; + r[4*i+2] = (m->counter[i] >> 16) & 0xFF; + r[4*i+3] = (m->counter[i] >> 24) & 0xFF; + } + } +#if 0 { int i; u_int32_t *r = (u_int32_t *)res; @@ -253,4 +265,5 @@ md4_finito (struct md4 *m, void *res) for (i = 0; i < 4; ++i) r[i] = swap_u_int32_t (m->counter[i]); } +#endif } diff --git a/lib/des/sha.c b/lib/des/sha.c index 4bde7c05b..be41772df 100644 --- a/lib/des/sha.c +++ b/lib/des/sha.c @@ -294,6 +294,18 @@ sha_finito (struct sha *m, void *res) len = swap_u_int32_t (len); memcpy (zeros + dstart + 4, &len, sizeof(len)); sha_update (m, zeros, dstart + 8); + { + int i; + u_char *r = (u_char *)res; + + for (i = 0; i < 5; ++i) { + r[4*i] = m->counter[i] & 0xFF; + r[4*i+1] = (m->counter[i] >> 8) & 0xFF; + r[4*i+2] = (m->counter[i] >> 16) & 0xFF; + r[4*i+3] = (m->counter[i] >> 24) & 0xFF; + } + } +#if 0 { int i; u_int32_t *r = (u_int32_t *)res; @@ -301,4 +313,5 @@ sha_finito (struct sha *m, void *res) for (i = 0; i < 5; ++i) r[i] = swap_u_int32_t (m->counter[i]); } +#endif }