# error "Either SHA_0 or SHA_1 must be defined."
#endif
-#ifndef FLAT_INC
-#include "../md32_common.h"
-#else
#include "md32_common.h"
-#endif
#define INIT_DATA_h0 0x67452301UL
#define INIT_DATA_h1 0xefcdab89UL
#define INIT_DATA_h3 0x10325476UL
#define INIT_DATA_h4 0xc3d2e1f0UL
-void HASH_INIT (SHA_CTX *c)
+int HASH_INIT (SHA_CTX *c)
{
c->h0=INIT_DATA_h0;
c->h1=INIT_DATA_h1;
c->Nl=0;
c->Nh=0;
c->num=0;
+ return 1;
}
#define K_00_19 0x5a827999UL
(f)=xa+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \
(b)=ROTATE((b),30);
+#ifdef X
+#undef X
+#endif
+#ifndef MD32_XARRAY
+ /*
+ * Originally X was an array. As it's automatic it's natural
+ * to expect RISC compiler to accomodate at least part of it in
+ * the register bank, isn't it? Unfortunately not all compilers
+ * "find" this expectation reasonable:-( On order to make such
+ * compilers generate better code I replace X[] with a bunch of
+ * X0, X1, etc. See the function body below...
+ * <appro@fy.chalmers.se>
+ */
+# define X(i) XX##i
+#else
+ /*
+ * However! Some compilers (most notably HP C) get overwhelmed by
+ * that many local variables so that we have to have the way to
+ * fall down to the original behavior.
+ */
+# define X(i) XX[i]
+#endif
+
#ifndef DONT_IMPLEMENT_BLOCK_HOST_ORDER
void HASH_BLOCK_HOST_ORDER (SHA_CTX *c, const void *d, int num)
{
const SHA_LONG *W=d;
register unsigned long A,B,C,D,E,T;
-#ifdef SHA_XARRAY
- SHA_LONG X[16];
-# define X(i) X[(i)]
+#ifndef MD32_XARRAY
+ unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
+ XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
#else
- unsigned long X0, X1, X2, X3, X4, X5, X6, X7,
- X8, X9,X10,X11,X12,X13,X14,X15;
-# define X(i) X##i
+ SHA_LONG XX[16];
#endif
A=c->h0;
{
const unsigned char *data=p;
register unsigned long A,B,C,D,E,T,l;
-#ifdef SHA_XARRAY
- SHA_LONG X[16];
-# define X(i) X[(i)]
+#ifndef MD32_XARRAY
+ unsigned long XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
+ XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15;
#else
- unsigned long X0, X1, X2, X3, X4, X5, X6, X7,
- X8, X9,X10,X11,X12,X13,X14,X15;
-# define X(i) X##i
+ SHA_LONG XX[16];
#endif
A=c->h0;