1
Patch to replace RSA MD5 code with MD5 code found in dpkg.
2
The RSA MD5 code is removed from the upstream source and patched in
4
===================================================================
5
diff -urN upstream/mediatomb-0.10.0/tombupnp/upnp/src/inc/upnp_md5.h mediatomb-0.10.0/tombupnp/upnp/src/inc/upnp_md5.h
6
--- upstream/mediatomb-0.10.0/tombupnp/upnp/src/inc/upnp_md5.h 1969-12-31 19:00:00.000000000 -0500
7
+++ mediatomb-0.10.0/tombupnp/upnp/src/inc/upnp_md5.h 2007-12-28 13:49:59.000000000 -0500
10
+ * This is the header file for the MD5 message-digest algorithm.
11
+ * The algorithm is due to Ron Rivest. This code was
12
+ * written by Colin Plumb in 1993, no copyright is claimed.
13
+ * This code is in the public domain; do with it what you wish.
15
+ * Equivalent code is available from RSA Data Security, Inc.
16
+ * This code has been tested against that, and is equivalent,
17
+ * except that you don't need to include two pages of legalese
20
+ * To compute the message digest of a chunk of bytes, declare an
21
+ * MD5Context structure, pass it to MD5Init, call MD5Update as
22
+ * needed on buffers full of bytes, and then call MD5Final, which
23
+ * will fill a supplied 16-byte array with the digest.
25
+ * Changed so as no longer to depend on Colin Plumb's `usual.h'
26
+ * header definitions; now uses stuff from dpkg's config.h
27
+ * - Ian Jackson <ian@chiark.greenend.org.uk>.
28
+ * Still in the public domain.
34
+#define md5byte unsigned char
36
+#if SIZEOF_UNSIGNED_LONG==4
37
+# define UWORD32 unsigned long
38
+#elif SIZEOF_UNSIGNED_INT==4
39
+# define UWORD32 unsigned int
41
+# error I do not know what to use for a UWORD32.
50
+void MD5Init(struct MD5Context *context);
51
+void MD5Update(struct MD5Context *context, md5byte const *buf, unsigned len);
52
+void MD5Final(unsigned char digest[16], struct MD5Context *context);
53
+void MD5Transform(UWORD32 buf[4], UWORD32 const in[16]);
56
diff -urN upstream/mediatomb-0.10.0/tombupnp/upnp/src/uuid/sysdep.c mediatomb-0.10.0/tombupnp/upnp/src/uuid/sysdep.c
57
--- upstream/mediatomb-0.10.0/tombupnp/upnp/src/uuid/sysdep.c 2007-07-12 15:13:36.000000000 -0400
58
+++ mediatomb-0.10.0/tombupnp/upnp/src/uuid/sysdep.c 2007-12-28 13:49:10.000000000 -0500
61
get_random_info( char seed[16] )
64
+ struct MD5Context c;
70
get_random_info( char seed[16] )
73
+ struct MD5Context c;
77
diff -urN upstream/mediatomb-0.10.0/tombupnp/upnp/src/uuid/upnp_md5.c mediatomb-0.10.0/tombupnp/upnp/src/uuid/upnp_md5.c
78
--- upstream/mediatomb-0.10.0/tombupnp/upnp/src/uuid/upnp_md5.c 1969-12-31 19:00:00.000000000 -0500
79
+++ mediatomb-0.10.0/tombupnp/upnp/src/uuid/upnp_md5.c 2007-12-28 13:52:16.000000000 -0500
82
+ * This code implements the MD5 message-digest algorithm.
83
+ * The algorithm is due to Ron Rivest. This code was
84
+ * written by Colin Plumb in 1993, no copyright is claimed.
85
+ * This code is in the public domain; do with it what you wish.
87
+ * Equivalent code is available from RSA Data Security, Inc.
88
+ * This code has been tested against that, and is equivalent,
89
+ * except that you don't need to include two pages of legalese
92
+ * To compute the message digest of a chunk of bytes, declare an
93
+ * MD5Context structure, pass it to MD5Init, call MD5Update as
94
+ * needed on buffers full of bytes, and then call MD5Final, which
95
+ * will fill a supplied 16-byte array with the digest.
97
+ * Changed so as no longer to depend on Colin Plumb's `usual.h' header
98
+ * definitions; now uses stuff from dpkg's config.h.
99
+ * - Ian Jackson <ian@chiark.greenend.org.uk>.
100
+ * Still in the public domain.
104
+#include <string.h> /* for memcpy() */
105
+#include <sys/types.h> /* for stupid systems */
106
+#include <netinet/in.h> /* for ntohl() */
108
+#include "upnp_md5.h"
110
+#ifdef WORDS_BIGENDIAN
112
+byteSwap(UWORD32 *buf, unsigned words)
114
+ md5byte *p = (md5byte *)buf;
117
+ *buf++ = (UWORD32)((unsigned)p[3] << 8 | p[2]) << 16 |
118
+ ((unsigned)p[1] << 8 | p[0]);
123
+#define byteSwap(buf,words)
127
+ * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
128
+ * initialization constants.
131
+MD5Init(struct MD5Context *ctx)
133
+ ctx->buf[0] = 0x67452301;
134
+ ctx->buf[1] = 0xefcdab89;
135
+ ctx->buf[2] = 0x98badcfe;
136
+ ctx->buf[3] = 0x10325476;
143
+ * Update context to reflect the concatenation of another buffer full
147
+MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len)
151
+ /* Update byte count */
154
+ if ((ctx->bytes[0] = t + len) < t)
155
+ ctx->bytes[1]++; /* Carry from low to high */
157
+ t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
159
+ memcpy((md5byte *)ctx->in + 64 - t, buf, len);
162
+ /* First chunk is an odd size */
163
+ memcpy((md5byte *)ctx->in + 64 - t, buf, t);
164
+ byteSwap(ctx->in, 16);
165
+ MD5Transform(ctx->buf, ctx->in);
169
+ /* Process data in 64-byte chunks */
170
+ while (len >= 64) {
171
+ memcpy(ctx->in, buf, 64);
172
+ byteSwap(ctx->in, 16);
173
+ MD5Transform(ctx->buf, ctx->in);
178
+ /* Handle any remaining bytes of data. */
179
+ memcpy(ctx->in, buf, len);
183
+ * Final wrapup - pad to 64-byte boundary with the bit pattern
184
+ * 1 0* (64-bit count of bits processed, MSB-first)
187
+MD5Final(md5byte digest[16], struct MD5Context *ctx)
189
+ int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
190
+ md5byte *p = (md5byte *)ctx->in + count;
192
+ /* Set the first char of padding to 0x80. There is always room. */
195
+ /* Bytes of padding needed to make 56 bytes (-8..55) */
196
+ count = 56 - 1 - count;
198
+ if (count < 0) { /* Padding forces an extra block */
199
+ memset(p, 0, count + 8);
200
+ byteSwap(ctx->in, 16);
201
+ MD5Transform(ctx->buf, ctx->in);
202
+ p = (md5byte *)ctx->in;
205
+ memset(p, 0, count);
206
+ byteSwap(ctx->in, 14);
208
+ /* Append length in bits and transform */
209
+ ctx->in[14] = ctx->bytes[0] << 3;
210
+ ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
211
+ MD5Transform(ctx->buf, ctx->in);
213
+ byteSwap(ctx->buf, 4);
214
+ memcpy(digest, ctx->buf, 16);
215
+ memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
220
+/* The four core functions - F1 is optimized somewhat */
222
+/* #define F1(x, y, z) (x & y | ~x & z) */
223
+#define F1(x, y, z) (z ^ (x & (y ^ z)))
224
+#define F2(x, y, z) F1(z, x, y)
225
+#define F3(x, y, z) (x ^ y ^ z)
226
+#define F4(x, y, z) (y ^ (x | ~z))
228
+/* This is the central step in the MD5 algorithm. */
229
+#define MD5STEP(f,w,x,y,z,in,s) \
230
+ (w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
233
+ * The core of the MD5 algorithm, this alters an existing MD5 hash to
234
+ * reflect the addition of 16 longwords of new data. MD5Update blocks
235
+ * the data and converts bytes into longwords for this routine.
238
+MD5Transform(UWORD32 buf[4], UWORD32 const in[16])
240
+ register UWORD32 a, b, c, d;
247
+ MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
248
+ MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
249
+ MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
250
+ MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
251
+ MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
252
+ MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
253
+ MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
254
+ MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
255
+ MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
256
+ MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
257
+ MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
258
+ MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
259
+ MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
260
+ MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
261
+ MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
262
+ MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
264
+ MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
265
+ MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
266
+ MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
267
+ MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
268
+ MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
269
+ MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
270
+ MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
271
+ MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
272
+ MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
273
+ MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
274
+ MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
275
+ MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
276
+ MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
277
+ MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
278
+ MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
279
+ MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
281
+ MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
282
+ MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
283
+ MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
284
+ MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
285
+ MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
286
+ MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
287
+ MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
288
+ MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
289
+ MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
290
+ MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
291
+ MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
292
+ MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
293
+ MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
294
+ MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
295
+ MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
296
+ MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
298
+ MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
299
+ MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
300
+ MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
301
+ MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
302
+ MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
303
+ MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
304
+ MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
305
+ MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
306
+ MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
307
+ MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
308
+ MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
309
+ MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
310
+ MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
311
+ MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
312
+ MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
313
+ MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
322
diff -urN upstream/mediatomb-0.10.0/tombupnp/upnp/src/uuid/upnp_uuid.c mediatomb-0.10.0/tombupnp/upnp/src/uuid/upnp_uuid.c
323
--- upstream/mediatomb-0.10.0/tombupnp/upnp/src/uuid/upnp_uuid.c 2007-07-12 15:13:36.000000000 -0400
324
+++ mediatomb-0.10.0/tombupnp/upnp/src/uuid/upnp_uuid.c 2007-12-28 13:49:12.000000000 -0500
326
int namelen /* the length of the name */
330
+ struct MD5Context c;
331
unsigned char hash[16];
332
uuid_upnp net_nsid; /* context UUID in network byte order */