From 1cd2f3eb7441f11a0e80c92fea6ec927cbb3639b Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Sat, 5 Apr 1997 22:04:15 +0000 Subject: [PATCH] (sha_finito_little_endian): byte-swap correctly. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1548 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/otp/otp_md.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/otp/otp_md.c b/lib/otp/otp_md.c index af9673a20..a04bd6315 100644 --- a/lib/otp/otp_md.c +++ b/lib/otp/otp_md.c @@ -219,16 +219,16 @@ otp_md5_next (OtpKey key) static void sha_finito_little_endian (struct sha *m, void *res) { - u_int32_t tmp[20]; + unsigned char tmp[20]; unsigned char *p = res; - int i, j; + int j; sha_finito (m, tmp); - for (i = 0, j = 0; j < 20; i++, j += 4) { - p[j] = (unsigned char)(tmp[i] & 0xff); - p[j+1] = (unsigned char)((tmp[i] >> 8) & 0xff); - p[j+2] = (unsigned char)((tmp[i] >> 16) & 0xff); - p[j+3] = (unsigned char)((tmp[i] >> 24) & 0xff); + for (j = 0; j < 20; j += 4) { + p[j] = tmp[j+3]; + p[j+1] = tmp[j+2]; + p[j+2] = tmp[j+1]; + p[j+3] = tmp[j]; } }