Hide symbols for fcrypt.
Use libzip types for fixed sizes.
Use config.h for endianness.
diff --git a/lib/gladman-fcrypt/aes.h b/lib/gladman-fcrypt/aes.h
index 186ef80..7d62e0d 100644
--- a/lib/gladman-fcrypt/aes.h
+++ b/lib/gladman-fcrypt/aes.h
@@ -39,27 +39,18 @@
#if defined(__cplusplus)
extern "C"
{
+#if 0
+}
+#endif
#endif
/* If a table pointer is needed in the AES context, include the define */
/* #define AES_TABLE_PTR */
-/* This include is used to find 8 and 32 bit unsigned integer types */
-#include "limits.h"
+#include "config.h"
-#if UCHAR_MAX == 0xff /* an unsigned 8 bit type */
- typedef unsigned char aes_08t;
-#else
-#error Please define aes_08t as an 8-bit unsigned integer type in aes.h
-#endif
-
-#if UINT_MAX == 0xffffffff /* an unsigned 32 bit type */
- typedef unsigned int aes_32t;
-#elif ULONG_MAX == 0xffffffff
- typedef unsigned long aes_32t;
-#else
-#error Please define aes_32t as a 32-bit unsigned integer type in aes.h
-#endif
+typedef zip_uint8_t aes_08t;
+typedef zip_uint32_t aes_32t;
/* This BLOCK_SIZE is in BYTES. It can have the values 16, 24, 32 or */
/* undefined for use with aescrypt.c and aeskey.c, or 16, 20, 24, 28, */
@@ -105,7 +96,7 @@
/* otherwise aes_bad is returned. */
#if !defined(BLOCK_SIZE)
-aes_rval aes_set_block_size(unsigned int blen, aes_ctx cx[1]);
+INTERNAL aes_rval aes_set_block_size(unsigned int blen, aes_ctx cx[1]);
#endif
/* The key length (klen) is input in bytes when it is in the range */
@@ -116,14 +107,14 @@
/* and 256 bit) keys. The value aes_good is returned if the requested */
/* key size is legal, otherwise aes_bad is returned. */
-aes_rval aes_set_encrypt_key(const unsigned char in_key[],
+INTERNAL aes_rval aes_set_encrypt_key(const unsigned char in_key[],
unsigned int klen, aes_ctx cx[1]);
-aes_rval aes_encrypt_block(const unsigned char in_blk[],
+INTERNAL aes_rval aes_encrypt_block(const unsigned char in_blk[],
unsigned char out_blk[], const aes_ctx cx[1]);
-aes_rval aes_set_decrypt_key(const unsigned char in_key[],
+INTERNAL aes_rval aes_set_decrypt_key(const unsigned char in_key[],
unsigned int klen, aes_ctx cx[1]);
-aes_rval aes_decrypt_block(const unsigned char in_blk[],
+INTERNAL aes_rval aes_decrypt_block(const unsigned char in_blk[],
unsigned char out_blk[], const aes_ctx cx[1]);
#if defined(__cplusplus)
diff --git a/lib/gladman-fcrypt/aescrypt.c b/lib/gladman-fcrypt/aescrypt.c
index 4e6e771..ac7094c 100644
--- a/lib/gladman-fcrypt/aescrypt.c
+++ b/lib/gladman-fcrypt/aescrypt.c
@@ -236,7 +236,7 @@
#define fwd_lrnd(y,x,k,c) (s(y,c) = no_table(x,t_use(s,box),fwd_var,rf1,c) ^ (k)[c])
#endif
-aes_rval aes_encrypt_block(const unsigned char in_blk[], unsigned char out_blk[], const aes_ctx cx[1])
+INTERNAL aes_rval aes_encrypt_block(const unsigned char in_blk[], unsigned char out_blk[], const aes_ctx cx[1])
{ aes_32t locals(b0, b1);
const aes_32t *kp = cx->k_sch;
dec_fmvars /* declare variables for fwd_mcol() if needed */
@@ -373,7 +373,7 @@
#define inv_lrnd(y,x,k,c) (s(y,c) = no_table(x,t_use(i,box),inv_var,rf1,c) ^ (k)[c])
#endif
-aes_rval aes_decrypt_block(const unsigned char in_blk[], unsigned char out_blk[], const aes_ctx cx[1])
+INTERNAL aes_rval aes_decrypt_block(const unsigned char in_blk[], unsigned char out_blk[], const aes_ctx cx[1])
{ aes_32t locals(b0, b1);
const aes_32t *kp = cx->k_sch + nc * cx->n_rnd;
dec_imvars /* declare variables for inv_mcol() if needed */
diff --git a/lib/gladman-fcrypt/aeskey.c b/lib/gladman-fcrypt/aeskey.c
index 5bb39d4..cc002ca 100644
--- a/lib/gladman-fcrypt/aeskey.c
+++ b/lib/gladman-fcrypt/aeskey.c
@@ -52,7 +52,7 @@
#if !defined(BLOCK_SIZE)
-aes_rval aes_set_block_size(unsigned int blen, aes_ctx cx[1])
+INTERNAL aes_rval aes_set_block_size(unsigned int blen, aes_ctx cx[1])
{
#if !defined(FIXED_TABLES)
#ifdef GLOBALS
@@ -123,7 +123,7 @@
#if defined(ENCRYPTION_KEY_SCHEDULE)
-aes_rval aes_set_encrypt_key(const unsigned char in_key[], unsigned int klen, aes_ctx cx[1])
+INTERNAL aes_rval aes_set_encrypt_key(const unsigned char in_key[], unsigned int klen, aes_ctx cx[1])
{ aes_32t ss[8];
#if !defined(FIXED_TABLES)
@@ -308,7 +308,7 @@
ss[2] ^= ss[1]; k[8*(i)+10] = ss[2]; ss[3] ^= ss[2]; k[8*(i)+11] = ss[3]; \
}
-aes_rval aes_set_decrypt_key(const unsigned char in_key[], unsigned int klen, aes_ctx cx[1])
+INTERNAL aes_rval aes_set_decrypt_key(const unsigned char in_key[], unsigned int klen, aes_ctx cx[1])
{ aes_32t ss[8];
d_vars
diff --git a/lib/gladman-fcrypt/aesopt.h b/lib/gladman-fcrypt/aesopt.h
index a3e8561..12db549 100644
--- a/lib/gladman-fcrypt/aesopt.h
+++ b/lib/gladman-fcrypt/aesopt.h
@@ -154,6 +154,9 @@
#if defined(__cplusplus)
extern "C"
{
+#if 0
+}
+#endif
#endif
/* START OF CONFIGURATION OPTIONS
@@ -180,37 +183,14 @@
/* 1. PLATFORM SPECIFIC INCLUDES */
-#if defined( __CRYPTLIB__ ) && !defined( INC_ALL ) && !defined( INC_CHILD )
-#include "crypt/aes.h"
-#else
- #include "aes.h"
-#endif
+#include "aes.h"
-#if defined(__GNUC__) || defined(__GNU_LIBRARY__)
-# include <endian.h>
-# include <byteswap.h>
-#elif defined(__CRYPTLIB__)
-# if defined( INC_ALL )
-# include "crypt.h"
-# elif defined( INC_CHILD )
-# include "../crypt.h"
-# else
-# include "crypt.h"
-# endif
-# if defined(DATA_LITTLEENDIAN)
-# define PLATFORM_BYTE_ORDER AES_LITTLE_ENDIAN
-# else
-# define PLATFORM_BYTE_ORDER AES_BIG_ENDIAN
-# endif
-#elif defined(_MSC_VER)
-# include <stdlib.h>
-#elif !defined(WIN32)
-# include <stdlib.h>
-# if !defined (_ENDIAN_H)
-# include <sys/param.h>
-# else
-# include _ENDIAN_H
-# endif
+#include "config.h"
+
+#if defined(WORDS_BIGENDIAN)
+# define PLATFORM_BYTE_ORDER AES_BIG_ENDIAN
+#else
+# define PLATFORM_BYTE_ORDER AES_LITTLE_ENDIAN
#endif
/* 2. BYTE ORDER IN 32-BIT WORDS
@@ -744,7 +724,7 @@
#ifdef FIXED_TABLES
-#define prefx extern const
+#define prefx INTERNAL const
#elif defined(GLOBALS)
#define prefx extern
extern aes_08t t_dec(in,it);
diff --git a/lib/gladman-fcrypt/aestab.c b/lib/gladman-fcrypt/aestab.c
index 567791b..7b202be 100644
--- a/lib/gladman-fcrypt/aestab.c
+++ b/lib/gladman-fcrypt/aestab.c
@@ -197,7 +197,7 @@
#define v2(p) bytes2word(fd(p), fb(p), fe(p), f9(p))
#define v3(p) bytes2word(f9(p), fd(p), fb(p), fe(p))
-const aes_32t t_dec(r,c)[RC_LENGTH] =
+INTERNAL const aes_32t t_dec(r,c)[RC_LENGTH] =
{
w0(0x01), w0(0x02), w0(0x04), w0(0x08), w0(0x10),
w0(0x20), w0(0x40), w0(0x80), w0(0x1b), w0(0x36),
@@ -216,57 +216,57 @@
};
#ifdef SBX_SET
-const aes_08t t_dec(s,box)[256] = { sb_data(h0) };
+INTERNAL const aes_08t t_dec(s,box)[256] = { sb_data(h0) };
#endif
#ifdef ISB_SET
-const aes_08t t_dec(i,box)[256] = { isb_data(h0) };
+INTERNAL const aes_08t t_dec(i,box)[256] = { isb_data(h0) };
#endif
#ifdef FT1_SET
-const aes_32t t_dec(f,n)[256] = { sb_data(u0) };
+INTERNAL const aes_32t t_dec(f,n)[256] = { sb_data(u0) };
#endif
#ifdef FT4_SET
-const aes_32t t_dec(f,n)[4][256] =
+INTERNAL const aes_32t t_dec(f,n)[4][256] =
{ { sb_data(u0) }, { sb_data(u1) }, { sb_data(u2) }, { sb_data(u3) } };
#endif
#ifdef FL1_SET
-const aes_32t t_dec(f,l)[256] = { sb_data(w0) };
+INTERNAL const aes_32t t_dec(f,l)[256] = { sb_data(w0) };
#endif
#ifdef FL4_SET
-const aes_32t t_dec(f,l)[4][256] =
+INTERNAL const aes_32t t_dec(f,l)[4][256] =
{ { sb_data(w0) }, { sb_data(w1) }, { sb_data(w2) }, { sb_data(w3) } };
#endif
#ifdef IT1_SET
-const aes_32t t_dec(i,n)[256] = { isb_data(v0) };
+INTERNAL const aes_32t t_dec(i,n)[256] = { isb_data(v0) };
#endif
#ifdef IT4_SET
-const aes_32t t_dec(i,n)[4][256] =
+INTERNAL const aes_32t t_dec(i,n)[4][256] =
{ { isb_data(v0) }, { isb_data(v1) }, { isb_data(v2) }, { isb_data(v3) } };
#endif
#ifdef IL1_SET
-const aes_32t t_dec(i,l)[256] = { isb_data(w0) };
+INTERNAL const aes_32t t_dec(i,l)[256] = { isb_data(w0) };
#endif
#ifdef IL4_SET
-const aes_32t t_dec(i,l)[4][256] =
+INTERNAL const aes_32t t_dec(i,l)[4][256] =
{ { isb_data(w0) }, { isb_data(w1) }, { isb_data(w2) }, { isb_data(w3) } };
#endif
#ifdef LS1_SET
-const aes_32t t_dec(l,s)[256] = { sb_data(w0) };
+INTERNAL const aes_32t t_dec(l,s)[256] = { sb_data(w0) };
#endif
#ifdef LS4_SET
-const aes_32t t_dec(l,s)[4][256] =
+INTERNAL const aes_32t t_dec(l,s)[4][256] =
{ { sb_data(w0) }, { sb_data(w1) }, { sb_data(w2) }, { sb_data(w3) } };
#endif
#ifdef IM1_SET
-const aes_32t t_dec(i,m)[256] = { mm_data(v0) };
+INTERNAL const aes_32t t_dec(i,m)[256] = { mm_data(v0) };
#endif
#ifdef IM4_SET
-const aes_32t t_dec(i,m)[4][256] =
+INTERNAL const aes_32t t_dec(i,m)[4][256] =
{ { mm_data(v0) }, { mm_data(v1) }, { mm_data(v2) }, { mm_data(v3) } };
#endif
@@ -402,9 +402,9 @@
(w = (aes_32t)x, w = (w<<1)^(w<<3)^(w<<6), 0x05^(aes_08t)(w^(w>>8)))
#ifdef GLOBALS
-void gen_tabs(void)
+INTERNAL void gen_tabs(void)
#else
-void gen_tabs(aes_ctx cx[1])
+INTERNAL void gen_tabs(aes_ctx cx[1])
#endif
{ aes_32t i, w;
diff --git a/lib/gladman-fcrypt/fileenc.c b/lib/gladman-fcrypt/fileenc.c
index cff7d67..05e8cfc 100644
--- a/lib/gladman-fcrypt/fileenc.c
+++ b/lib/gladman-fcrypt/fileenc.c
@@ -70,7 +70,7 @@
cx->encr_pos = pos;
}
-int fcrypt_init(
+int _zip_fcrypt_init(
int mode, /* the mode to be used (input) */
const unsigned char pwd[], /* the user specified password (input) */
unsigned int pwd_len, /* the length of the password (input) */
@@ -116,7 +116,7 @@
/* perform 'in place' encryption and authentication */
-void fcrypt_encrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1])
+void _zip_fcrypt_encrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1])
{
encr_data(data, data_len, cx);
hmac_sha1_data(data, data_len, cx->auth_ctx);
@@ -124,7 +124,7 @@
/* perform 'in place' authentication and decryption */
-void fcrypt_decrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1])
+void _zip_fcrypt_decrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1])
{
hmac_sha1_data(data, data_len, cx->auth_ctx);
encr_data(data, data_len, cx);
@@ -132,7 +132,7 @@
/* close encryption/decryption and return the MAC value */
-int fcrypt_end(unsigned char mac[], fcrypt_ctx cx[1])
+int _zip_fcrypt_end(unsigned char mac[], fcrypt_ctx cx[1])
{
hmac_sha1_end(mac, MAC_LENGTH(cx->mode), cx->auth_ctx);
return MAC_LENGTH(cx->mode); /* return MAC length in bytes */
diff --git a/lib/gladman-fcrypt/fileenc.h b/lib/gladman-fcrypt/fileenc.h
index b488902..3735ee1 100644
--- a/lib/gladman-fcrypt/fileenc.h
+++ b/lib/gladman-fcrypt/fileenc.h
@@ -93,7 +93,7 @@
/* initialise file encryption or decryption */
-int fcrypt_init(
+int _zip_fcrypt_init(
int mode, /* the mode to be used (input) */
const unsigned char pwd[], /* the user specified password (input) */
unsigned int pwd_len, /* the length of the password (input) */
@@ -105,13 +105,13 @@
/* perform 'in place' encryption or decryption and authentication */
-void fcrypt_encrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1]);
-void fcrypt_decrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1]);
+void _zip_fcrypt_encrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1]);
+void _zip_fcrypt_decrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1]);
/* close encryption/decryption and return the MAC value */
/* the return value is the length of the MAC */
-int fcrypt_end(unsigned char mac[], /* the MAC value (output) */
+int _zip_fcrypt_end(unsigned char mac[], /* the MAC value (output) */
fcrypt_ctx cx[1]); /* the context (input) */
#if defined(__cplusplus)
diff --git a/lib/gladman-fcrypt/hmac.c b/lib/gladman-fcrypt/hmac.c
index a57f376..9048583 100644
--- a/lib/gladman-fcrypt/hmac.c
+++ b/lib/gladman-fcrypt/hmac.c
@@ -41,13 +41,13 @@
#endif
/* initialise the HMAC context to zero */
-void hmac_sha1_begin(hmac_ctx cx[1])
+INTERNAL void hmac_sha1_begin(hmac_ctx cx[1])
{
memset(cx, 0, sizeof(hmac_ctx));
}
/* input the HMAC key (can be called multiple times) */
-int hmac_sha1_key(const unsigned char key[], unsigned long key_len, hmac_ctx cx[1])
+INTERNAL int hmac_sha1_key(const unsigned char key[], unsigned long key_len, hmac_ctx cx[1])
{
if(cx->klen == HMAC_IN_DATA) /* error if further key input */
return HMAC_BAD_MODE; /* is attempted in data mode */
@@ -71,7 +71,7 @@
/* input the HMAC data (can be called multiple times) - */
/* note that this call terminates the key input phase */
-void hmac_sha1_data(const unsigned char data[], unsigned long data_len, hmac_ctx cx[1])
+INTERNAL void hmac_sha1_data(const unsigned char data[], unsigned long data_len, hmac_ctx cx[1])
{ unsigned int i;
if(cx->klen != HMAC_IN_DATA) /* if not yet in data phase */
@@ -103,7 +103,7 @@
}
/* compute and output the MAC value */
-void hmac_sha1_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1])
+INTERNAL void hmac_sha1_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1])
{ unsigned char dig[OUT_BLOCK_LENGTH];
unsigned int i;
@@ -129,7 +129,7 @@
}
/* 'do it all in one go' subroutine */
-void hmac_sha1(const unsigned char key[], unsigned int key_len,
+INTERNAL void hmac_sha1(const unsigned char key[], unsigned int key_len,
const unsigned char data[], unsigned int data_len,
unsigned char mac[], unsigned int mac_len)
{ hmac_ctx cx[1];
diff --git a/lib/gladman-fcrypt/hmac.h b/lib/gladman-fcrypt/hmac.h
index bbeac00..015cf72 100644
--- a/lib/gladman-fcrypt/hmac.h
+++ b/lib/gladman-fcrypt/hmac.h
@@ -58,15 +58,15 @@
unsigned int klen;
} hmac_ctx;
-void hmac_sha1_begin(hmac_ctx cx[1]);
+INTERNAL void hmac_sha1_begin(hmac_ctx cx[1]);
-int hmac_sha1_key(const unsigned char key[], unsigned long key_len, hmac_ctx cx[1]);
+INTERNAL int hmac_sha1_key(const unsigned char key[], unsigned long key_len, hmac_ctx cx[1]);
-void hmac_sha1_data(const unsigned char data[], unsigned long data_len, hmac_ctx cx[1]);
+INTERNAL void hmac_sha1_data(const unsigned char data[], unsigned long data_len, hmac_ctx cx[1]);
-void hmac_sha1_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1]);
+INTERNAL void hmac_sha1_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1]);
-void hmac_sha1(const unsigned char key[], unsigned int key_len,
+INTERNAL void hmac_sha1(const unsigned char key[], unsigned int key_len,
const unsigned char data[], unsigned int data_len,
unsigned char mac[], unsigned int mac_len);
diff --git a/lib/gladman-fcrypt/prng.c b/lib/gladman-fcrypt/prng.c
index 14fc09d..cdb3ca3 100644
--- a/lib/gladman-fcrypt/prng.c
+++ b/lib/gladman-fcrypt/prng.c
@@ -97,7 +97,7 @@
prng_mix(ctx->obuf);
}
-void prng_init(prng_entropy_fn fun, prng_ctx ctx[1])
+INTERNAL void prng_init(prng_entropy_fn fun, prng_ctx ctx[1])
{ int i;
/* clear the buffers and the counter in the context */
@@ -119,7 +119,7 @@
/* provide random bytes from the random data pool */
-void prng_rand(unsigned char data[], unsigned int data_len, prng_ctx ctx[1])
+INTERNAL void prng_rand(unsigned char data[], unsigned int data_len, prng_ctx ctx[1])
{ unsigned char *rp = data;
unsigned int len, pos = ctx->pos;
@@ -143,7 +143,7 @@
ctx->pos = pos;
}
-void prng_end(prng_ctx ctx[1])
+INTERNAL void prng_end(prng_ctx ctx[1])
{
/* ensure the data in the context is destroyed */
memset(ctx, 0, sizeof(prng_ctx));
diff --git a/lib/gladman-fcrypt/prng.h b/lib/gladman-fcrypt/prng.h
index 9a77426..87c99d1 100644
--- a/lib/gladman-fcrypt/prng.h
+++ b/lib/gladman-fcrypt/prng.h
@@ -67,13 +67,13 @@
} prng_ctx;
/* initialise the random stream generator */
-void prng_init(prng_entropy_fn fun, prng_ctx ctx[1]);
+INTERNAL void prng_init(prng_entropy_fn fun, prng_ctx ctx[1]);
/* obtain random bytes from the generator */
-void prng_rand(unsigned char data[], unsigned int data_len, prng_ctx ctx[1]);
+INTERNAL void prng_rand(unsigned char data[], unsigned int data_len, prng_ctx ctx[1]);
/* close the random stream generator */
-void prng_end(prng_ctx ctx[1]);
+INTERNAL void prng_end(prng_ctx ctx[1]);
#if defined(__cplusplus)
}
diff --git a/lib/gladman-fcrypt/pwd2key.c b/lib/gladman-fcrypt/pwd2key.c
index 7763f6a..3bda272 100644
--- a/lib/gladman-fcrypt/pwd2key.c
+++ b/lib/gladman-fcrypt/pwd2key.c
@@ -42,7 +42,7 @@
{
#endif
-void derive_key(const unsigned char pwd[], /* the PASSWORD */
+INTERNAL void derive_key(const unsigned char pwd[], /* the PASSWORD */
unsigned int pwd_len, /* and its length */
const unsigned char salt[], /* the SALT and its */
unsigned int salt_len, /* length */
diff --git a/lib/gladman-fcrypt/pwd2key.h b/lib/gladman-fcrypt/pwd2key.h
index d8bc401..d6a2c4a 100644
--- a/lib/gladman-fcrypt/pwd2key.h
+++ b/lib/gladman-fcrypt/pwd2key.h
@@ -42,7 +42,7 @@
{
#endif
-void derive_key(
+INTERNAL void derive_key(
const unsigned char pwd[], /* the PASSWORD, and */
unsigned int pwd_len, /* its length */
const unsigned char salt[], /* the SALT and its */
diff --git a/lib/gladman-fcrypt/sha1.c b/lib/gladman-fcrypt/sha1.c
index 68aeeb9..1aedf57 100644
--- a/lib/gladman-fcrypt/sha1.c
+++ b/lib/gladman-fcrypt/sha1.c
@@ -37,16 +37,14 @@
#include <string.h> /* for memcpy() etc. */
#include <stdlib.h> /* for _lrotl with VC++ */
-#if defined(__GNUC__) || defined(__GNU_LIBRARY__)
-#include <byteswap.h>
-#include <endian.h>
-#endif
-
#include "sha1.h"
#if defined(__cplusplus)
extern "C"
{
+#if 0
+}
+#endif
#endif
/*
@@ -60,6 +58,16 @@
#define SHA_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */
#define SHA_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */
+#include "config.h"
+
+#if !defined(PLATFORM_BYTE_ORDER)
+# if defined(WORDS_BIGENDIAN)
+# define PLATFORM_BYTE_ORDER SHA_BIG_ENDIAN
+# else
+# define PLATFORM_BYTE_ORDER SHA_LITTLE_ENDIAN
+# endif
+#endif
+
#if !defined(PLATFORM_BYTE_ORDER)
#if defined(LITTLE_ENDIAN) || defined(BIG_ENDIAN)
# if defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
@@ -128,7 +136,7 @@
t = a; a = rotl32(a,5) + f(b,c,d) + e + k + w[i]; \
e = d; d = c; c = rotl32(b, 30); b = t
-void sha1_compile(sha1_ctx ctx[1])
+INTERNAL void sha1_compile(sha1_ctx ctx[1])
{ sha1_32t w[80], i, a, b, c, d, e, t;
/* note that words are compiled from the buffer into 32-bit */
@@ -173,7 +181,7 @@
ctx->hash[4] += e;
}
-void sha1_begin(sha1_ctx ctx[1])
+INTERNAL void sha1_begin(sha1_ctx ctx[1])
{
ctx->count[0] = ctx->count[1] = 0;
ctx->hash[0] = 0x67452301;
@@ -186,7 +194,7 @@
/* SHA1 hash data in an array of bytes into hash buffer and */
/* call the hash_compile function as required. */
-void sha1_hash(const unsigned char data[], unsigned int len, sha1_ctx ctx[1])
+INTERNAL void sha1_hash(const unsigned char data[], unsigned int len, sha1_ctx ctx[1])
{ sha1_32t pos = (sha1_32t)(ctx->count[0] & SHA1_MASK),
space = SHA1_BLOCK_SIZE - pos;
const unsigned char *sp = data;
@@ -226,7 +234,7 @@
{ 0x80000000, 0x00800000, 0x00008000, 0x00000080 };
#endif
-void sha1_end(unsigned char hval[], sha1_ctx ctx[1])
+INTERNAL void sha1_end(unsigned char hval[], sha1_ctx ctx[1])
{ sha1_32t i = (sha1_32t)(ctx->count[0] & SHA1_MASK);
/* mask out the rest of any partial 32-bit word and then set */
@@ -266,7 +274,7 @@
hval[i] = (unsigned char)(ctx->hash[i >> 2] >> (8 * (~i & 3)));
}
-void sha1(unsigned char hval[], const unsigned char data[], unsigned int len)
+INTERNAL void sha1(unsigned char hval[], const unsigned char data[], unsigned int len)
{ sha1_ctx cx[1];
sha1_begin(cx); sha1_hash(data, len, cx); sha1_end(hval, cx);
diff --git a/lib/gladman-fcrypt/sha1.h b/lib/gladman-fcrypt/sha1.h
index 3061235..766ccc2 100644
--- a/lib/gladman-fcrypt/sha1.h
+++ b/lib/gladman-fcrypt/sha1.h
@@ -48,13 +48,9 @@
/* define an unsigned 32-bit type */
-#if UINT_MAX == 0xffffffff
- typedef unsigned int sha1_32t;
-#elif ULONG_MAX == 0xffffffff
- typedef unsigned long sha1_32t;
-#else
-#error Please define sha1_32t as an unsigned 32 bit type in sha2.h
-#endif
+#include "config.h"
+
+typedef zip_uint32_t sha1_32t;
/* type to hold the SHA256 context */
@@ -64,12 +60,12 @@
sha1_32t wbuf[16];
} sha1_ctx;
-void sha1_compile(sha1_ctx ctx[1]);
+INTERNAL void sha1_compile(sha1_ctx ctx[1]);
-void sha1_begin(sha1_ctx ctx[1]);
-void sha1_hash(const unsigned char data[], unsigned int len, sha1_ctx ctx[1]);
-void sha1_end(unsigned char hval[], sha1_ctx ctx[1]);
-void sha1(unsigned char hval[], const unsigned char data[], unsigned int len);
+INTERNAL void sha1_begin(sha1_ctx ctx[1]);
+INTERNAL void sha1_hash(const unsigned char data[], unsigned int len, sha1_ctx ctx[1]);
+INTERNAL void sha1_end(unsigned char hval[], sha1_ctx ctx[1]);
+INTERNAL void sha1(unsigned char hval[], const unsigned char data[], unsigned int len);
#if defined(__cplusplus)
}