summaryrefslogtreecommitdiffstats
path: root/chksums
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-07-11 23:06:25 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-07-11 23:06:25 -0700
commit51b2bfe3706a01aec70716991e7658491982d63f (patch)
tree137d8c445b17459d67f91c843f03a1a416097136 /chksums
parent26c21f4648acb3866567bb15c961d086aeae2fa3 (diff)
downloadtxr-51b2bfe3706a01aec70716991e7658491982d63f.tar.gz
txr-51b2bfe3706a01aec70716991e7658491982d63f.tar.bz2
txr-51b2bfe3706a01aec70716991e7658491982d63f.zip
md5: bugfix: broken on big endian.
* chksums/md5.c (encode, decode): Fix these functions so they actually swap the byte order of 4 byte words on big endian. Tested on PPC64.
Diffstat (limited to 'chksums')
-rw-r--r--chksums/md5.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/chksums/md5.c b/chksums/md5.c
index b5fdb76d..11c6dd37 100644
--- a/chksums/md5.c
+++ b/chksums/md5.c
@@ -56,10 +56,10 @@ static void encode(unsigned char *output, u32_t *input, unsigned int len)
for (i = 0; i < len; i += 4) {
u32_t iw = input[i/4];
- output[i] = (iw >> 24) & 0xff;
- output[i+1] = (iw >> 16) & 0xff;
- output[i+2] = (iw >> 8) & 0xff;
- output[i+3] = iw & 0xff;
+ output[i] = iw & 0xff;
+ output[i+1] = (iw >> 8) & 0xff;
+ output[i+2] = (iw >> 16) & 0xff;
+ output[i+3] = (iw >> 24) & 0xff;
}
}
@@ -72,10 +72,10 @@ static void decode(u32_t *output, const unsigned char *input, unsigned int len)
unsigned int i;
for (i = 0; i < len; i += 4) {
- u32_t ow = convert(u32_t, input[i]) << 24;
- ow |= convert(u32_t, input[i+1]) << 16;
- ow |= convert(u32_t, input[i+2]) << 8;
- ow |= convert(u32_t, input[i+3]);
+ u32_t ow = convert(u32_t, input[i]);
+ ow |= convert(u32_t, input[i+1]) << 8;
+ ow |= convert(u32_t, input[i+2]) << 16;
+ ow |= convert(u32_t, input[i+3]) << 24;
output[i/4] = ow;
}
}