mirror of
https://github.com/n64dev/cen64.git
synced 2024-06-23 14:33:13 -04:00
sha1: MSVC is braindead, so help it out a little.
This commit is contained in:
parent
322ac0c934
commit
ed08c028e5
|
@ -48,7 +48,7 @@
|
|||
|
||||
/* XXX: hacky */
|
||||
#ifdef _WIN32
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#define BYTE_ORDER_IS_LITTLE_ENDIAN
|
||||
|
||||
static inline bcopy(const uint8_t *src, uint8_t *dest, size_t len) {
|
||||
size_t i;
|
||||
|
@ -56,17 +56,12 @@ static inline bcopy(const uint8_t *src, uint8_t *dest, size_t len) {
|
|||
for (i = 0; i < len; i++)
|
||||
dest[i] = src[i];
|
||||
}
|
||||
#else
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#define BYTE_ORDER_IS_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
/* sanity check */
|
||||
#if BYTE_ORDER != BIG_ENDIAN
|
||||
# if BYTE_ORDER != LITTLE_ENDIAN
|
||||
# define unsupported 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef unsupported
|
||||
|
||||
/* constant table */
|
||||
static uint32_t _K[] = { 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 };
|
||||
#define K(t) _K[(t) / 20]
|
||||
|
@ -110,7 +105,7 @@ sha1_step(ctxt)
|
|||
size_t t, s;
|
||||
uint32_t tmp;
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
#ifdef BYTE_ORDER_IS_LITTLE_ENDIAN
|
||||
struct sha1_ctxt tctxt;
|
||||
bcopy(&ctxt->m.b8[0], &tctxt.m.b8[0], 64);
|
||||
ctxt->m.b8[0] = tctxt.m.b8[3]; ctxt->m.b8[1] = tctxt.m.b8[2];
|
||||
|
@ -221,7 +216,7 @@ sha1_pad(ctxt)
|
|||
memset(&ctxt->m.b8[padstart], 0, padlen - 8);
|
||||
COUNT += (padlen - 8);
|
||||
COUNT %= 64;
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#ifndef BYTE_ORDER_IS_LITTLE_ENDIAN
|
||||
PUTPAD(ctxt->c.b8[0]); PUTPAD(ctxt->c.b8[1]);
|
||||
PUTPAD(ctxt->c.b8[2]); PUTPAD(ctxt->c.b8[3]);
|
||||
PUTPAD(ctxt->c.b8[4]); PUTPAD(ctxt->c.b8[5]);
|
||||
|
@ -268,7 +263,7 @@ sha1_result(ctxt, digest)
|
|||
uint8_t *digest;
|
||||
{
|
||||
sha1_pad(ctxt);
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#ifndef BYTE_ORDER_IS_LITTLE_ENDIAN
|
||||
bcopy(&ctxt->h.b8[0], digest, 20);
|
||||
#else
|
||||
digest[0] = ctxt->h.b8[3]; digest[1] = ctxt->h.b8[2];
|
||||
|
@ -295,4 +290,3 @@ extern void sha1(data, size, digest)
|
|||
sha1_result(&ctx, digest);
|
||||
}
|
||||
|
||||
#endif /*unsupported*/
|
||||
|
|
Loading…
Reference in a new issue