Skip to content
Permalink
Browse files

Fix: crash when running in 64-bit

  • Loading branch information
hboon committed Feb 4, 2015
1 parent 5fdb3b1 commit 34f0f9844c4504336b73e314f1202648a85af33b
Showing with 8 additions and 7 deletions.
  1. +5 −5 Crytpo/sha1.c
  2. +3 −2 Crytpo/sha1.h
@@ -23,7 +23,7 @@ A million repetitions of "a"

#include "sha1.h"

void SHA1Transform(unsigned long state[5], unsigned char buffer[64]);
void SHA1Transform(uint32_t state[5], unsigned char buffer[64]);

#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))

@@ -48,12 +48,12 @@ void SHA1Transform(unsigned long state[5], unsigned char buffer[64]);

/* 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
@@ -141,7 +141,7 @@ unsigned int i, j;

void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
{
unsigned long i, j;
uint32_t i, j;
unsigned char finalcount[8];

for (i = 0; i < 8; i++) {
@@ -1,9 +1,10 @@
#include <stdint.h>

// From http://www.mirrors.wiretapped.net/security/cryptography/hashes/sha1/sha1.c

typedef struct {
unsigned long state[5];
unsigned long count[2];
uint32_t state[5];
uint32_t count[2];
unsigned char buffer[64];
} SHA1_CTX;

0 comments on commit 34f0f98

Please sign in to comment.
You can’t perform that action at this time.