Module: sems Branch: master Commit: 2cb7cb0ab1c90f8e23811cd6d19a6b58edf412a2 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=2cb7cb0ab1c90f8e23811cd6d19a6b58edf412a2
Author: Raphael Coeffic <[email protected]> Committer: Raphael Coeffic <[email protected]> Date: Thu Sep 2 11:41:38 2010 +0200 fixes uac_auth on max os x --- core/plug-in/uac_auth/Makefile | 20 ++++---- core/plug-in/uac_auth/UACAuth.cpp | 22 ++------- core/plug-in/uac_auth/{md5.c => md5.cpp} | 75 +++++++++++------------------- core/plug-in/uac_auth/md5.h | 7 +-- core/plug-in/uac_auth/md5global.h | 15 ------ 5 files changed, 46 insertions(+), 93 deletions(-) diff --git a/core/plug-in/uac_auth/Makefile b/core/plug-in/uac_auth/Makefile index 8471244..70e0cee 100644 --- a/core/plug-in/uac_auth/Makefile +++ b/core/plug-in/uac_auth/Makefile @@ -1,10 +1,10 @@ COREPATH =../.. plug_in_name = uac_auth -module_extra_objs = md5.o +#module_extra_objs = md5.o -extra_depends = md5.d -extra_clean = clean_md5 +#extra_depends = md5.d +#extra_clean = clean_md5 module_ldflags = module_cflags = @@ -14,14 +14,14 @@ ifeq ($(OS),solaris) module_cflags += -shared endif -%.o : %.c %.d - $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ +#%.o : %.c %.d +# $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ -%.d : %.c %.h Makefile - $(CC) -MM $< $(CFLAGS) $(CPPFLAGS) > $@ +#%.d : %.c %.h Makefile +# $(CC) -MM $< $(CFLAGS) $(CPPFLAGS) > $@ -.PHONY: clean_md5 -clean_md5: - rm -f md5.o md5.d +#.PHONY: clean_md5 +#clean_md5: +# rm -f md5.o md5.d include ../Makefile.app_module diff --git a/core/plug-in/uac_auth/UACAuth.cpp b/core/plug-in/uac_auth/UACAuth.cpp index a98d55e..e059d28 100644 --- a/core/plug-in/uac_auth/UACAuth.cpp +++ b/core/plug-in/uac_auth/UACAuth.cpp @@ -35,6 +35,11 @@ #include <cctype> #include <algorithm> +#include "md5.h" + +using std::string; + + #define MOD_NAME "uac_auth" EXPORT_SESSION_EVENT_HANDLER_FACTORY(UACAuthFactory, MOD_NAME); @@ -209,23 +214,6 @@ bool UACAuth::onSendReply(const AmSipRequest& req, return false; } - - -#include "md5global.h" - -typedef struct { - UINT4 state[4]; /* state (ABCD) */ - UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ - unsigned char buffer[64]; /* input buffer */ -} MD5_CTX; - -extern "C" void MD5Init (MD5_CTX * ctx); -extern "C" void MD5Update (MD5_CTX *, unsigned char *, unsigned int); -extern "C" void MD5Final (unsigned char [16], MD5_CTX *); - - -using std::string; - void w_MD5Update(MD5_CTX *ctx, const string& s) { unsigned char a[255]; if (s.length()>255) { diff --git a/core/plug-in/uac_auth/md5.c b/core/plug-in/uac_auth/md5.cpp similarity index 85% rename from core/plug-in/uac_auth/md5.c rename to core/plug-in/uac_auth/md5.cpp index 8ebf793..e36082b 100644 --- a/core/plug-in/uac_auth/md5.c +++ b/core/plug-in/uac_auth/md5.cpp @@ -57,13 +57,11 @@ documentation and/or software. #define S43 15 #define S44 21 -static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64])); -static void Encode PROTO_LIST - ((unsigned char *, UINT4 *, unsigned int)); -static void Decode PROTO_LIST - ((UINT4 *, unsigned char *, unsigned int)); -static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int)); -static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int)); +static void MD5Transform(UINT4 [4], unsigned char [64]); +static void Encode(unsigned char *, UINT4 *, unsigned int); +static void Decode(UINT4 *, unsigned char *, unsigned int); +static void MD5_memcpy(POINTER, POINTER, unsigned int); +static void MD5_memset(POINTER, int, unsigned int); static unsigned char PADDING[64] = { 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. /* MD5 initialization. Begins an MD5 operation, writing a new context. */ -void MD5Init (context) -MD5_CTX *context; /* context */ +void MD5Init (MD5_CTX *context) { context->count[0] = context->count[1] = 0; /* Load magic initialization constants. @@ -124,10 +121,10 @@ MD5_CTX *context; /* context */ operation, processing another message block, and updating the context. */ -void MD5Update (context, input, inputLen) -MD5_CTX *context; /* context */ -unsigned char *input; /* input block */ -unsigned int inputLen; /* length of input block */ +void MD5Update (MD5_CTX *context, /* context */ + unsigned char *input, /* input block */ + unsigned int inputLen /* length of input block */ + ) { unsigned int i, index, partLen; @@ -167,9 +164,7 @@ unsigned int inputLen; /* length of input block */ /* MD5 finalization. Ends an MD5 message-digest operation, writing the the message digest and zeroizing the context. */ -void MD5Final (digest, context) -unsigned char digest[16]; /* message digest */ -MD5_CTX *context; /* context */ +void MD5Final (unsigned char digest[16], MD5_CTX *context) { unsigned char bits[8]; unsigned int index, padLen; @@ -196,9 +191,7 @@ MD5_CTX *context; /* context */ /* MD5 basic transformation. Transforms state based on block. */ -static void MD5Transform (state, block) -UINT4 state[4]; -unsigned char block[64]; +static void MD5Transform (UINT4 state[4], unsigned char block[64]) { UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; @@ -289,10 +282,7 @@ unsigned char block[64]; /* Encodes input (UINT4) into output (unsigned char). Assumes len is a multiple of 4. */ -static void Encode (output, input, len) -unsigned char *output; -UINT4 *input; -unsigned int len; +static void Encode (unsigned char *output, UINT4 *input, unsigned int len) { unsigned int i, j; @@ -307,10 +297,7 @@ unsigned int len; /* Decodes input (unsigned char) into output (UINT4). Assumes len is a multiple of 4. */ -static void Decode (output, input, len) -UINT4 *output; -unsigned char *input; -unsigned int len; +static void Decode (UINT4 *output, unsigned char *input, unsigned int len) { unsigned int i, j; @@ -322,36 +309,30 @@ unsigned int len; /* Note: Replace "for loop" with standard memcpy if possible. */ -static void MD5_memcpy (output, input, len) -POINTER output; -POINTER input; -unsigned int len; +static void MD5_memcpy (POINTER output, POINTER input, unsigned int len) { -#ifndef USE_MEM - unsigned int i; +// #ifndef USE_MEM +// unsigned int i; - for (i = 0; i < len; i++) - output[i] = input[i]; -#else +// for (i = 0; i < len; i++) +// output[i] = input[i]; +// #else memcpy( output, input, len ); -#endif +// #endif } /* Note: Replace "for loop" with standard memset if possible. */ -static void MD5_memset (output, value, len) -POINTER output; -int value; -unsigned int len; +static void MD5_memset (POINTER output, int value, unsigned int len) { -#ifndef USE_MEM - unsigned int i; - for (i = 0; i < len; i++) - ((char *)output)[i] = (char)value; -#else +// #ifndef USE_MEM +// unsigned int i; +// for (i = 0; i < len; i++) +// ((char *)output)[i] = (char)value; +// #else memset( output, value, len ); -#endif +// #endif } diff --git a/core/plug-in/uac_auth/md5.h b/core/plug-in/uac_auth/md5.h index ac53da7..eb5106d 100644 --- a/core/plug-in/uac_auth/md5.h +++ b/core/plug-in/uac_auth/md5.h @@ -37,9 +37,8 @@ typedef struct { unsigned char buffer[64]; /* input buffer */ } MD5_CTX; -void MD5Init PROTO_LIST ((MD5_CTX *)); -void MD5Update PROTO_LIST - ((MD5_CTX *, unsigned char *, unsigned int)); -void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *)); +void MD5Init(MD5_CTX *); +void MD5Update(MD5_CTX *, unsigned char *, unsigned int); +void MD5Final(unsigned char [16], MD5_CTX *); #endif /* MD5_H */ diff --git a/core/plug-in/uac_auth/md5global.h b/core/plug-in/uac_auth/md5global.h index aac0fa8..d0943cf 100644 --- a/core/plug-in/uac_auth/md5global.h +++ b/core/plug-in/uac_auth/md5global.h @@ -11,11 +11,6 @@ The following makes PROTOTYPES default to 0 if it has not already #ifndef MD5GLOBAL_H #define MD5GLOBAL_H - -#ifndef PROTOTYPES -#define PROTOTYPES 0 -#endif - /* POINTER defines a generic pointer type */ typedef unsigned char *POINTER; @@ -25,14 +20,4 @@ typedef unsigned short int UINT2; /* UINT4 defines a four byte word */ typedef unsigned int UINT4; -/* PROTO_LIST is defined depending on how PROTOTYPES is defined above. -If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it - returns an empty list. - */ -#if PROTOTYPES -#define PROTO_LIST(list) list -#else -#define PROTO_LIST(list) () -#endif - #endif /* MD5GLOBAL_H */ _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
