[algo_sha1] fix compile break and warnings

size_t requires <sys/types.h> or <unistd.h>, <stdint.h>/<inttypes.h> is
not enough.

also use `const` consistently for the passed data.
personal/stbuehler/cleanup-build
Stefan Bühler 2017-10-01 12:35:46 +02:00 committed by Glenn Strauss
parent 46719b8925
commit f46b1b1d53
2 changed files with 4 additions and 3 deletions

View File

@ -69,7 +69,7 @@ typedef union _BYTE64QUAD16 {
} BYTE64QUAD16;
/* Hash a single 512-bit block. This is the core of the algorithm. */
void SHA1_Transform(sha1_quadbyte state[5], sha1_byte buffer[64]) {
void SHA1_Transform(sha1_quadbyte state[5], const sha1_byte buffer[64]) {
sha1_quadbyte a, b, c, d, e;
BYTE64QUAD16 src;
BYTE64QUAD16 *block;
@ -127,7 +127,7 @@ void SHA1_Init(SHA_CTX* context) {
}
/* Run your data through this. */
void SHA1_Update(SHA_CTX *context, sha1_byte *data, unsigned int len) {
void SHA1_Update(SHA_CTX *context, const sha1_byte *data, unsigned int len) {
unsigned int i, j;
j = (context->count[0] >> 3) & 63;

View File

@ -44,6 +44,7 @@ extern "C" {
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#include <sys/types.h>
/* Make sure you define these types for your architecture: */
typedef uint32_t sha1_quadbyte; /* 4 byte type */
@ -63,7 +64,7 @@ typedef struct _SHA_CTX {
#ifndef NOPROTO
void SHA1_Init(SHA_CTX *context);
void SHA1_Update(SHA_CTX *context, sha1_byte *data, unsigned int len);
void SHA1_Update(SHA_CTX *context, const sha1_byte *data, unsigned int len);
void SHA1_Final(sha1_byte digest[SHA1_DIGEST_LENGTH], SHA_CTX *context);
/*(added for lighttpd)*/
unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);