提交 1fc5fd0e authored 作者: Anthony Minessale's avatar Anthony Minessale

inherited 64bit bug curses to unsigned long

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3374 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 54e68cfe
Tue Oct 24 13:51:01 CDT 2006
Tue Nov 14 19:14:29 EST 2006
......@@ -973,7 +973,7 @@ static void sha1_hash(char *out, char *in)
sha_context_t sha;
char *p;
int x;
unsigned char digest[20];
unsigned char digest[20] = "";
SHA1Init(&sha);
......@@ -995,9 +995,10 @@ static int on_stream_component(ldl_handle_t *handle, int type, iks *node)
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);
......
......@@ -92,12 +92,12 @@ A million repetitions of "a"
/* 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 @@ void SHA1Init(sha_context_t* context)
/* 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 @@ unsigned int i, j;
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++) {
......
......@@ -41,15 +41,40 @@ extern "C" {
}
#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
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论