mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-10 16:31:44 +00:00
Fix endianness issues in unit test
This commit is contained in:
1 parent
b5355307a3
commit
88097f1829
7 files changed
+41
-73
No files matched your search
@@ -1,21 +1,19 @@
|
||||
#include "md5.h"
|
||||
#include "arch.h"
|
||||
#include "md5.h"
|
||||
|
||||
#if defined(MG_ENABLE_MD5) && MG_ENABLE_MD5
|
||||
|
||||
static void mg_byte_reverse(unsigned char *buf, unsigned longs) {
|
||||
/* Forrest: MD5 expect LITTLE_ENDIAN, swap if BIG_ENDIAN */
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
do {
|
||||
uint32_t t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
|
||||
((unsigned) buf[1] << 8 | buf[0]);
|
||||
*(uint32_t *) buf = t;
|
||||
buf += 4;
|
||||
} while (--longs);
|
||||
#else
|
||||
(void) buf;
|
||||
(void) longs;
|
||||
#endif
|
||||
if (MG_BIG_ENDIAN) {
|
||||
do {
|
||||
uint32_t t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
|
||||
((unsigned) buf[1] << 8 | buf[0]);
|
||||
*(uint32_t *) buf = t;
|
||||
buf += 4;
|
||||
} while (--longs);
|
||||
} else {
|
||||
(void) buf, (void) longs; // Little endian. Do nothing
|
||||
}
|
||||
}
|
||||
|
||||
#define F1(x, y, z) (z ^ (x & (y ^ z)))
|
||||
|
||||
Reference in new issue
Block a user