Lines 30-41
Link Here
|
30 |
#include <string.h> |
30 |
#include <string.h> |
31 |
|
31 |
|
32 |
typedef struct { |
32 |
typedef struct { |
33 |
unsigned long state[5]; |
33 |
uint32_t state[5]; |
34 |
unsigned long count[2]; |
34 |
uint32_t count[2]; |
35 |
unsigned char buffer[64]; |
35 |
unsigned char buffer[64]; |
36 |
} SHA1_CTX; |
36 |
} SHA1_CTX; |
37 |
|
37 |
|
38 |
static void SHA1Transform(unsigned long state[5], unsigned char buffer[64]); |
38 |
static void SHA1Transform(uint32_t state[5], unsigned char buffer[64]); |
39 |
static void SHA1Init(SHA1_CTX* context); |
39 |
static void SHA1Init(SHA1_CTX* context); |
40 |
static void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len); |
40 |
static void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len); |
41 |
static void SHA1Final(unsigned char digest[20], SHA1_CTX* context); |
41 |
static void SHA1Final(unsigned char digest[20], SHA1_CTX* context); |
Lines 63-74
Link Here
|
63 |
|
63 |
|
64 |
/* Hash a single 512-bit block. This is the core of the algorithm. */ |
64 |
/* Hash a single 512-bit block. This is the core of the algorithm. */ |
65 |
|
65 |
|
66 |
static void SHA1Transform(unsigned long state[5], unsigned char buffer[64]) |
66 |
static void SHA1Transform(uint32_t state[5], unsigned char buffer[64]) |
67 |
{ |
67 |
{ |
68 |
unsigned long a, b, c, d, e; |
68 |
uint32_t a, b, c, d, e; |
69 |
typedef union { |
69 |
typedef union { |
70 |
unsigned char c[64]; |
70 |
unsigned char c[64]; |
71 |
unsigned long l[16]; |
71 |
uint32_t l[16]; |
72 |
} CHAR64LONG16; |
72 |
} CHAR64LONG16; |
73 |
CHAR64LONG16* block; |
73 |
CHAR64LONG16* block; |
74 |
#ifdef SHA1HANDSOFF |
74 |
#ifdef SHA1HANDSOFF |
Lines 156-162
Link Here
|
156 |
|
156 |
|
157 |
static void SHA1Final(unsigned char digest[20], SHA1_CTX* context) |
157 |
static void SHA1Final(unsigned char digest[20], SHA1_CTX* context) |
158 |
{ |
158 |
{ |
159 |
unsigned long i, j; |
159 |
uint32_t i, j; |
160 |
unsigned char finalcount[8]; |
160 |
unsigned char finalcount[8]; |
161 |
|
161 |
|
162 |
for (i = 0; i < 8; i++) { |
162 |
for (i = 0; i < 8; i++) { |