From 7e1b44a2e4d84f1564d6a4ac4baa43a8d189ae38 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Sun, 24 Oct 2004 23:31:20 +0000 Subject: [PATCH] Don't use unsigned long in the SHA1 code; we want 32-bit variables and unsigned long is 64 bits on 64-bit platforms. Use unsigned int or u_int32_t instead. Pointed out by Oleg Makarenko. --- linux/mppe/sha1.c | 10 +++++----- linux/mppe/sha1.h | 4 ++-- pppd/sha1.c | 10 +++++----- pppd/sha1.h | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/linux/mppe/sha1.c b/linux/mppe/sha1.c index 7e8b03c..a895c87 100644 --- a/linux/mppe/sha1.c +++ b/linux/mppe/sha1.c @@ -29,7 +29,7 @@ #include "sha1.h" -static void SHA1_Transform(unsigned long[5], const unsigned char[64]); +static void SHA1_Transform(unsigned int[5], const unsigned char[64]); #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) @@ -57,12 +57,12 @@ static void SHA1_Transform(unsigned long[5], const unsigned char[64]); /* Hash a single 512-bit block. This is the core of the algorithm. */ static void -SHA1_Transform(unsigned long state[5], const unsigned char buffer[64]) +SHA1_Transform(unsigned int state[5], const unsigned char buffer[64]) { - unsigned long a, b, c, d, e; + unsigned int a, b, c, d, e; typedef union { unsigned char c[64]; - unsigned long l[16]; + unsigned int l[16]; } CHAR64LONG16; CHAR64LONG16 *block; @@ -156,7 +156,7 @@ SHA1_Update(SHA1_CTX *context, const unsigned char *data, unsigned int len) void SHA1_Final(unsigned char digest[20], SHA1_CTX *context) { - unsigned long i, j; + unsigned int i, j; unsigned char finalcount[8]; for (i = 0; i < 8; i++) { diff --git a/linux/mppe/sha1.h b/linux/mppe/sha1.h index b23356b..451868c 100644 --- a/linux/mppe/sha1.h +++ b/linux/mppe/sha1.h @@ -4,8 +4,8 @@ #define _SHA1_H typedef struct { - unsigned long state[5]; - unsigned long count[2]; + unsigned int state[5]; + unsigned int count[2]; unsigned char buffer[64]; } SHA1_CTX; diff --git a/pppd/sha1.c b/pppd/sha1.c index b8701b4..da142f1 100644 --- a/pppd/sha1.c +++ b/pppd/sha1.c @@ -21,7 +21,7 @@ #include "sha1.h" static void -SHA1_Transform(unsigned long[5], const unsigned char[64]); +SHA1_Transform(u_int32_t[5], const unsigned char[64]); #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) @@ -42,12 +42,12 @@ SHA1_Transform(unsigned long[5], const unsigned char[64]); /* Hash a single 512-bit block. This is the core of the algorithm. */ static void -SHA1_Transform(unsigned long state[5], const unsigned char buffer[64]) +SHA1_Transform(u_int32_t state[5], const unsigned char buffer[64]) { - unsigned long a, b, c, d, e; + u_int32_t a, b, c, d, e; typedef union { unsigned char c[64]; - unsigned long l[16]; + u_int32_t l[16]; } CHAR64LONG16; CHAR64LONG16 *block; @@ -141,7 +141,7 @@ SHA1_Update(SHA1_CTX *context, const unsigned char *data, unsigned int len) void SHA1_Final(unsigned char digest[20], SHA1_CTX *context) { - unsigned long i, j; + u_int32_t i, j; unsigned char finalcount[8]; for (i = 0; i < 8; i++) { diff --git a/pppd/sha1.h b/pppd/sha1.h index f1d2661..83f64df 100644 --- a/pppd/sha1.h +++ b/pppd/sha1.h @@ -17,8 +17,8 @@ #endif typedef struct { - unsigned long state[5]; - unsigned long count[2]; + u_int32_t state[5]; + u_int32_t count[2]; unsigned char buffer[64]; } SHA1_CTX; -- 2.39.2