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:
agc 2007-11-28 16:46:38 +00:00
parent a0b58b4601
commit 23c77f8d12
1 changed files with 12 additions and 11 deletions

23
dist/iscsi/src/md5.c vendored
View File

@ -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