Author: anthm Date: Tue Nov 14 19:15:38 2006 New Revision: 3374 Modified: freeswitch/trunk/libs/libdingaling/.update freeswitch/trunk/libs/libdingaling/src/libdingaling.c freeswitch/trunk/libs/libdingaling/src/sha1.c freeswitch/trunk/libs/libdingaling/src/sha1.h Log: inherited 64bit bug curses to unsigned long Modified: freeswitch/trunk/libs/libdingaling/.update ============================================================================== --- freeswitch/trunk/libs/libdingaling/.update (original) +++ freeswitch/trunk/libs/libdingaling/.update Tue Nov 14 19:15:38 2006 @@ -1 +1 @@ -Tue Oct 24 13:51:01 CDT 2006 +Tue Nov 14 19:14:29 EST 2006 Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.c ============================================================================== --- freeswitch/trunk/libs/libdingaling/src/libdingaling.c (original) +++ freeswitch/trunk/libs/libdingaling/src/libdingaling.c Tue Nov 14 19:15:38 2006 @@ -973,7 +973,7 @@ sha_context_t sha; char *p; int x; - unsigned char digest[20]; + unsigned char digest[20] = ""; SHA1Init(&sha); @@ -995,9 +995,10 @@ switch (type) { case IKS_NODE_START: if (handle->state == CS_NEW) { - char secret[256]; - char hash[256]; - char handshake[512]; + char secret[256] = ""; + char hash[256] = ""; + char handshake[512] = ""; + snprintf(secret, sizeof(secret), "%s%s", pak->id, handle->password); sha1_hash(hash, secret); snprintf(handshake, sizeof(handshake), "<handshake>%s</handshake>", hash); Modified: freeswitch/trunk/libs/libdingaling/src/sha1.c ============================================================================== --- freeswitch/trunk/libs/libdingaling/src/sha1.c (original) +++ freeswitch/trunk/libs/libdingaling/src/sha1.c Tue Nov 14 19:15:38 2006 @@ -92,12 +92,12 @@ /* Hash a single 512-bit block. This is the core of the algorithm. */ -void SHA1Transform(unsigned long state[5], unsigned char buffer[64]) +void SHA1Transform(uint32_t state[5], unsigned char buffer[64]) { -unsigned long a, b, c, d, e; +uint32_t a, b, c, d, e; typedef union { unsigned char c[64]; - unsigned long l[16]; + uint32_t l[16]; } CHAR64LONG16; CHAR64LONG16* block; #ifdef SHA1HANDSOFF @@ -161,9 +161,9 @@ /* Run your data through this. */ -void SHA1Update(sha_context_t* context, unsigned char* data, unsigned int len) +void SHA1Update(sha_context_t* context, unsigned char* data, uint32_t len) { -unsigned int i, j; +uint32_t i, j; j = (context->count[0] >> 3) & 63; if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++; @@ -185,7 +185,7 @@ void SHA1Final(unsigned char digest[20], sha_context_t* context) { -unsigned long i, j; +uint32_t i, j; unsigned char finalcount[8]; for (i = 0; i < 8; i++) { Modified: freeswitch/trunk/libs/libdingaling/src/sha1.h ============================================================================== --- freeswitch/trunk/libs/libdingaling/src/sha1.h (original) +++ freeswitch/trunk/libs/libdingaling/src/sha1.h Tue Nov 14 19:15:38 2006 @@ -41,15 +41,40 @@ } #endif +#undef inline +#define inline __inline + +#ifndef uint32_t +#ifdef WIN32 +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned long in_addr_t; +#else +#include <limits.h> +#include <inttypes.h> +#include <sys/types.h> +#include <inttypes.h> +#include <unistd.h> +#include <stdlib.h> +#include <time.h> +#endif +#endif + typedef struct { - unsigned long state[5]; - unsigned long count[2]; + uint32_t state[5]; + uint32_t count[2]; unsigned char buffer[64]; } sha_context_t; -void SHA1Transform(unsigned long state[5], unsigned char buffer[64]); +void SHA1Transform(uint32_t state[5], unsigned char buffer[64]); void SHA1Init(sha_context_t* context); -void SHA1Update(sha_context_t* context, unsigned char* data, unsigned int len); +void SHA1Update(sha_context_t* context, unsigned char* data, uint32_t len); void SHA1Final(unsigned char digest[20], sha_context_t* context); #ifdef __cplusplus