Codebase list ntl / 0e42bed
Remove all patches Julien Puydt 8 years ago
8 changed file(s) with 198 addition(s) and 712 deletion(s). Raw diff Collapse all Expand all
+0
-48
debian/patches/0001-gcc-4.5-mips.patch less more
0 From 25e20161828a9f83623051ddd2c048b45b2ff979 Mon Sep 17 00:00:00 2001
1 From: Aurelien Jarno <aurel32@debian.org>
2 Date: Sun, 17 Apr 2011 23:41:31 +0200
3 Subject: gcc-4.5-mips
4
5 Bug-Debian: 623162
6
7 Since GCC 4.4 it's not possible anymore to use the 'h' constraints for
8 MIPS inline assembly code when doing a multiplication. That's why sprng
9 fails to build from source on mips and mipsel.
10
11 That said GCC supports 32x32 => 64 multiplication on 32-bit architecture
12 for a lot of time, so there is no need to use assembly code for that.
13 The patch below fixes the problem by using standard multiplication
14 instead of assembly code. I have also included the code for MIPS64 using
15 128-bit hints for reference (the second hunk), though it is not used in
16 Debian.
17 ---
18 include/NTL/SPMM_ASM.h | 9 +++++----
19 1 file changed, 5 insertions(+), 4 deletions(-)
20
21 diff --git a/include/NTL/SPMM_ASM.h b/include/NTL/SPMM_ASM.h
22 index dc0bfb9..9ff7942 100644
23 --- a/include/NTL/SPMM_ASM.h
24 +++ b/include/NTL/SPMM_ASM.h
25 @@ -147,8 +147,8 @@ static inline unsigned long MulHiUL(unsigned long a, unsigned long b)
26
27 static inline unsigned long MulHiUL(unsigned long a, unsigned long b)
28 {
29 - unsigned long hi, lo;
30 - __asm__ ("multu %2,%3" : "=l" (lo), "=h" (hi) : "d" (a), "d" (b));
31 + unsigned long hi;
32 + hi = ((unsigned long long) a * b) >> 32;
33 return hi;
34 }
35
36 @@ -159,8 +159,9 @@ static inline unsigned long MulHiUL(unsigned long a, unsigned long b)
37
38 static inline unsigned long MulHiUL(unsigned long a, unsigned long b)
39 {
40 - unsigned long hi, lo;
41 - __asm__ ("dmultu %2,%3" : "=l" (lo), "=h" (hi) : "d" (a), "d" (b));
42 + typedef unsigned int uint128_t __attribute__((mode(TI)));
43 + unsigned long hi;
44 + hi = ((uint128_t) a * b) >> 64;
45 return hi;
46 }
47
+0
-77
debian/patches/0002-a-callback-for-sage.patch less more
0 From 55fce221fee2063e886e2a1c516842b0fc738053 Mon Sep 17 00:00:00 2001
1 From: Felix Salfelder <salfelder@em.cs.uni-frankfurt.de>
2 Date: Thu, 26 Jan 2012 21:34:21 +0100
3 Subject: a callback for sage
4
5 (from sage-4.7.tar/spkg/ntl/dist/debian)
6
7 We add a SetErrorCallbackFunction(). This sets a global callback function _function_,
8 which gets called with parameter _context_ and an error message string whenever Error()
9 gets called.
10
11 Note that if the custom error handler *returns*, then NTL will dump the error message
12 back to stderr and abort() as it habitually does.
13
14 -- David Harvey (2008-04-12)
15 ---
16 include/NTL/tools.h | 6 ++++++
17 src/tools.c | 27 +++++++++++++++++++++++++++
18 2 files changed, 33 insertions(+)
19
20 diff --git a/include/NTL/tools.h b/include/NTL/tools.h
21 index d79ea43..ca41173 100644
22 --- a/include/NTL/tools.h
23 +++ b/include/NTL/tools.h
24 @@ -310,6 +310,12 @@ long CharToIntVal(long c);
25 char IntValToChar(long a);
26
27
28 +/*
29 + This function is not present in vanilla NTL 5.4.2.
30 + See tools.c for documentation.
31 + */
32 +void SetErrorCallbackFunction(void (*func)(const char *s, void *context), void *context);
33 +
34
35 void Error(const char *s);
36
37 diff --git a/src/tools.c b/src/tools.c
38 index 36c956b..f05f557 100644
39 --- a/src/tools.c
40 +++ b/src/tools.c
41 @@ -18,8 +18,35 @@ NTL_START_IMPL
42 NTL_THREAD_LOCAL void (*ErrorCallback)() = 0;
43
44
45 +/*
46 + The following code differs from vanilla NTL 5.4.2.
47 +
48 + We add a SetErrorCallbackFunction(). This sets a global callback function _function_,
49 + which gets called with parameter _context_ and an error message string whenever Error()
50 + gets called.
51 +
52 + Note that if the custom error handler *returns*, then NTL will dump the error message
53 + back to stderr and abort() as it habitually does.
54 +
55 + -- David Harvey (2008-04-12)
56 +*/
57 +
58 +void (*ErrorCallbackFunction)(const char*, void*) = NULL;
59 +void *ErrorCallbackContext = NULL;
60 +
61 +
62 +void SetErrorCallbackFunction(void (*function)(const char*, void*), void *context)
63 +{
64 + ErrorCallbackFunction = function;
65 + ErrorCallbackContext = context;
66 +}
67 +
68 +
69 void Error(const char *s)
70 {
71 + if (ErrorCallbackFunction != NULL)
72 + ErrorCallbackFunction(s, ErrorCallbackContext);
73 +
74 cerr << s << "\n";
75 _ntl_abort();
76 }
+0
-402
debian/patches/0003-replace-md5-implementation.patch less more
0 From a30639584ce76b2b2aa6b237a61d31744fd3f748 Mon Sep 17 00:00:00 2001
1 From: "Bernhard R. Link" <brlink@debian.org>
2 Date: Sat, 11 Feb 2012 10:35:46 +0100
3 Subject: replace md5 implementation
4
5 Replace RSA's md5 implementation with a public domain one to
6 get rid of the advertisement clause.
7 ---
8 src/ZZ.c | 316 +++++++++++++++++++++++++++------------------------------------
9 1 file changed, 133 insertions(+), 183 deletions(-)
10
11 diff --git a/src/ZZ.c b/src/ZZ.c
12 index 054259b..4af7952 100644
13 --- a/src/ZZ.c
14 +++ b/src/ZZ.c
15 @@ -1331,207 +1331,157 @@ long power_long(long a, long e)
16 // which I've modified to work on 64-bit machines
17
18
19 +#ifndef uint32
20 +# if NTL_BITS_PER_INT == 32
21 +typedef unsigned int uint32;
22 +# elif NTL_BITS_PER_LONG == 32
23 +typedef unsigned long uint32;
24 +# else
25 +# error unable to find 32 bit type
26 +# endif
27 +#endif
28 /*
29 - * BEGIN RSA's md5 stuff
30 + * BEGIN md5 stuff
31 *
32 */
33
34 /*
35 - **********************************************************************
36 - ** md5.c **
37 - ** RSA Data Security, Inc. MD5 Message Digest Algorithm **
38 - ** Created: 2/17/90 RLR **
39 - ** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version **
40 - **********************************************************************
41 + * This code implements the MD5 message-digest algorithm.
42 + * The algorithm is due to Ron Rivest. This code was
43 + * written by Colin Plumb in 1993, no copyright is claimed.
44 + * This code is in the public domain; do with it what you wish.
45 + *
46 + * Equivalent code is available from RSA Data Security, Inc.
47 + * This code has been tested against that, and is equivalent,
48 + * except that you don't need to include two pages of legalese
49 + * with every copy.
50 + *
51 + Modified to only contain the functions needed here.
52 */
53
54 /*
55 - **********************************************************************
56 - ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
57 - ** **
58 - ** License to copy and use this software is granted provided that **
59 - ** it is identified as the "RSA Data Security, Inc. MD5 Message **
60 - ** Digest Algorithm" in all material mentioning or referencing this **
61 - ** software or this function. **
62 - ** **
63 - ** License is also granted to make and use derivative works **
64 - ** provided that such works are identified as "derived from the RSA **
65 - ** Data Security, Inc. MD5 Message Digest Algorithm" in all **
66 - ** material mentioning or referencing the derived work. **
67 - ** **
68 - ** RSA Data Security, Inc. makes no representations concerning **
69 - ** either the merchantability of this software or the suitability **
70 - ** of this software for any particular purpose. It is provided "as **
71 - ** is" without express or implied warranty of any kind. **
72 - ** **
73 - ** These notices must be retained in any copies of any part of this **
74 - ** documentation and/or software. **
75 - **********************************************************************
76 + * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
77 + * initialization constants.
78 */
79 -
80 -
81 -#if (NTL_BITS_PER_LONG <= 32)
82 -#define TRUNC32(x) (x)
83 -#else
84 -#define TRUNC32(x) ((x) & ((1UL << 32)-1UL))
85 -#endif
86 -
87 -/* F, G and H are basic MD5 functions: selection, majority, parity */
88 -#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
89 -#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
90 -#define H(x, y, z) ((x) ^ (y) ^ (z))
91 -#define I(x, y, z) (TRUNC32((y) ^ ((x) | (~z))))
92 -
93 -/* ROTATE_LEFT rotates x left n bits */
94 -#define ROTATE_LEFT(x, n) (TRUNC32(((x) << (n)) | ((x) >> (32-(n)))))
95 -
96 -/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
97 -/* Rotation is separate from addition to prevent recomputation */
98 -#define FF(a, b, c, d, x, s, ac) \
99 - {(a) = TRUNC32((a) + F((b), (c), (d)) + (x) + (ac)); \
100 - (a) = ROTATE_LEFT((a), (s)); \
101 - (a) = TRUNC32((a) + (b)); \
102 - }
103 -#define GG(a, b, c, d, x, s, ac) \
104 - {(a) = TRUNC32((a) + G((b), (c), (d)) + (x) + (ac)); \
105 - (a) = ROTATE_LEFT((a), (s)); \
106 - (a) = TRUNC32((a) + (b)); \
107 - }
108 -#define HH(a, b, c, d, x, s, ac) \
109 - {(a) = TRUNC32((a) + H((b), (c), (d)) + (x) + (ac)); \
110 - (a) = ROTATE_LEFT((a), (s)); \
111 - (a) = TRUNC32((a) + (b)); \
112 - }
113 -#define II(a, b, c, d, x, s, ac) \
114 - {(a) = TRUNC32((a) + I((b), (c), (d)) + (x) + (ac)); \
115 - (a) = ROTATE_LEFT((a), (s)); \
116 - (a) = TRUNC32((a) + (b)); \
117 - }
118 -
119 -
120 -
121 static
122 -void MD5_default_IV(unsigned long *buf)
123 +void MD5Init(uint32 buf[4])
124 {
125 - buf[0] = 0x67452301UL;
126 - buf[1] = 0xefcdab89UL;
127 - buf[2] = 0x98badcfeUL;
128 - buf[3] = 0x10325476UL;
129 + buf[0] = 0x67452301U;
130 + buf[1] = 0xefcdab89U;
131 + buf[2] = 0x98badcfeU;
132 + buf[3] = 0x10325476U;
133 }
134
135 +/* The four core functions - F1 is optimized somewhat */
136
137 +/* #define F1(x, y, z) (x & y | ~x & z) */
138 +#define F1(x, y, z) (z ^ (x & (y ^ z)))
139 +#define F2(x, y, z) F1(z, x, y)
140 +#define F3(x, y, z) (x ^ y ^ z)
141 +#define F4(x, y, z) (y ^ (x | ~z))
142
143 -/* Basic MD5 step. Transform buf based on in.
144 - */
145 +/* This is the central step in the MD5 algorithm. */
146 +#define MD5STEP(f, w, x, y, z, data, s) \
147 + ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
148
149 +/*
150 + * The core of the MD5 algorithm, this alters an existing MD5 hash to
151 + * reflect the addition of 16 longwords of new data. MD5Update blocks
152 + * the data and converts bytes into longwords for this routine.
153 + */
154 static
155 -void MD5_compress(unsigned long *buf, unsigned long *in)
156 -{
157 - unsigned long a = buf[0], b = buf[1], c = buf[2], d = buf[3];
158 -
159 - /* Round 1 */
160 -#define S11 7
161 -#define S12 12
162 -#define S13 17
163 -#define S14 22
164 - FF ( a, b, c, d, in[ 0], S11, 3614090360UL); /* 1 */
165 - FF ( d, a, b, c, in[ 1], S12, 3905402710UL); /* 2 */
166 - FF ( c, d, a, b, in[ 2], S13, 606105819UL); /* 3 */
167 - FF ( b, c, d, a, in[ 3], S14, 3250441966UL); /* 4 */
168 - FF ( a, b, c, d, in[ 4], S11, 4118548399UL); /* 5 */
169 - FF ( d, a, b, c, in[ 5], S12, 1200080426UL); /* 6 */
170 - FF ( c, d, a, b, in[ 6], S13, 2821735955UL); /* 7 */
171 - FF ( b, c, d, a, in[ 7], S14, 4249261313UL); /* 8 */
172 - FF ( a, b, c, d, in[ 8], S11, 1770035416UL); /* 9 */
173 - FF ( d, a, b, c, in[ 9], S12, 2336552879UL); /* 10 */
174 - FF ( c, d, a, b, in[10], S13, 4294925233UL); /* 11 */
175 - FF ( b, c, d, a, in[11], S14, 2304563134UL); /* 12 */
176 - FF ( a, b, c, d, in[12], S11, 1804603682UL); /* 13 */
177 - FF ( d, a, b, c, in[13], S12, 4254626195UL); /* 14 */
178 - FF ( c, d, a, b, in[14], S13, 2792965006UL); /* 15 */
179 - FF ( b, c, d, a, in[15], S14, 1236535329UL); /* 16 */
180 -
181 - /* Round 2 */
182 -#define S21 5
183 -#define S22 9
184 -#define S23 14
185 -#define S24 20
186 - GG ( a, b, c, d, in[ 1], S21, 4129170786UL); /* 17 */
187 - GG ( d, a, b, c, in[ 6], S22, 3225465664UL); /* 18 */
188 - GG ( c, d, a, b, in[11], S23, 643717713UL); /* 19 */
189 - GG ( b, c, d, a, in[ 0], S24, 3921069994UL); /* 20 */
190 - GG ( a, b, c, d, in[ 5], S21, 3593408605UL); /* 21 */
191 - GG ( d, a, b, c, in[10], S22, 38016083UL); /* 22 */
192 - GG ( c, d, a, b, in[15], S23, 3634488961UL); /* 23 */
193 - GG ( b, c, d, a, in[ 4], S24, 3889429448UL); /* 24 */
194 - GG ( a, b, c, d, in[ 9], S21, 568446438UL); /* 25 */
195 - GG ( d, a, b, c, in[14], S22, 3275163606UL); /* 26 */
196 - GG ( c, d, a, b, in[ 3], S23, 4107603335UL); /* 27 */
197 - GG ( b, c, d, a, in[ 8], S24, 1163531501UL); /* 28 */
198 - GG ( a, b, c, d, in[13], S21, 2850285829UL); /* 29 */
199 - GG ( d, a, b, c, in[ 2], S22, 4243563512UL); /* 30 */
200 - GG ( c, d, a, b, in[ 7], S23, 1735328473UL); /* 31 */
201 - GG ( b, c, d, a, in[12], S24, 2368359562UL); /* 32 */
202 -
203 - /* Round 3 */
204 -#define S31 4
205 -#define S32 11
206 -#define S33 16
207 -#define S34 23
208 - HH ( a, b, c, d, in[ 5], S31, 4294588738UL); /* 33 */
209 - HH ( d, a, b, c, in[ 8], S32, 2272392833UL); /* 34 */
210 - HH ( c, d, a, b, in[11], S33, 1839030562UL); /* 35 */
211 - HH ( b, c, d, a, in[14], S34, 4259657740UL); /* 36 */
212 - HH ( a, b, c, d, in[ 1], S31, 2763975236UL); /* 37 */
213 - HH ( d, a, b, c, in[ 4], S32, 1272893353UL); /* 38 */
214 - HH ( c, d, a, b, in[ 7], S33, 4139469664UL); /* 39 */
215 - HH ( b, c, d, a, in[10], S34, 3200236656UL); /* 40 */
216 - HH ( a, b, c, d, in[13], S31, 681279174UL); /* 41 */
217 - HH ( d, a, b, c, in[ 0], S32, 3936430074UL); /* 42 */
218 - HH ( c, d, a, b, in[ 3], S33, 3572445317UL); /* 43 */
219 - HH ( b, c, d, a, in[ 6], S34, 76029189UL); /* 44 */
220 - HH ( a, b, c, d, in[ 9], S31, 3654602809UL); /* 45 */
221 - HH ( d, a, b, c, in[12], S32, 3873151461UL); /* 46 */
222 - HH ( c, d, a, b, in[15], S33, 530742520UL); /* 47 */
223 - HH ( b, c, d, a, in[ 2], S34, 3299628645UL); /* 48 */
224 -
225 - /* Round 4 */
226 -#define S41 6
227 -#define S42 10
228 -#define S43 15
229 -#define S44 21
230 - II ( a, b, c, d, in[ 0], S41, 4096336452UL); /* 49 */
231 - II ( d, a, b, c, in[ 7], S42, 1126891415UL); /* 50 */
232 - II ( c, d, a, b, in[14], S43, 2878612391UL); /* 51 */
233 - II ( b, c, d, a, in[ 5], S44, 4237533241UL); /* 52 */
234 - II ( a, b, c, d, in[12], S41, 1700485571UL); /* 53 */
235 - II ( d, a, b, c, in[ 3], S42, 2399980690UL); /* 54 */
236 - II ( c, d, a, b, in[10], S43, 4293915773UL); /* 55 */
237 - II ( b, c, d, a, in[ 1], S44, 2240044497UL); /* 56 */
238 - II ( a, b, c, d, in[ 8], S41, 1873313359UL); /* 57 */
239 - II ( d, a, b, c, in[15], S42, 4264355552UL); /* 58 */
240 - II ( c, d, a, b, in[ 6], S43, 2734768916UL); /* 59 */
241 - II ( b, c, d, a, in[13], S44, 1309151649UL); /* 60 */
242 - II ( a, b, c, d, in[ 4], S41, 4149444226UL); /* 61 */
243 - II ( d, a, b, c, in[11], S42, 3174756917UL); /* 62 */
244 - II ( c, d, a, b, in[ 2], S43, 718787259UL); /* 63 */
245 - II ( b, c, d, a, in[ 9], S44, 3951481745UL); /* 64 */
246 -
247 - buf[0] = TRUNC32(buf[0] + a);
248 - buf[1] = TRUNC32(buf[1] + b);
249 - buf[2] = TRUNC32(buf[2] + c);
250 - buf[3] = TRUNC32(buf[3] + d);
251 +void MD5Transform(uint32 buf[4], uint32 const in[16])
252 +{
253 + register uint32 a, b, c, d;
254 +
255 + a = buf[0];
256 + b = buf[1];
257 + c = buf[2];
258 + d = buf[3];
259 +
260 + MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478U, 7);
261 + MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756U, 12);
262 + MD5STEP(F1, c, d, a, b, in[2] + 0x242070dbU, 17);
263 + MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceeeU, 22);
264 + MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0fafU, 7);
265 + MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62aU, 12);
266 + MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613U, 17);
267 + MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501U, 22);
268 + MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8U, 7);
269 + MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7afU, 12);
270 + MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1U, 17);
271 + MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7beU, 22);
272 + MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122U, 7);
273 + MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193U, 12);
274 + MD5STEP(F1, c, d, a, b, in[14] + 0xa679438eU, 17);
275 + MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821U, 22);
276 +
277 + MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562U, 5);
278 + MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340U, 9);
279 + MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51U, 14);
280 + MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aaU, 20);
281 + MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105dU, 5);
282 + MD5STEP(F2, d, a, b, c, in[10] + 0x02441453U, 9);
283 + MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
284 + MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8U, 20);
285 + MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6U, 5);
286 + MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6U, 9);
287 + MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87U, 14);
288 + MD5STEP(F2, b, c, d, a, in[8] + 0x455a14edU, 20);
289 + MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905U, 5);
290 + MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8U, 9);
291 + MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9U, 14);
292 + MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8aU, 20);
293 +
294 + MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942U, 4);
295 + MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681U, 11);
296 + MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122U, 16);
297 + MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380cU, 23);
298 + MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44U, 4);
299 + MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9U, 11);
300 + MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60U, 16);
301 + MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70U, 23);
302 + MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6U, 4);
303 + MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127faU, 11);
304 + MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085U, 16);
305 + MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05U, 23);
306 + MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039U, 4);
307 + MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5U, 11);
308 + MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8U, 16);
309 + MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665U, 23);
310 +
311 + MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244U, 6);
312 + MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97U, 10);
313 + MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7U, 15);
314 + MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039U, 21);
315 + MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3U, 6);
316 + MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92U, 10);
317 + MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47dU, 15);
318 + MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1U, 21);
319 + MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4fU, 6);
320 + MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0U, 10);
321 + MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314U, 15);
322 + MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1U, 21);
323 + MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82U, 6);
324 + MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235U, 10);
325 + MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bbU, 15);
326 + MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391U, 21);
327 +
328 + buf[0] += a;
329 + buf[1] += b;
330 + buf[2] += c;
331 + buf[3] += d;
332 }
333
334
335 /*
336 - * END RSA's md5 stuff
337 + * END md5 stuff
338 *
339 */
340
341
342 static
343 -void words_from_bytes(unsigned long *txtl, const unsigned char *txtc, long n)
344 +void words_from_bytes(uint32 *txtl, unsigned char *txtc, long n)
345 {
346 long i;
347 unsigned long v;
348 @@ -1546,7 +1496,7 @@ void words_from_bytes(unsigned long *txtl, const unsigned char *txtc, long n)
349 }
350
351 static
352 -void bytes_from_words(unsigned char *txtc, const unsigned long *txtl, long n)
353 +void bytes_from_words(unsigned char *txtc, uint32 *txtl, long n)
354 {
355 long i;
356 unsigned long v;
357 @@ -1565,9 +1515,9 @@ void bytes_from_words(unsigned char *txtc, const unsigned long *txtl, long n)
358
359
360 static
361 -void MD5_compress1(unsigned long *buf, unsigned char *in, long n)
362 +void MD5_compress1(uint32 *buf, unsigned char *in, long n)
363 {
364 - unsigned long txtl[16];
365 + uint32 txtl[16];
366 unsigned char txtc[64];
367 long i, j, k;
368
369 @@ -1582,7 +1532,7 @@ void MD5_compress1(unsigned long *buf, unsigned char *in, long n)
370 for (; j < 64; j++)
371 txtc[j] = 0;
372 words_from_bytes(txtl, txtc, 16);
373 - MD5_compress(buf, txtl);
374 + MD5Transform(buf, txtl);
375 i += k;
376 }
377 }
378 @@ -1667,7 +1617,7 @@ void arc4(unsigned char *buffer_ptr, long buffer_len, _ZZ_arc4_key *key)
379 NTL_THREAD_LOCAL static long ran_initialized = 0;
380 NTL_THREAD_LOCAL static _ZZ_arc4_key ran_key;
381
382 -static const unsigned long default_md5_tab[16] = {
383 +static uint32 default_md5_tab[16] = {
384 744663023UL, 1011602954UL, 3163087192UL, 3383838527UL,
385 3305324122UL, 3197458079UL, 2266495600UL, 2760303563UL,
386 346234297UL, 1919920720UL, 1896169861UL, 2192176675UL,
387 @@ -1691,11 +1641,11 @@ void build_arc4_tab(unsigned char *seed_bytes, const ZZ& s)
388
389 bytes_from_words(txt + nb + 4, default_md5_tab, 16);
390
391 - unsigned long buf[4];
392 + uint32 buf[4];
393
394 - unsigned long i;
395 + uint32 i;
396 for (i = 0; i < 16; i++) {
397 - MD5_default_IV(buf);
398 + MD5Init(buf);
399 bytes_from_words(txt, &i, 1);
400
401 MD5_compress1(buf, txt, nb + 68);
+0
-3
debian/patches/series less more
0 0001-gcc-4.5-mips.patch
1 0002-a-callback-for-sage.patch
2 0003-replace-md5-implementation.patch
146146
147147 static inline unsigned long MulHiUL(unsigned long a, unsigned long b)
148148 {
149 unsigned long hi;
150 hi = ((unsigned long long) a * b) >> 32;
149 unsigned long hi, lo;
150 __asm__ ("multu %2,%3" : "=l" (lo), "=h" (hi) : "d" (a), "d" (b));
151151 return hi;
152152 }
153153
158158
159159 static inline unsigned long MulHiUL(unsigned long a, unsigned long b)
160160 {
161 typedef unsigned int uint128_t __attribute__((mode(TI)));
162 unsigned long hi;
163 hi = ((uint128_t) a * b) >> 64;
161 unsigned long hi, lo;
162 __asm__ ("dmultu %2,%3" : "=l" (lo), "=h" (hi) : "d" (a), "d" (b));
164163 return hi;
165164 }
166165
309309 char IntValToChar(long a);
310310
311311
312 /*
313 This function is not present in vanilla NTL 5.4.2.
314 See tools.c for documentation.
315 */
316 void SetErrorCallbackFunction(void (*func)(const char *s, void *context), void *context);
317
318312
319313 void Error(const char *s);
320314
+194
-144
src/ZZ.c less more
13301330 // which I've modified to work on 64-bit machines
13311331
13321332
1333 #ifndef uint32
1334 # if NTL_BITS_PER_INT == 32
1335 typedef unsigned int uint32;
1336 # elif NTL_BITS_PER_LONG == 32
1337 typedef unsigned long uint32;
1338 # else
1339 # error unable to find 32 bit type
1340 # endif
1341 #endif
13421333 /*
1343 * BEGIN md5 stuff
1334 * BEGIN RSA's md5 stuff
13441335 *
13451336 */
13461337
13471338 /*
1348 * This code implements the MD5 message-digest algorithm.
1349 * The algorithm is due to Ron Rivest. This code was
1350 * written by Colin Plumb in 1993, no copyright is claimed.
1351 * This code is in the public domain; do with it what you wish.
1352 *
1353 * Equivalent code is available from RSA Data Security, Inc.
1354 * This code has been tested against that, and is equivalent,
1355 * except that you don't need to include two pages of legalese
1356 * with every copy.
1357 *
1358 Modified to only contain the functions needed here.
1339 **********************************************************************
1340 ** md5.c **
1341 ** RSA Data Security, Inc. MD5 Message Digest Algorithm **
1342 ** Created: 2/17/90 RLR **
1343 ** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version **
1344 **********************************************************************
13591345 */
13601346
13611347 /*
1362 * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
1363 * initialization constants.
1348 **********************************************************************
1349 ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
1350 ** **
1351 ** License to copy and use this software is granted provided that **
1352 ** it is identified as the "RSA Data Security, Inc. MD5 Message **
1353 ** Digest Algorithm" in all material mentioning or referencing this **
1354 ** software or this function. **
1355 ** **
1356 ** License is also granted to make and use derivative works **
1357 ** provided that such works are identified as "derived from the RSA **
1358 ** Data Security, Inc. MD5 Message Digest Algorithm" in all **
1359 ** material mentioning or referencing the derived work. **
1360 ** **
1361 ** RSA Data Security, Inc. makes no representations concerning **
1362 ** either the merchantability of this software or the suitability **
1363 ** of this software for any particular purpose. It is provided "as **
1364 ** is" without express or implied warranty of any kind. **
1365 ** **
1366 ** These notices must be retained in any copies of any part of this **
1367 ** documentation and/or software. **
1368 **********************************************************************
13641369 */
1370
1371
1372 #if (NTL_BITS_PER_LONG <= 32)
1373 #define TRUNC32(x) (x)
1374 #else
1375 #define TRUNC32(x) ((x) & ((1UL << 32)-1UL))
1376 #endif
1377
1378 /* F, G and H are basic MD5 functions: selection, majority, parity */
1379 #define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
1380 #define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
1381 #define H(x, y, z) ((x) ^ (y) ^ (z))
1382 #define I(x, y, z) (TRUNC32((y) ^ ((x) | (~z))))
1383
1384 /* ROTATE_LEFT rotates x left n bits */
1385 #define ROTATE_LEFT(x, n) (TRUNC32(((x) << (n)) | ((x) >> (32-(n)))))
1386
1387 /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
1388 /* Rotation is separate from addition to prevent recomputation */
1389 #define FF(a, b, c, d, x, s, ac) \
1390 {(a) = TRUNC32((a) + F((b), (c), (d)) + (x) + (ac)); \
1391 (a) = ROTATE_LEFT((a), (s)); \
1392 (a) = TRUNC32((a) + (b)); \
1393 }
1394 #define GG(a, b, c, d, x, s, ac) \
1395 {(a) = TRUNC32((a) + G((b), (c), (d)) + (x) + (ac)); \
1396 (a) = ROTATE_LEFT((a), (s)); \
1397 (a) = TRUNC32((a) + (b)); \
1398 }
1399 #define HH(a, b, c, d, x, s, ac) \
1400 {(a) = TRUNC32((a) + H((b), (c), (d)) + (x) + (ac)); \
1401 (a) = ROTATE_LEFT((a), (s)); \
1402 (a) = TRUNC32((a) + (b)); \
1403 }
1404 #define II(a, b, c, d, x, s, ac) \
1405 {(a) = TRUNC32((a) + I((b), (c), (d)) + (x) + (ac)); \
1406 (a) = ROTATE_LEFT((a), (s)); \
1407 (a) = TRUNC32((a) + (b)); \
1408 }
1409
1410
1411
13651412 static
1366 void MD5Init(uint32 buf[4])
1367 {
1368 buf[0] = 0x67452301U;
1369 buf[1] = 0xefcdab89U;
1370 buf[2] = 0x98badcfeU;
1371 buf[3] = 0x10325476U;
1372 }
1373
1374 /* The four core functions - F1 is optimized somewhat */
1375
1376 /* #define F1(x, y, z) (x & y | ~x & z) */
1377 #define F1(x, y, z) (z ^ (x & (y ^ z)))
1378 #define F2(x, y, z) F1(z, x, y)
1379 #define F3(x, y, z) (x ^ y ^ z)
1380 #define F4(x, y, z) (y ^ (x | ~z))
1381
1382 /* This is the central step in the MD5 algorithm. */
1383 #define MD5STEP(f, w, x, y, z, data, s) \
1384 ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
1413 void MD5_default_IV(unsigned long *buf)
1414 {
1415 buf[0] = 0x67452301UL;
1416 buf[1] = 0xefcdab89UL;
1417 buf[2] = 0x98badcfeUL;
1418 buf[3] = 0x10325476UL;
1419 }
1420
1421
1422
1423 /* Basic MD5 step. Transform buf based on in.
1424 */
1425
1426 static
1427 void MD5_compress(unsigned long *buf, unsigned long *in)
1428 {
1429 unsigned long a = buf[0], b = buf[1], c = buf[2], d = buf[3];
1430
1431 /* Round 1 */
1432 #define S11 7
1433 #define S12 12
1434 #define S13 17
1435 #define S14 22
1436 FF ( a, b, c, d, in[ 0], S11, 3614090360UL); /* 1 */
1437 FF ( d, a, b, c, in[ 1], S12, 3905402710UL); /* 2 */
1438 FF ( c, d, a, b, in[ 2], S13, 606105819UL); /* 3 */
1439 FF ( b, c, d, a, in[ 3], S14, 3250441966UL); /* 4 */
1440 FF ( a, b, c, d, in[ 4], S11, 4118548399UL); /* 5 */
1441 FF ( d, a, b, c, in[ 5], S12, 1200080426UL); /* 6 */
1442 FF ( c, d, a, b, in[ 6], S13, 2821735955UL); /* 7 */
1443 FF ( b, c, d, a, in[ 7], S14, 4249261313UL); /* 8 */
1444 FF ( a, b, c, d, in[ 8], S11, 1770035416UL); /* 9 */
1445 FF ( d, a, b, c, in[ 9], S12, 2336552879UL); /* 10 */
1446 FF ( c, d, a, b, in[10], S13, 4294925233UL); /* 11 */
1447 FF ( b, c, d, a, in[11], S14, 2304563134UL); /* 12 */
1448 FF ( a, b, c, d, in[12], S11, 1804603682UL); /* 13 */
1449 FF ( d, a, b, c, in[13], S12, 4254626195UL); /* 14 */
1450 FF ( c, d, a, b, in[14], S13, 2792965006UL); /* 15 */
1451 FF ( b, c, d, a, in[15], S14, 1236535329UL); /* 16 */
1452
1453 /* Round 2 */
1454 #define S21 5
1455 #define S22 9
1456 #define S23 14
1457 #define S24 20
1458 GG ( a, b, c, d, in[ 1], S21, 4129170786UL); /* 17 */
1459 GG ( d, a, b, c, in[ 6], S22, 3225465664UL); /* 18 */
1460 GG ( c, d, a, b, in[11], S23, 643717713UL); /* 19 */
1461 GG ( b, c, d, a, in[ 0], S24, 3921069994UL); /* 20 */
1462 GG ( a, b, c, d, in[ 5], S21, 3593408605UL); /* 21 */
1463 GG ( d, a, b, c, in[10], S22, 38016083UL); /* 22 */
1464 GG ( c, d, a, b, in[15], S23, 3634488961UL); /* 23 */
1465 GG ( b, c, d, a, in[ 4], S24, 3889429448UL); /* 24 */
1466 GG ( a, b, c, d, in[ 9], S21, 568446438UL); /* 25 */
1467 GG ( d, a, b, c, in[14], S22, 3275163606UL); /* 26 */
1468 GG ( c, d, a, b, in[ 3], S23, 4107603335UL); /* 27 */
1469 GG ( b, c, d, a, in[ 8], S24, 1163531501UL); /* 28 */
1470 GG ( a, b, c, d, in[13], S21, 2850285829UL); /* 29 */
1471 GG ( d, a, b, c, in[ 2], S22, 4243563512UL); /* 30 */
1472 GG ( c, d, a, b, in[ 7], S23, 1735328473UL); /* 31 */
1473 GG ( b, c, d, a, in[12], S24, 2368359562UL); /* 32 */
1474
1475 /* Round 3 */
1476 #define S31 4
1477 #define S32 11
1478 #define S33 16
1479 #define S34 23
1480 HH ( a, b, c, d, in[ 5], S31, 4294588738UL); /* 33 */
1481 HH ( d, a, b, c, in[ 8], S32, 2272392833UL); /* 34 */
1482 HH ( c, d, a, b, in[11], S33, 1839030562UL); /* 35 */
1483 HH ( b, c, d, a, in[14], S34, 4259657740UL); /* 36 */
1484 HH ( a, b, c, d, in[ 1], S31, 2763975236UL); /* 37 */
1485 HH ( d, a, b, c, in[ 4], S32, 1272893353UL); /* 38 */
1486 HH ( c, d, a, b, in[ 7], S33, 4139469664UL); /* 39 */
1487 HH ( b, c, d, a, in[10], S34, 3200236656UL); /* 40 */
1488 HH ( a, b, c, d, in[13], S31, 681279174UL); /* 41 */
1489 HH ( d, a, b, c, in[ 0], S32, 3936430074UL); /* 42 */
1490 HH ( c, d, a, b, in[ 3], S33, 3572445317UL); /* 43 */
1491 HH ( b, c, d, a, in[ 6], S34, 76029189UL); /* 44 */
1492 HH ( a, b, c, d, in[ 9], S31, 3654602809UL); /* 45 */
1493 HH ( d, a, b, c, in[12], S32, 3873151461UL); /* 46 */
1494 HH ( c, d, a, b, in[15], S33, 530742520UL); /* 47 */
1495 HH ( b, c, d, a, in[ 2], S34, 3299628645UL); /* 48 */
1496
1497 /* Round 4 */
1498 #define S41 6
1499 #define S42 10
1500 #define S43 15
1501 #define S44 21
1502 II ( a, b, c, d, in[ 0], S41, 4096336452UL); /* 49 */
1503 II ( d, a, b, c, in[ 7], S42, 1126891415UL); /* 50 */
1504 II ( c, d, a, b, in[14], S43, 2878612391UL); /* 51 */
1505 II ( b, c, d, a, in[ 5], S44, 4237533241UL); /* 52 */
1506 II ( a, b, c, d, in[12], S41, 1700485571UL); /* 53 */
1507 II ( d, a, b, c, in[ 3], S42, 2399980690UL); /* 54 */
1508 II ( c, d, a, b, in[10], S43, 4293915773UL); /* 55 */
1509 II ( b, c, d, a, in[ 1], S44, 2240044497UL); /* 56 */
1510 II ( a, b, c, d, in[ 8], S41, 1873313359UL); /* 57 */
1511 II ( d, a, b, c, in[15], S42, 4264355552UL); /* 58 */
1512 II ( c, d, a, b, in[ 6], S43, 2734768916UL); /* 59 */
1513 II ( b, c, d, a, in[13], S44, 1309151649UL); /* 60 */
1514 II ( a, b, c, d, in[ 4], S41, 4149444226UL); /* 61 */
1515 II ( d, a, b, c, in[11], S42, 3174756917UL); /* 62 */
1516 II ( c, d, a, b, in[ 2], S43, 718787259UL); /* 63 */
1517 II ( b, c, d, a, in[ 9], S44, 3951481745UL); /* 64 */
1518
1519 buf[0] = TRUNC32(buf[0] + a);
1520 buf[1] = TRUNC32(buf[1] + b);
1521 buf[2] = TRUNC32(buf[2] + c);
1522 buf[3] = TRUNC32(buf[3] + d);
1523 }
1524
13851525
13861526 /*
1387 * The core of the MD5 algorithm, this alters an existing MD5 hash to
1388 * reflect the addition of 16 longwords of new data. MD5Update blocks
1389 * the data and converts bytes into longwords for this routine.
1390 */
1391 static
1392 void MD5Transform(uint32 buf[4], uint32 const in[16])
1393 {
1394 register uint32 a, b, c, d;
1395
1396 a = buf[0];
1397 b = buf[1];
1398 c = buf[2];
1399 d = buf[3];
1400
1401 MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478U, 7);
1402 MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756U, 12);
1403 MD5STEP(F1, c, d, a, b, in[2] + 0x242070dbU, 17);
1404 MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceeeU, 22);
1405 MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0fafU, 7);
1406 MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62aU, 12);
1407 MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613U, 17);
1408 MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501U, 22);
1409 MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8U, 7);
1410 MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7afU, 12);
1411 MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1U, 17);
1412 MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7beU, 22);
1413 MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122U, 7);
1414 MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193U, 12);
1415 MD5STEP(F1, c, d, a, b, in[14] + 0xa679438eU, 17);
1416 MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821U, 22);
1417
1418 MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562U, 5);
1419 MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340U, 9);
1420 MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51U, 14);
1421 MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aaU, 20);
1422 MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105dU, 5);
1423 MD5STEP(F2, d, a, b, c, in[10] + 0x02441453U, 9);
1424 MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
1425 MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8U, 20);
1426 MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6U, 5);
1427 MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6U, 9);
1428 MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87U, 14);
1429 MD5STEP(F2, b, c, d, a, in[8] + 0x455a14edU, 20);
1430 MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905U, 5);
1431 MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8U, 9);
1432 MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9U, 14);
1433 MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8aU, 20);
1434
1435 MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942U, 4);
1436 MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681U, 11);
1437 MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122U, 16);
1438 MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380cU, 23);
1439 MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44U, 4);
1440 MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9U, 11);
1441 MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60U, 16);
1442 MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70U, 23);
1443 MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6U, 4);
1444 MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127faU, 11);
1445 MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085U, 16);
1446 MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05U, 23);
1447 MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039U, 4);
1448 MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5U, 11);
1449 MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8U, 16);
1450 MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665U, 23);
1451
1452 MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244U, 6);
1453 MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97U, 10);
1454 MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7U, 15);
1455 MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039U, 21);
1456 MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3U, 6);
1457 MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92U, 10);
1458 MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47dU, 15);
1459 MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1U, 21);
1460 MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4fU, 6);
1461 MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0U, 10);
1462 MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314U, 15);
1463 MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1U, 21);
1464 MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82U, 6);
1465 MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235U, 10);
1466 MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bbU, 15);
1467 MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391U, 21);
1468
1469 buf[0] += a;
1470 buf[1] += b;
1471 buf[2] += c;
1472 buf[3] += d;
1473 }
1474
1475
1476 /*
1477 * END md5 stuff
1527 * END RSA's md5 stuff
14781528 *
14791529 */
14801530
14811531
14821532 static
1483 void words_from_bytes(uint32 *txtl, unsigned char *txtc, long n)
1533 void words_from_bytes(unsigned long *txtl, const unsigned char *txtc, long n)
14841534 {
14851535 long i;
14861536 unsigned long v;
14951545 }
14961546
14971547 static
1498 void bytes_from_words(unsigned char *txtc, uint32 *txtl, long n)
1548 void bytes_from_words(unsigned char *txtc, const unsigned long *txtl, long n)
14991549 {
15001550 long i;
15011551 unsigned long v;
15141564
15151565
15161566 static
1517 void MD5_compress1(uint32 *buf, unsigned char *in, long n)
1518 {
1519 uint32 txtl[16];
1567 void MD5_compress1(unsigned long *buf, unsigned char *in, long n)
1568 {
1569 unsigned long txtl[16];
15201570 unsigned char txtc[64];
15211571 long i, j, k;
15221572
15311581 for (; j < 64; j++)
15321582 txtc[j] = 0;
15331583 words_from_bytes(txtl, txtc, 16);
1534 MD5Transform(buf, txtl);
1584 MD5_compress(buf, txtl);
15351585 i += k;
15361586 }
15371587 }
16161666 NTL_THREAD_LOCAL static long ran_initialized = 0;
16171667 NTL_THREAD_LOCAL static _ZZ_arc4_key ran_key;
16181668
1619 static uint32 default_md5_tab[16] = {
1669 static const unsigned long default_md5_tab[16] = {
16201670 744663023UL, 1011602954UL, 3163087192UL, 3383838527UL,
16211671 3305324122UL, 3197458079UL, 2266495600UL, 2760303563UL,
16221672 346234297UL, 1919920720UL, 1896169861UL, 2192176675UL,
16401690
16411691 bytes_from_words(txt + nb + 4, default_md5_tab, 16);
16421692
1643 uint32 buf[4];
1644
1645 uint32 i;
1693 unsigned long buf[4];
1694
1695 unsigned long i;
16461696 for (i = 0; i < 16; i++) {
1647 MD5Init(buf);
1697 MD5_default_IV(buf);
16481698 bytes_from_words(txt, &i, 1);
16491699
16501700 MD5_compress1(buf, txt, nb + 68);
1717 NTL_THREAD_LOCAL void (*ErrorCallback)() = 0;
1818
1919
20 /*
21 The following code differs from vanilla NTL 5.4.2.
22
23 We add a SetErrorCallbackFunction(). This sets a global callback function _function_,
24 which gets called with parameter _context_ and an error message string whenever Error()
25 gets called.
26
27 Note that if the custom error handler *returns*, then NTL will dump the error message
28 back to stderr and abort() as it habitually does.
29
30 -- David Harvey (2008-04-12)
31 */
32
33 void (*ErrorCallbackFunction)(const char*, void*) = NULL;
34 void *ErrorCallbackContext = NULL;
35
36
37 void SetErrorCallbackFunction(void (*function)(const char*, void*), void *context)
38 {
39 ErrorCallbackFunction = function;
40 ErrorCallbackContext = context;
41 }
42
43
4420 void Error(const char *s)
4521 {
46 if (ErrorCallbackFunction != NULL)
47 ErrorCallbackFunction(s, ErrorCallbackContext);
48
4922 cerr << s << "\n";
5023 _ntl_abort();
5124 }