*/
#include <sys/types.h>
+#ifdef WIN32
+
+#ifndef BIG_ENDIAN
+#define BIG_ENDIAN 4321 /* to show byte order (taken from gcc) */
+#endif
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN 1234
+#endif
+#ifndef BYTE_ORDER
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif
+
+typedef unsigned __int64 u_int64_t;
+
+#undef __P
+#ifndef __P
+#if __STDC__
+#define __P(protos) protos
+#else
+#define __P(protos) ()
+#endif
+#endif
+
+#define bzero(b, len) (memset((b), '\0', (len)), (void) 0)
+
+#else
+#include <sys/stat.h>
#include <sys/cdefs.h>
#include <sys/time.h>
+#endif
+
#include <string.h>
struct sha1_ctxt {
union {
- u_int8_t b8[20];
- u_int32_t b32[5];
+ unsigned char b8[20];
+ unsigned int b32[5];
} h;
union {
- u_int8_t b8[8];
- u_int64_t b64[1];
+ unsigned char b8[8];
+ u_int64_t b64[1];
} c;
union {
- u_int8_t b8[64];
- u_int32_t b32[16];
+ unsigned char b8[64];
+ unsigned int b32[16];
} m;
- u_int8_t count;
+ unsigned char count;
};
/* sanity check */
#ifndef unsupported
/* constant table */
-static u_int32_t _K[] = { 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 };
+static const unsigned int _K[] =
+ { 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6 };
#define K(t) _K[(t) / 20]
#define F0(b, c, d) (((b) & (c)) | ((~(b)) & (d)))
ctxt->c.b64[0] += 8; \
if (COUNT % 64 == 0) \
sha1_step(ctxt); \
- }
+ }
#define PUTPAD(x) { \
ctxt->m.b8[(COUNT % 64)] = (x); \
COUNT %= 64; \
if (COUNT % 64 == 0) \
sha1_step(ctxt); \
- }
+ }
static void sha1_step __P((struct sha1_ctxt *));
static void
sha1_step(struct sha1_ctxt *ctxt)
{
- u_int32_t a, b, c, d, e;
+ unsigned int a, b, c, d, e, tmp;
size_t t, s;
- u_int32_t tmp;
#if BYTE_ORDER == LITTLE_ENDIAN
struct sha1_ctxt tctxt;
}
void
-sha1_loop(struct sha1_ctxt *ctxt, const u_int8_t *input, size_t len)
+sha1_loop(struct sha1_ctxt *ctxt, const unsigned char *input, size_t len)
{
size_t gaplen;
size_t gapstart;
}
void
-sha1_result(struct sha1_ctxt *ctxt, caddr_t digest0)
+sha1_result(struct sha1_ctxt *ctxt, void *digest0)
{
- u_int8_t *digest;
+ unsigned char *digest;
- digest = (u_int8_t *)digest0;
+ digest = (unsigned char *)digest0;
sha1_pad(ctxt);
#if BYTE_ORDER == BIG_ENDIAN
memcpy(digest, &ctxt->h.b8[0], 20);
sha1_init(&ctx);
sha1_loop(&ctx, d, n);
- sha1_result(&ctx, (caddr_t)md);
+ sha1_result(&ctx, (void *)md);
return md;
}
#endif /*unsupported*/
-