mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
sha1.c: use standard uint32_t.
This commit is contained in:
parent
1d6eb701d8
commit
1b25757f41
14
src/sha1.c
14
src/sha1.c
@ -23,7 +23,7 @@ A million repetitions of "a"
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h> /* for u_int*_t */
|
#include <stdint.h>
|
||||||
#include "solarisfixes.h"
|
#include "solarisfixes.h"
|
||||||
#include "sha1.h"
|
#include "sha1.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -53,12 +53,12 @@ A million repetitions of "a"
|
|||||||
|
|
||||||
/* Hash a single 512-bit block. This is the core of the algorithm. */
|
/* Hash a single 512-bit block. This is the core of the algorithm. */
|
||||||
|
|
||||||
void SHA1Transform(u_int32_t state[5], const unsigned char buffer[64])
|
void SHA1Transform(uint32_t state[5], const unsigned char buffer[64])
|
||||||
{
|
{
|
||||||
u_int32_t a, b, c, d, e;
|
uint32_t a, b, c, d, e;
|
||||||
typedef union {
|
typedef union {
|
||||||
unsigned char c[64];
|
unsigned char c[64];
|
||||||
u_int32_t l[16];
|
uint32_t l[16];
|
||||||
} CHAR64LONG16;
|
} CHAR64LONG16;
|
||||||
#ifdef SHA1HANDSOFF
|
#ifdef SHA1HANDSOFF
|
||||||
CHAR64LONG16 block[1]; /* use array to appear as a pointer */
|
CHAR64LONG16 block[1]; /* use array to appear as a pointer */
|
||||||
@ -128,9 +128,9 @@ void SHA1Init(SHA1_CTX* context)
|
|||||||
|
|
||||||
/* Run your data through this. */
|
/* Run your data through this. */
|
||||||
|
|
||||||
void SHA1Update(SHA1_CTX* context, const unsigned char* data, u_int32_t len)
|
void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len)
|
||||||
{
|
{
|
||||||
u_int32_t i, j;
|
uint32_t i, j;
|
||||||
|
|
||||||
j = context->count[0];
|
j = context->count[0];
|
||||||
if ((context->count[0] += len << 3) < j)
|
if ((context->count[0] += len << 3) < j)
|
||||||
@ -168,7 +168,7 @@ void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
|
|||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
u_int32_t t = context->count[i];
|
uint32_t t = context->count[i];
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
for (j = 0; j < 4; t >>= 8, j++)
|
for (j = 0; j < 4; t >>= 8, j++)
|
||||||
|
@ -8,14 +8,14 @@ By Steve Reid <steve@edmweb.com>
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u_int32_t state[5];
|
uint32_t state[5];
|
||||||
u_int32_t count[2];
|
uint32_t count[2];
|
||||||
unsigned char buffer[64];
|
unsigned char buffer[64];
|
||||||
} SHA1_CTX;
|
} SHA1_CTX;
|
||||||
|
|
||||||
void SHA1Transform(u_int32_t state[5], const unsigned char buffer[64]);
|
void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
|
||||||
void SHA1Init(SHA1_CTX* context);
|
void SHA1Init(SHA1_CTX* context);
|
||||||
void SHA1Update(SHA1_CTX* context, const unsigned char* data, u_int32_t len);
|
void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len);
|
||||||
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
|
void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
|
||||||
|
|
||||||
#ifdef REDIS_TEST
|
#ifdef REDIS_TEST
|
||||||
|
Loading…
x
Reference in New Issue
Block a user