1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
Patch adds modifications by Andreas Kupries to HAVAL message digest library;
and switches tcltrf to use haval-1.1 subdirectory instead of haval.1996.
--- a/generic/haval.c
+++ b/generic/haval.c
@@ -28,7 +28,7 @@
*/
#include "transformInt.h"
-#include "haval.1996/haval.h"
+#include "haval-1.1/haval.h"
/*
* Generator description
@@ -204,4 +204,4 @@
* External code from here on.
*/
-#include "haval.1996/haval.c" /* THREADING: import of one constant var, read-only => safe */
+#include "haval-1.1/haval.c" /* THREADING: import of one constant var, read-only => safe */
--- a/generic/haval-1.1/havalapp.h
+++ b/generic/haval-1.1/havalapp.h
@@ -60,11 +60,19 @@
* FPTLEN define the length of a fingerprint (128, 160, 192, 224 or 256)
*/
-#include "config.h"
+/* #include "config.h" -- Sergei Golovan */
-#ifdef THIS_IS_JUST_A_DUMMY_DIRECTIVE
+/* #ifdef THIS_IS_JUST_A_DUMMY_DIRECTIVE -- Sergei Golovan */
-#undef LITTLE_ENDIAN
+/*#undef LITTLE_ENDIAN -- aku */
+
+/* aku -- use configure of Tcl-TRF */
+#ifdef WORDS_BIGENDIAN
+#undef LITTLE_ENDIAN
+#else
+#undef LITTLE_ENDIAN
+#define LITTLE_ENDIAN
+#endif
#ifndef PASS
#define PASS 3 /* 3, 4, or 5 */
@@ -75,6 +83,6 @@
#define FPTLEN 256 /* 128, 160, 192, 224 or 256 */
#endif
-#endif /* THIS_IS_JUST_A_DUMMY_DIRECTIVE */
+/* #endif -- Sergei Golovan */ /* THIS_IS_JUST_A_DUMMY_DIRECTIVE */
--- a/generic/haval-1.1/haval.c
+++ b/generic/haval-1.1/haval.c
@@ -76,21 +76,21 @@
#include <stdio.h>
#include <string.h>
-/* #include "havalapp.h" */
-#include "config.h"
+#include "havalapp.h" /* uncommented by Sergei Golovan */
+/* #include "config.h" -- Sergei Golovan */
#include "haval.h"
#define HAVAL_VERSION 1 /* current version number */
-void haval_string (char *, unsigned char *); /* hash a string */
-int haval_file (char *, unsigned char *); /* hash a file */
-void haval_stdin (void); /* hash input from stdin */
-void haval_start (haval_state *); /* initialization */
-void haval_hash (haval_state *,
- unsigned char *, unsigned int); /* updating routine */
-void haval_end (haval_state *, unsigned char *); /* finalization */
-void haval_hash_block (haval_state *); /* hash a 32-word block */
-static void haval_tailor (haval_state *); /* folding the last output */
+void haval_string _ANSI_ARGS_((char *, unsigned char *)); /* hash a string */
+int haval_file _ANSI_ARGS_((char *, unsigned char *)); /* hash a file */
+void haval_stdin _ANSI_ARGS_((void)); /* hash input from stdin */
+void haval_start _ANSI_ARGS_((haval_state *)); /* initialization */
+void haval_hash _ANSI_ARGS_((haval_state *,
+ unsigned char *, unsigned int)); /* updating routine */
+void haval_end _ANSI_ARGS_((haval_state *, unsigned char *)); /* finalization */
+void haval_hash_block _ANSI_ARGS_((haval_state *)); /* hash a 32-word block */
+static void haval_tailor _ANSI_ARGS_((haval_state *)); /* folding the last output */
static unsigned char padding[128] = { /* constants for padding */
0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -103,26 +103,30 @@
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
+/* aku, Jul 8, 1997, added () to eliminate gcc warnings:
+ * "suggest parentheses around arithmetic in operand of ^"
+ * semantics not changed!
+ */
#define f_1(x6, x5, x4, x3, x2, x1, x0) \
- ((x1) & ((x0) ^ (x4)) ^ (x2) & (x5) ^ \
- (x3) & (x6) ^ (x0))
+ (((x1) & ((x0) ^ (x4))) ^ ((x2) & (x5)) ^ \
+ ((x3) & (x6)) ^ (x0))
#define f_2(x6, x5, x4, x3, x2, x1, x0) \
- ((x2) & ((x1) & ~(x3) ^ (x4) & (x5) ^ (x6) ^ (x0)) ^ \
- (x4) & ((x1) ^ (x5)) ^ (x3) & (x5) ^ (x0))
+ (((x2) & (((x1) & ~(x3)) ^ ((x4) & (x5)) ^ (x6) ^ (x0))) ^ \
+ ((x4) & ((x1) ^ (x5))) ^ ((x3) & (x5)) ^ (x0))
#define f_3(x6, x5, x4, x3, x2, x1, x0) \
- ((x3) & ((x1) & (x2) ^ (x6) ^ (x0)) ^ \
- (x1) & (x4) ^ (x2) & (x5) ^ (x0))
+ (((x3) & (((x1) & (x2)) ^ (x6) ^ (x0))) ^ \
+ ((x1) & (x4)) ^ ((x2) & (x5)) ^ (x0))
#define f_4(x6, x5, x4, x3, x2, x1, x0) \
- ((x4) & ((x5) & ~(x2) ^ (x3) & ~(x6) ^ (x1) ^ (x6) ^ (x0)) ^ \
- (x3) & ((x1) & (x2) ^ (x5) ^ (x6)) ^ \
- (x2) & (x6) ^ (x0))
+ (((x4) & (((x5) & ~(x2)) ^ ((x3) & ~(x6)) ^ (x1) ^ (x6) ^ (x0))) ^ \
+ ((x3) & (((x1) & (x2)) ^ (x5) ^ (x6))) ^ \
+ ((x2) & (x6)) ^ (x0))
#define f_5(x6, x5, x4, x3, x2, x1, x0) \
- ((x0) & ((x1) & (x2) & (x3) ^ ~(x5)) ^ \
- (x1) & (x4) ^ (x2) & (x5) ^ (x3) & (x6))
+ (((x0) & (((x1) & (x2) & (x3)) ^ ~(x5))) ^ \
+ ((x1) & (x4)) ^ ((x2) & (x5)) ^ ((x3) & (x6)))
/*
* Permutations phi_{i,j}, i=3,4,5, j=1,...,i.
@@ -633,7 +637,9 @@
/* tailor the last output */
static void haval_tailor (haval_state *state)
{
+#if (FPTLEN != 224) && (FPTLEN != 256) /* aku, Jul 8, 1997, define temp only if necessary */
haval_word temp;
+#endif
#if FPTLEN == 128
temp = (state->fingerprint[7] & 0x000000FFL) |
--- a/generic/haval-1.1/haval.h
+++ b/generic/haval-1.1/haval.h
@@ -68,7 +68,13 @@
* For a list of changes, see the ChangeLog file.
*/
-typedef unsigned long int haval_word; /* a HAVAL word = 32 bits */
+#ifndef HAVAL_H
+#define HAVAL_H
+
+#include <tcl.h> /* to surely have _ANSI_ARGS_ */
+
+#include <stdint.h> /* for uint32_t */
+typedef uint32_t haval_word; /* a HAVAL word = 32 bits */
typedef struct {
haval_word count[2]; /* number of bits in a message */
@@ -77,13 +83,13 @@
unsigned char remainder[32*4]; /* unhashed chars (No.<128) */
} haval_state;
-void haval_string (char *, unsigned char *); /* hash a string */
-int haval_file (char *, unsigned char *); /* hash a file */
-void haval_stdin (void); /* filter -- hash input from stdin */
-void haval_start (haval_state *); /* initialization */
-void haval_hash (haval_state *, unsigned char *,
- unsigned int); /* updating routine */
-void haval_end (haval_state *, unsigned char *); /* finalization */
-void haval_hash_block (haval_state *); /* hash a 32-word block */
-
+void haval_string _ANSI_ARGS_((char *, unsigned char *)); /* hash a string */
+int haval_file _ANSI_ARGS_((char *, unsigned char *)); /* hash a file */
+void haval_stdin _ANSI_ARGS_((void)); /* filter -- hash input from stdin */
+void haval_start _ANSI_ARGS_((haval_state *)); /* initialization */
+void haval_hash _ANSI_ARGS_((haval_state *, unsigned char *,
+ unsigned int)); /* updating routine */
+void haval_end _ANSI_ARGS_((haval_state *, unsigned char *)); /* finalization */
+void haval_hash_block _ANSI_ARGS_((haval_state *)); /* hash a 32-word block */
+#endif /* HAVAL_H */
|