Do runtime detection of machine's endianness, rather than relying on a cpp
macro which was never changed. This is the QAD fix, longer term we will move to use native md5 routines if available. Should go some way to fixing authentication problems when using an initiator and target of different endianness.
This commit is contained in:
parent
a0b58b4601
commit
23c77f8d12
|
@ -26,22 +26,23 @@
|
|||
|
||||
#include "md5.h"
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
void
|
||||
static void
|
||||
byteSwap(UWORD32 *buf, uint32_t words)
|
||||
{
|
||||
md5byte *p = (md5byte *)buf;
|
||||
int indian = 1;
|
||||
|
||||
do {
|
||||
*buf++ = (UWORD32)((uint32_t)p[3] << 8 | p[2]) << 16 |
|
||||
((uint32_t)p[1] << 8 | p[0]);
|
||||
p += 4;
|
||||
} while (--words);
|
||||
if (*(char *) (void *) &indian) {
|
||||
/* little endian */
|
||||
/* nothing needed */
|
||||
} else {
|
||||
do {
|
||||
*buf++ = (UWORD32)((uint32_t)p[3] << 8 | p[2]) << 16 |
|
||||
((uint32_t)p[1] << 8 | p[0]);
|
||||
p += 4;
|
||||
} while (--words);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define byteSwap(buf,words)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
|
||||
|
|
Loading…
Reference in New Issue