Browse code

fixes uac_auth on max os x

Raphael Coeffic authored on 02/09/2010 09:41:38
Showing 5 changed files
... ...
@@ -1,10 +1,10 @@
1 1
 COREPATH =../..
2 2
 plug_in_name = uac_auth
3 3
 
4
-module_extra_objs = md5.o
4
+#module_extra_objs = md5.o
5 5
 
6
-extra_depends = md5.d
7
-extra_clean = clean_md5
6
+#extra_depends = md5.d
7
+#extra_clean = clean_md5
8 8
 
9 9
 module_ldflags = 
10 10
 module_cflags  = 
... ...
@@ -14,14 +14,14 @@ ifeq ($(OS),solaris)
14 14
 	module_cflags += -shared
15 15
 endif
16 16
 
17
-%.o : %.c %.d
18
-	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
17
+#%.o : %.c %.d
18
+#	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
19 19
 
20
-%.d : %.c %.h Makefile
21
-	$(CC) -MM $< $(CFLAGS) $(CPPFLAGS) > $@
20
+#%.d : %.c %.h Makefile
21
+#	$(CC) -MM $< $(CFLAGS) $(CPPFLAGS) > $@
22 22
 
23
-.PHONY: clean_md5
24
-clean_md5:
25
-	rm -f md5.o md5.d
23
+#.PHONY: clean_md5
24
+#clean_md5:
25
+#	rm -f md5.o md5.d
26 26
 
27 27
 include ../Makefile.app_module 
... ...
@@ -35,6 +35,11 @@
35 35
 #include <cctype>
36 36
 #include <algorithm>
37 37
 
38
+#include "md5.h"
39
+
40
+using std::string;
41
+
42
+
38 43
 #define MOD_NAME "uac_auth"
39 44
 
40 45
 EXPORT_SESSION_EVENT_HANDLER_FACTORY(UACAuthFactory, MOD_NAME);
... ...
@@ -209,23 +214,6 @@ bool UACAuth::onSendReply(const AmSipRequest& req,
209 214
   return false;
210 215
 }
211 216
 
212
-
213
-
214
-#include "md5global.h"
215
-
216
-typedef struct {
217
-  UINT4 state[4];                                   /* state (ABCD) */
218
-  UINT4 count[2];        /* number of bits, modulo 2^64 (lsb first) */
219
-  unsigned char buffer[64];                         /* input buffer */
220
-} MD5_CTX;
221
-
222
-extern "C" void MD5Init  (MD5_CTX * ctx);
223
-extern "C" void MD5Update (MD5_CTX *, unsigned char *, unsigned int);
224
-extern "C" void MD5Final (unsigned char [16], MD5_CTX *);
225
-
226
-
227
-using std::string;
228
-
229 217
 void w_MD5Update(MD5_CTX *ctx, const string& s) {
230 218
   unsigned char a[255];
231 219
   if (s.length()>255) {
232 220
similarity index 85%
233 221
rename from core/plug-in/uac_auth/md5.c
234 222
rename to core/plug-in/uac_auth/md5.cpp
... ...
@@ -57,13 +57,11 @@ documentation and/or software.
57 57
 #define S43 15
58 58
 #define S44 21
59 59
 
60
-static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64]));
61
-static void Encode PROTO_LIST
62
-  ((unsigned char *, UINT4 *, unsigned int));
63
-static void Decode PROTO_LIST
64
-  ((UINT4 *, unsigned char *, unsigned int));
65
-static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int));
66
-static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int));
60
+static void MD5Transform(UINT4 [4], unsigned char [64]);
61
+static void Encode(unsigned char *, UINT4 *, unsigned int);
62
+static void Decode(UINT4 *, unsigned char *, unsigned int);
63
+static void MD5_memcpy(POINTER, POINTER, unsigned int);
64
+static void MD5_memset(POINTER, int, unsigned int);
67 65
 
68 66
 static unsigned char PADDING[64] = {
69 67
   0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
... ...
@@ -108,8 +106,7 @@ Rotation is separate from addition to prevent recomputation.
108 106
 
109 107
 /* MD5 initialization. Begins an MD5 operation, writing a new context.
110 108
  */
111
-void MD5Init (context)
112
-MD5_CTX *context;                                        /* context */
109
+void MD5Init (MD5_CTX *context)
113 110
 {
114 111
   context->count[0] = context->count[1] = 0;
115 112
   /* Load magic initialization constants.
... ...
@@ -124,10 +121,10 @@ MD5_CTX *context;                                        /* context */
124 121
   operation, processing another message block, and updating the
125 122
   context.
126 123
  */
127
-void MD5Update (context, input, inputLen)
128
-MD5_CTX *context;                                        /* context */
129
-unsigned char *input;                                /* input block */
130
-unsigned int inputLen;                     /* length of input block */
124
+void MD5Update (MD5_CTX *context,                                        /* context */
125
+		unsigned char *input,                                /* input block */
126
+		unsigned int inputLen                     /* length of input block */
127
+		)
131 128
 {
132 129
   unsigned int i, index, partLen;
133 130
 
... ...
@@ -167,9 +164,7 @@ unsigned int inputLen;                     /* length of input block */
167 164
 /* MD5 finalization. Ends an MD5 message-digest operation, writing the
168 165
   the message digest and zeroizing the context.
169 166
  */
170
-void MD5Final (digest, context)
171
-unsigned char digest[16];                         /* message digest */
172
-MD5_CTX *context;                                       /* context */
167
+void MD5Final (unsigned char digest[16], MD5_CTX *context)
173 168
 {
174 169
   unsigned char bits[8];
175 170
   unsigned int index, padLen;
... ...
@@ -196,9 +191,7 @@ MD5_CTX *context;                                       /* context */
196 191
 
197 192
 /* MD5 basic transformation. Transforms state based on block.
198 193
  */
199
-static void MD5Transform (state, block)
200
-UINT4 state[4];
201
-unsigned char block[64];
194
+static void MD5Transform (UINT4 state[4], unsigned char block[64])
202 195
 {
203 196
   UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
204 197
 
... ...
@@ -289,10 +282,7 @@ unsigned char block[64];
289 282
 /* Encodes input (UINT4) into output (unsigned char). Assumes len is
290 283
   a multiple of 4.
291 284
  */
292
-static void Encode (output, input, len)
293
-unsigned char *output;
294
-UINT4 *input;
295
-unsigned int len;
285
+static void Encode (unsigned char *output, UINT4 *input, unsigned int len)
296 286
 {
297 287
   unsigned int i, j;
298 288
 
... ...
@@ -307,10 +297,7 @@ unsigned int len;
307 297
 /* Decodes input (unsigned char) into output (UINT4). Assumes len is
308 298
   a multiple of 4.
309 299
  */
310
-static void Decode (output, input, len)
311
-UINT4 *output;
312
-unsigned char *input;
313
-unsigned int len;
300
+static void Decode (UINT4 *output, unsigned char *input, unsigned int len)
314 301
 {
315 302
   unsigned int i, j;
316 303
 
... ...
@@ -322,36 +309,30 @@ unsigned int len;
322 309
 /* Note: Replace "for loop" with standard memcpy if possible.
323 310
  */
324 311
 
325
-static void MD5_memcpy (output, input, len)
326
-POINTER output;
327
-POINTER input;
328
-unsigned int len;
312
+static void MD5_memcpy (POINTER output, POINTER input, unsigned int len)
329 313
 {
330 314
 
331
-#ifndef USE_MEM
332
-  unsigned int i;
315
+// #ifndef USE_MEM
316
+//   unsigned int i;
333 317
 
334
-  for (i = 0; i < len; i++)
335
- output[i] = input[i];
336
-#else
318
+//   for (i = 0; i < len; i++)
319
+//  output[i] = input[i];
320
+// #else
337 321
   memcpy( output, input, len );
338
-#endif
322
+// #endif
339 323
 }
340 324
 
341 325
 /* Note: Replace "for loop" with standard memset if possible.
342 326
  */
343
-static void MD5_memset (output, value, len)
344
-POINTER output;
345
-int value;
346
-unsigned int len;
327
+static void MD5_memset (POINTER output, int value, unsigned int len)
347 328
 {
348 329
 
349
-#ifndef USE_MEM
350
-  unsigned int i;
351
-  for (i = 0; i < len; i++)
352
- ((char *)output)[i] = (char)value;
353
-#else
330
+// #ifndef USE_MEM
331
+//   unsigned int i;
332
+//   for (i = 0; i < len; i++)
333
+//  ((char *)output)[i] = (char)value;
334
+// #else
354 335
   memset( output, value, len );
355
-#endif
336
+// #endif
356 337
 }
357 338
 
... ...
@@ -37,9 +37,8 @@ typedef struct {
37 37
   unsigned char buffer[64];                         /* input buffer */
38 38
 } MD5_CTX;
39 39
 
40
-void MD5Init PROTO_LIST ((MD5_CTX *));
41
-void MD5Update PROTO_LIST
42
-  ((MD5_CTX *, unsigned char *, unsigned int));
43
-void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *));
40
+void MD5Init(MD5_CTX *);
41
+void MD5Update(MD5_CTX *, unsigned char *, unsigned int);
42
+void MD5Final(unsigned char [16], MD5_CTX *);
44 43
 
45 44
 #endif /* MD5_H */
... ...
@@ -11,11 +11,6 @@ The following makes PROTOTYPES default to 0 if it has not already
11 11
 #ifndef MD5GLOBAL_H
12 12
 #define MD5GLOBAL_H
13 13
 
14
-
15
-#ifndef PROTOTYPES
16
-#define PROTOTYPES 0
17
-#endif
18
-
19 14
 /* POINTER defines a generic pointer type */
20 15
 typedef unsigned char *POINTER;
21 16
 
... ...
@@ -25,14 +20,4 @@ typedef unsigned short int UINT2;
25 20
 /* UINT4 defines a four byte word */
26 21
 typedef unsigned int UINT4;
27 22
 
28
-/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
29
-If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
30
-  returns an empty list.
31
- */
32
-#if PROTOTYPES
33
-#define PROTO_LIST(list) list
34
-#else
35
-#define PROTO_LIST(list) ()
36
-#endif
37
-
38 23
 #endif /* MD5GLOBAL_H */