From d515df16404c0e598fe94573c8dfaaab7e745829 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Tue, 16 Apr 2024 18:13:58 +0200 Subject: [PATCH] Avoid C namespace pollution by keeping implementations static As reported in #35, some of the C files in this library (e.g. src/poly1305-donna.c) are also present in other libraries, causing name collisions for the functions they export. This commit applies a `static` modifier to all C functions exported by these files, and includes directly the C files in the stub-*.c files. In the end, the only functions exported are now the OCaml/C stub functions, prefixed by `caml_`. The `static` modifier is hidden behind a `EXPORT` macro, so that the original visibility can be restored by compiling with `-DEXPORT=`, if that's ever needed. While we're at it: removed the remaining `$Id` comments. --- src/aesni.c | 22 +++--- src/aesni.h | 12 ++-- src/arcfour.c | 6 +- src/arcfour.h | 4 +- src/blake2.c | 12 ++-- src/blake2.h | 12 ++-- src/blake3.c | 18 ++--- src/blake3.h | 30 ++++---- src/blake3_dispatch.c | 8 +-- src/blake3_impl.h | 156 ++++++++++++++++++++--------------------- src/blake3_portable.c | 6 +- src/blowfish.c | 6 +- src/blowfish.h | 6 +- src/chacha20.c | 6 +- src/chacha20.h | 16 ++--- src/d3des.c | 4 +- src/d3des.h | 4 +- src/dune | 23 +----- src/ghash.c | 4 +- src/ghash.h | 4 +- src/keccak.c | 6 +- src/keccak.h | 6 +- src/pclmul.c | 10 +-- src/pclmul.h | 6 +- src/poly1305-donna.c | 2 +- src/poly1305-donna.h | 6 +- src/rijndael-alg-fst.c | 14 ++-- src/rijndael-alg-fst.h | 12 ++-- src/ripemd160.c | 8 +-- src/ripemd160.h | 6 +- src/sha1.c | 8 +-- src/sha1.h | 6 +- src/sha256.c | 8 +-- src/sha256.h | 6 +- src/sha512.c | 8 +-- src/sha512.h | 6 +- src/siphash.c | 6 +- src/siphash.h | 6 +- src/stubs-aes.c | 7 +- src/stubs-arcfour.c | 4 +- src/stubs-blake2.c | 3 +- src/stubs-blake3.c | 5 +- src/stubs-blowfish.c | 4 +- src/stubs-chacha20.c | 2 +- src/stubs-des.c | 4 +- src/stubs-ghash.c | 4 +- src/stubs-md5.c | 2 - src/stubs-misc.c | 2 - src/stubs-poly1305.c | 2 +- src/stubs-ripemd160.c | 4 +- src/stubs-rng.c | 2 - src/stubs-sha1.c | 4 +- src/stubs-sha256.c | 4 +- src/stubs-sha3.c | 4 +- src/stubs-sha512.c | 4 +- src/stubs-siphash.c | 3 +- src/stubs-zlib.c | 2 - 57 files changed, 253 insertions(+), 302 deletions(-) diff --git a/src/aesni.c b/src/aesni.c index 4013657..79e620a 100644 --- a/src/aesni.c +++ b/src/aesni.c @@ -21,9 +21,9 @@ #include #include -int aesni_available = -1; +EXPORT int aesni_available = -1; -int aesni_check_available(void) +EXPORT int aesni_check_available(void) { unsigned int eax, ebx, ecx, edx; if(__get_cpuid(1, &eax, &ebx, &ecx, &edx)) { @@ -224,7 +224,7 @@ static void * align16(void * p) return (void *) n; } -int aesniKeySetupEnc(unsigned char * ckey, +EXPORT int aesniKeySetupEnc(unsigned char * ckey, const unsigned char * key, int keylength) { @@ -239,7 +239,7 @@ int aesniKeySetupEnc(unsigned char * ckey, return nrounds; } -int aesniKeySetupDec(unsigned char * ckey, +EXPORT int aesniKeySetupDec(unsigned char * ckey, const unsigned char * key, int keylength) { @@ -257,7 +257,7 @@ int aesniKeySetupDec(unsigned char * ckey, return nrounds; } -void aesniEncrypt(const unsigned char * key, int nrounds, +EXPORT void aesniEncrypt(const unsigned char * key, int nrounds, const unsigned char * in, unsigned char * out) { @@ -278,7 +278,7 @@ void aesniEncrypt(const unsigned char * key, int nrounds, _mm_storeu_si128 ((__m128i*) out, t); } -void aesniDecrypt(const unsigned char * key, int nrounds, +EXPORT void aesniDecrypt(const unsigned char * key, int nrounds, const unsigned char * in, unsigned char * out) { @@ -303,24 +303,24 @@ void aesniDecrypt(const unsigned char * key, int nrounds, int aesni_available = 0; -int aesni_check_available(void) { return 0; } +EXPORT int aesni_check_available(void) { return 0; } -int aesniKeySetupEnc(unsigned char * ckey, +EXPORT int aesniKeySetupEnc(unsigned char * ckey, const unsigned char * key, int keylength) { abort(); } -int aesniKeySetupDec(unsigned char * ckey, +EXPORT int aesniKeySetupDec(unsigned char * ckey, const unsigned char * key, int keylength) { abort(); } -void aesniEncrypt(const unsigned char * key, int nrounds, +EXPORT void aesniEncrypt(const unsigned char * key, int nrounds, const unsigned char * in, unsigned char * out) { abort(); } -void aesniDecrypt(const unsigned char * key, int nrounds, +EXPORT void aesniDecrypt(const unsigned char * key, int nrounds, const unsigned char * in, unsigned char * out) { abort(); } diff --git a/src/aesni.h b/src/aesni.h index 016fb0e..0b36117 100644 --- a/src/aesni.h +++ b/src/aesni.h @@ -13,27 +13,27 @@ /* Hardware-accelerated implementation of AES */ -extern int aesni_available; +EXPORT int aesni_available; /* -1: unknown, call aesni_check_available() to determine 0: not available 1: available */ -extern int aesni_check_available(void); +EXPORT int aesni_check_available(void); -extern int aesniKeySetupEnc(unsigned char * ckey, +EXPORT int aesniKeySetupEnc(unsigned char * ckey, const unsigned char * key, int keylength); -extern int aesniKeySetupDec(unsigned char * ckey, +EXPORT int aesniKeySetupDec(unsigned char * ckey, const unsigned char * key, int keylength); -extern void aesniEncrypt(const unsigned char * key, int nrounds, +EXPORT void aesniEncrypt(const unsigned char * key, int nrounds, const unsigned char * in, unsigned char * out); -extern void aesniDecrypt(const unsigned char * key, int nrounds, +EXPORT void aesniDecrypt(const unsigned char * key, int nrounds, const unsigned char * in, unsigned char * out); diff --git a/src/arcfour.c b/src/arcfour.c index 8388008..ef32fad 100644 --- a/src/arcfour.c +++ b/src/arcfour.c @@ -11,11 +11,9 @@ /* */ /***********************************************************************/ -/* $Id$ */ - #include "arcfour.h" -void arcfour_cook_key(struct arcfour_key * key, +EXPORT void arcfour_cook_key(struct arcfour_key * key, unsigned char * key_data, int key_data_len) { @@ -37,7 +35,7 @@ void arcfour_cook_key(struct arcfour_key * key, } } -void arcfour_encrypt(struct arcfour_key * key, +EXPORT void arcfour_encrypt(struct arcfour_key * key, char * src, char * dst, long len) { int x, y, kx, ky; diff --git a/src/arcfour.h b/src/arcfour.h index 90bfb85..b82f779 100644 --- a/src/arcfour.h +++ b/src/arcfour.h @@ -19,10 +19,10 @@ struct arcfour_key unsigned char x, y; }; -extern void arcfour_cook_key(struct arcfour_key * key, +EXPORT void arcfour_cook_key(struct arcfour_key * key, unsigned char * key_data, int key_data_len); -extern void arcfour_encrypt(struct arcfour_key * key, +EXPORT void arcfour_encrypt(struct arcfour_key * key, char * src, char * dst, long len); diff --git a/src/blake2.c b/src/blake2.c index cdd0384..bf1f97d 100644 --- a/src/blake2.c +++ b/src/blake2.c @@ -116,7 +116,7 @@ static void blake2b_compress(struct blake2b * s, unsigned char * data, s->h[6] ^= v6 ^ v14; s->h[7] ^= v7 ^ v15; } -void blake2b_init(struct blake2b * s, +EXPORT void blake2b_init(struct blake2b * s, int hashlen, int keylen, unsigned char * key) { int i; @@ -134,7 +134,7 @@ void blake2b_init(struct blake2b * s, } } -void blake2b_add_data(struct blake2b * s, +EXPORT void blake2b_add_data(struct blake2b * s, unsigned char * data, size_t len) { int n; @@ -161,7 +161,7 @@ void blake2b_add_data(struct blake2b * s, s->numbytes = len; } -void blake2b_final(struct blake2b * s, int hashlen, unsigned char * hash) +EXPORT void blake2b_final(struct blake2b * s, int hashlen, unsigned char * hash) { unsigned int i; assert (0 < hashlen && hashlen <= 64); @@ -255,7 +255,7 @@ static void blake2s_compress(struct blake2s * s, unsigned char * data, s->h[6] ^= v6 ^ v14; s->h[7] ^= v7 ^ v15; } -void blake2s_init(struct blake2s * s, +EXPORT void blake2s_init(struct blake2s * s, int hashlen, int keylen, unsigned char * key) { int i; @@ -273,7 +273,7 @@ void blake2s_init(struct blake2s * s, } } -void blake2s_add_data(struct blake2s * s, +EXPORT void blake2s_add_data(struct blake2s * s, unsigned char * data, size_t len) { int n; @@ -300,7 +300,7 @@ void blake2s_add_data(struct blake2s * s, s->numbytes = len; } -void blake2s_final(struct blake2s * s, int hashlen, unsigned char * hash) +EXPORT void blake2s_final(struct blake2s * s, int hashlen, unsigned char * hash) { unsigned int i; assert (0 < hashlen && hashlen <= 32); diff --git a/src/blake2.h b/src/blake2.h index 1693b33..5f38659 100644 --- a/src/blake2.h +++ b/src/blake2.h @@ -22,11 +22,11 @@ struct blake2b { unsigned char buffer[BLAKE2b_BLOCKSIZE]; }; -extern void blake2b_init(struct blake2b * s, +EXPORT void blake2b_init(struct blake2b * s, int hashlen, int keylen, unsigned char * key); -extern void blake2b_add_data(struct blake2b * s, +EXPORT void blake2b_add_data(struct blake2b * s, unsigned char * data, size_t len); -extern void blake2b_final(struct blake2b * s, +EXPORT void blake2b_final(struct blake2b * s, int hashlen, unsigned char * hash); #define BLAKE2s_BLOCKSIZE 64 @@ -38,10 +38,10 @@ struct blake2s { unsigned char buffer[BLAKE2s_BLOCKSIZE]; }; -extern void blake2s_init(struct blake2s * s, +EXPORT void blake2s_init(struct blake2s * s, int hashlen, int keylen, unsigned char * key); -extern void blake2s_add_data(struct blake2s * s, +EXPORT void blake2s_add_data(struct blake2s * s, unsigned char * data, size_t len); -extern void blake2s_final(struct blake2s * s, +EXPORT void blake2s_final(struct blake2s * s, int hashlen, unsigned char * hash); diff --git a/src/blake3.c b/src/blake3.c index dc343f9..372c728 100644 --- a/src/blake3.c +++ b/src/blake3.c @@ -5,7 +5,7 @@ #include "blake3.h" #include "blake3_impl.h" -const char *blake3_version(void) { return BLAKE3_VERSION_STRING; } +EXPORT const char *blake3_version(void) { return BLAKE3_VERSION_STRING; } INLINE void chunk_state_init(blake3_chunk_state *self, const uint32_t key[8], uint8_t flags) { @@ -366,16 +366,16 @@ INLINE void hasher_init_base(blake3_hasher *self, const uint32_t key[8], self->cv_stack_len = 0; } -void blake3_hasher_init(blake3_hasher *self) { hasher_init_base(self, IV, 0); } +EXPORT void blake3_hasher_init(blake3_hasher *self) { hasher_init_base(self, IV, 0); } -void blake3_hasher_init_keyed(blake3_hasher *self, +EXPORT void blake3_hasher_init_keyed(blake3_hasher *self, const uint8_t key[BLAKE3_KEY_LEN]) { uint32_t key_words[8]; load_key_words(key, key_words); hasher_init_base(self, key_words, KEYED_HASH); } -void blake3_hasher_init_derive_key_raw(blake3_hasher *self, const void *context, +EXPORT void blake3_hasher_init_derive_key_raw(blake3_hasher *self, const void *context, size_t context_len) { blake3_hasher context_hasher; hasher_init_base(&context_hasher, IV, DERIVE_KEY_CONTEXT); @@ -387,7 +387,7 @@ void blake3_hasher_init_derive_key_raw(blake3_hasher *self, const void *context, hasher_init_base(self, context_key_words, DERIVE_KEY_MATERIAL); } -void blake3_hasher_init_derive_key(blake3_hasher *self, const char *context) { +EXPORT void blake3_hasher_init_derive_key(blake3_hasher *self, const char *context) { blake3_hasher_init_derive_key_raw(self, context, strlen(context)); } @@ -452,7 +452,7 @@ INLINE void hasher_push_cv(blake3_hasher *self, uint8_t new_cv[BLAKE3_OUT_LEN], self->cv_stack_len += 1; } -void blake3_hasher_update(blake3_hasher *self, const void *input, +EXPORT void blake3_hasher_update(blake3_hasher *self, const void *input, size_t input_len) { // Explicitly checking for zero avoids causing UB by passing a null pointer // to memcpy. This comes up in practice with things like: @@ -561,12 +561,12 @@ void blake3_hasher_update(blake3_hasher *self, const void *input, } } -void blake3_hasher_finalize(const blake3_hasher *self, uint8_t *out, +EXPORT void blake3_hasher_finalize(const blake3_hasher *self, uint8_t *out, size_t out_len) { blake3_hasher_finalize_seek(self, 0, out, out_len); } -void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek, +EXPORT void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek, uint8_t *out, size_t out_len) { // Explicitly checking for zero avoids causing UB by passing a null pointer // to memcpy. This comes up in practice with things like: @@ -610,7 +610,7 @@ void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek, output_root_bytes(&output, seek, out, out_len); } -void blake3_hasher_reset(blake3_hasher *self) { +EXPORT void blake3_hasher_reset(blake3_hasher *self) { chunk_state_reset(&self->chunk, self->key, 0); self->cv_stack_len = 0; } diff --git a/src/blake3.h b/src/blake3.h index 7caf9b4..5d846ab 100644 --- a/src/blake3.h +++ b/src/blake3.h @@ -5,7 +5,7 @@ #include #ifdef __cplusplus -extern "C" { +EXPORT "C" { #endif #define BLAKE3_VERSION_STRING "1.3.1" @@ -38,20 +38,20 @@ typedef struct { uint8_t cv_stack[(BLAKE3_MAX_DEPTH + 1) * BLAKE3_OUT_LEN]; } blake3_hasher; -const char *blake3_version(void); -void blake3_hasher_init(blake3_hasher *self); -void blake3_hasher_init_keyed(blake3_hasher *self, - const uint8_t key[BLAKE3_KEY_LEN]); -void blake3_hasher_init_derive_key(blake3_hasher *self, const char *context); -void blake3_hasher_init_derive_key_raw(blake3_hasher *self, const void *context, - size_t context_len); -void blake3_hasher_update(blake3_hasher *self, const void *input, - size_t input_len); -void blake3_hasher_finalize(const blake3_hasher *self, uint8_t *out, - size_t out_len); -void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek, - uint8_t *out, size_t out_len); -void blake3_hasher_reset(blake3_hasher *self); +EXPORT const char *blake3_version(void); +EXPORT void blake3_hasher_init(blake3_hasher *self); +EXPORT void blake3_hasher_init_keyed(blake3_hasher *self, + const uint8_t key[BLAKE3_KEY_LEN]); +EXPORT void blake3_hasher_init_derive_key(blake3_hasher *self, const char *context); +EXPORT void blake3_hasher_init_derive_key_raw(blake3_hasher *self, const void *context, + size_t context_len); +EXPORT void blake3_hasher_update(blake3_hasher *self, const void *input, + size_t input_len); +EXPORT void blake3_hasher_finalize(const blake3_hasher *self, uint8_t *out, + size_t out_len); +EXPORT void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek, + uint8_t *out, size_t out_len); +EXPORT void blake3_hasher_reset(blake3_hasher *self); #ifdef __cplusplus } diff --git a/src/blake3_dispatch.c b/src/blake3_dispatch.c index 0f348ef..9d9c2d7 100644 --- a/src/blake3_dispatch.c +++ b/src/blake3_dispatch.c @@ -133,7 +133,7 @@ static } } -void blake3_compress_in_place(uint32_t cv[8], +EXPORT void blake3_compress_in_place(uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags) { @@ -162,7 +162,7 @@ void blake3_compress_in_place(uint32_t cv[8], blake3_compress_in_place_portable(cv, block, block_len, counter, flags); } -void blake3_compress_xof(const uint32_t cv[8], +EXPORT void blake3_compress_xof(const uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags, uint8_t out[64]) { @@ -191,7 +191,7 @@ void blake3_compress_xof(const uint32_t cv[8], blake3_compress_xof_portable(cv, block, block_len, counter, flags, out); } -void blake3_hash_many(const uint8_t *const *inputs, size_t num_inputs, +EXPORT void blake3_hash_many(const uint8_t *const *inputs, size_t num_inputs, size_t blocks, const uint32_t key[8], uint64_t counter, bool increment_counter, uint8_t flags, uint8_t flags_start, uint8_t flags_end, uint8_t *out) { @@ -244,7 +244,7 @@ void blake3_hash_many(const uint8_t *const *inputs, size_t num_inputs, } // The dynamically detected SIMD degree of the current platform. -size_t blake3_simd_degree(void) { +EXPORT size_t blake3_simd_degree(void) { #if defined(IS_X86) const enum cpu_feature features = get_cpu_features(); MAYBE_UNUSED(features); diff --git a/src/blake3_impl.h b/src/blake3_impl.h index 46c8fd8..bd8331f 100644 --- a/src/blake3_impl.h +++ b/src/blake3_impl.h @@ -177,104 +177,104 @@ INLINE void store_cv_words(uint8_t bytes_out[32], uint32_t cv_words[8]) { store32(&bytes_out[7 * 4], cv_words[7]); } -void blake3_compress_in_place(uint32_t cv[8], - const uint8_t block[BLAKE3_BLOCK_LEN], - uint8_t block_len, uint64_t counter, - uint8_t flags); +EXPORT void blake3_compress_in_place(uint32_t cv[8], + const uint8_t block[BLAKE3_BLOCK_LEN], + uint8_t block_len, uint64_t counter, + uint8_t flags); -void blake3_compress_xof(const uint32_t cv[8], - const uint8_t block[BLAKE3_BLOCK_LEN], - uint8_t block_len, uint64_t counter, uint8_t flags, - uint8_t out[64]); +EXPORT void blake3_compress_xof(const uint32_t cv[8], + const uint8_t block[BLAKE3_BLOCK_LEN], + uint8_t block_len, uint64_t counter, uint8_t flags, + uint8_t out[64]); -void blake3_hash_many(const uint8_t *const *inputs, size_t num_inputs, - size_t blocks, const uint32_t key[8], uint64_t counter, - bool increment_counter, uint8_t flags, - uint8_t flags_start, uint8_t flags_end, uint8_t *out); +EXPORT void blake3_hash_many(const uint8_t *const *inputs, size_t num_inputs, + size_t blocks, const uint32_t key[8], uint64_t counter, + bool increment_counter, uint8_t flags, + uint8_t flags_start, uint8_t flags_end, uint8_t *out); -size_t blake3_simd_degree(void); +EXPORT size_t blake3_simd_degree(void); // Declarations for implementation-specific functions. -void blake3_compress_in_place_portable(uint32_t cv[8], - const uint8_t block[BLAKE3_BLOCK_LEN], - uint8_t block_len, uint64_t counter, - uint8_t flags); - -void blake3_compress_xof_portable(const uint32_t cv[8], - const uint8_t block[BLAKE3_BLOCK_LEN], - uint8_t block_len, uint64_t counter, - uint8_t flags, uint8_t out[64]); - -void blake3_hash_many_portable(const uint8_t *const *inputs, size_t num_inputs, - size_t blocks, const uint32_t key[8], - uint64_t counter, bool increment_counter, - uint8_t flags, uint8_t flags_start, - uint8_t flags_end, uint8_t *out); +EXPORT void blake3_compress_in_place_portable(uint32_t cv[8], + const uint8_t block[BLAKE3_BLOCK_LEN], + uint8_t block_len, uint64_t counter, + uint8_t flags); + +EXPORT void blake3_compress_xof_portable(const uint32_t cv[8], + const uint8_t block[BLAKE3_BLOCK_LEN], + uint8_t block_len, uint64_t counter, + uint8_t flags, uint8_t out[64]); + +EXPORT void blake3_hash_many_portable(const uint8_t *const *inputs, size_t num_inputs, + size_t blocks, const uint32_t key[8], + uint64_t counter, bool increment_counter, + uint8_t flags, uint8_t flags_start, + uint8_t flags_end, uint8_t *out); #if defined(IS_X86) #if !defined(BLAKE3_NO_SSE2) -void blake3_compress_in_place_sse2(uint32_t cv[8], - const uint8_t block[BLAKE3_BLOCK_LEN], - uint8_t block_len, uint64_t counter, - uint8_t flags); -void blake3_compress_xof_sse2(const uint32_t cv[8], - const uint8_t block[BLAKE3_BLOCK_LEN], - uint8_t block_len, uint64_t counter, - uint8_t flags, uint8_t out[64]); -void blake3_hash_many_sse2(const uint8_t *const *inputs, size_t num_inputs, - size_t blocks, const uint32_t key[8], - uint64_t counter, bool increment_counter, - uint8_t flags, uint8_t flags_start, - uint8_t flags_end, uint8_t *out); +EXPORT void blake3_compress_in_place_sse2(uint32_t cv[8], + const uint8_t block[BLAKE3_BLOCK_LEN], + uint8_t block_len, uint64_t counter, + uint8_t flags); +EXPORT void blake3_compress_xof_sse2(const uint32_t cv[8], + const uint8_t block[BLAKE3_BLOCK_LEN], + uint8_t block_len, uint64_t counter, + uint8_t flags, uint8_t out[64]); +EXPORT void blake3_hash_many_sse2(const uint8_t *const *inputs, size_t num_inputs, + size_t blocks, const uint32_t key[8], + uint64_t counter, bool increment_counter, + uint8_t flags, uint8_t flags_start, + uint8_t flags_end, uint8_t *out); #endif #if !defined(BLAKE3_NO_SSE41) -void blake3_compress_in_place_sse41(uint32_t cv[8], - const uint8_t block[BLAKE3_BLOCK_LEN], - uint8_t block_len, uint64_t counter, - uint8_t flags); -void blake3_compress_xof_sse41(const uint32_t cv[8], - const uint8_t block[BLAKE3_BLOCK_LEN], - uint8_t block_len, uint64_t counter, - uint8_t flags, uint8_t out[64]); -void blake3_hash_many_sse41(const uint8_t *const *inputs, size_t num_inputs, - size_t blocks, const uint32_t key[8], - uint64_t counter, bool increment_counter, - uint8_t flags, uint8_t flags_start, - uint8_t flags_end, uint8_t *out); +EXPORT void blake3_compress_in_place_sse41(uint32_t cv[8], + const uint8_t block[BLAKE3_BLOCK_LEN], + uint8_t block_len, uint64_t counter, + uint8_t flags); +EXPORT void blake3_compress_xof_sse41(const uint32_t cv[8], + const uint8_t block[BLAKE3_BLOCK_LEN], + uint8_t block_len, uint64_t counter, + uint8_t flags, uint8_t out[64]); +EXPORT void blake3_hash_many_sse41(const uint8_t *const *inputs, size_t num_inputs, + size_t blocks, const uint32_t key[8], + uint64_t counter, bool increment_counter, + uint8_t flags, uint8_t flags_start, + uint8_t flags_end, uint8_t *out); #endif #if !defined(BLAKE3_NO_AVX2) -void blake3_hash_many_avx2(const uint8_t *const *inputs, size_t num_inputs, - size_t blocks, const uint32_t key[8], - uint64_t counter, bool increment_counter, - uint8_t flags, uint8_t flags_start, - uint8_t flags_end, uint8_t *out); +EXPORT void blake3_hash_many_avx2(const uint8_t *const *inputs, size_t num_inputs, + size_t blocks, const uint32_t key[8], + uint64_t counter, bool increment_counter, + uint8_t flags, uint8_t flags_start, + uint8_t flags_end, uint8_t *out); #endif #if !defined(BLAKE3_NO_AVX512) -void blake3_compress_in_place_avx512(uint32_t cv[8], - const uint8_t block[BLAKE3_BLOCK_LEN], - uint8_t block_len, uint64_t counter, - uint8_t flags); +EXPORT void blake3_compress_in_place_avx512(uint32_t cv[8], + const uint8_t block[BLAKE3_BLOCK_LEN], + uint8_t block_len, uint64_t counter, + uint8_t flags); -void blake3_compress_xof_avx512(const uint32_t cv[8], - const uint8_t block[BLAKE3_BLOCK_LEN], - uint8_t block_len, uint64_t counter, - uint8_t flags, uint8_t out[64]); - -void blake3_hash_many_avx512(const uint8_t *const *inputs, size_t num_inputs, - size_t blocks, const uint32_t key[8], - uint64_t counter, bool increment_counter, - uint8_t flags, uint8_t flags_start, - uint8_t flags_end, uint8_t *out); +EXPORT void blake3_compress_xof_avx512(const uint32_t cv[8], + const uint8_t block[BLAKE3_BLOCK_LEN], + uint8_t block_len, uint64_t counter, + uint8_t flags, uint8_t out[64]); + +EXPORT void blake3_hash_many_avx512(const uint8_t *const *inputs, size_t num_inputs, + size_t blocks, const uint32_t key[8], + uint64_t counter, bool increment_counter, + uint8_t flags, uint8_t flags_start, + uint8_t flags_end, uint8_t *out); #endif #endif #if BLAKE3_USE_NEON == 1 -void blake3_hash_many_neon(const uint8_t *const *inputs, size_t num_inputs, - size_t blocks, const uint32_t key[8], - uint64_t counter, bool increment_counter, - uint8_t flags, uint8_t flags_start, - uint8_t flags_end, uint8_t *out); +EXPORT void blake3_hash_many_neon(const uint8_t *const *inputs, size_t num_inputs, + size_t blocks, const uint32_t key[8], + uint64_t counter, bool increment_counter, + uint8_t flags, uint8_t flags_start, + uint8_t flags_end, uint8_t *out); #endif diff --git a/src/blake3_portable.c b/src/blake3_portable.c index 062dd1b..8b0e138 100644 --- a/src/blake3_portable.c +++ b/src/blake3_portable.c @@ -81,7 +81,7 @@ INLINE void compress_pre(uint32_t state[16], const uint32_t cv[8], round_fn(state, &block_words[0], 6); } -void blake3_compress_in_place_portable(uint32_t cv[8], +EXPORT void blake3_compress_in_place_portable(uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags) { @@ -97,7 +97,7 @@ void blake3_compress_in_place_portable(uint32_t cv[8], cv[7] = state[7] ^ state[15]; } -void blake3_compress_xof_portable(const uint32_t cv[8], +EXPORT void blake3_compress_xof_portable(const uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags, uint8_t out[64]) { @@ -142,7 +142,7 @@ INLINE void hash_one_portable(const uint8_t *input, size_t blocks, store_cv_words(out, cv); } -void blake3_hash_many_portable(const uint8_t *const *inputs, size_t num_inputs, +EXPORT void blake3_hash_many_portable(const uint8_t *const *inputs, size_t num_inputs, size_t blocks, const uint32_t key[8], uint64_t counter, bool increment_counter, uint8_t flags, uint8_t flags_start, diff --git a/src/blowfish.c b/src/blowfish.c index a069b34..f93c68f 100644 --- a/src/blowfish.c +++ b/src/blowfish.c @@ -363,7 +363,7 @@ static u32 F(BLOWFISH_CTX *ctx, u32 x) { #endif -void Blowfish_Encrypt(BLOWFISH_CTX *ctx, u32 *xl, u32 *xr){ +EXPORT void Blowfish_Encrypt(BLOWFISH_CTX *ctx, u32 *xl, u32 *xr){ u32 Xl; u32 Xr; @@ -415,7 +415,7 @@ void Blowfish_Encrypt(BLOWFISH_CTX *ctx, u32 *xl, u32 *xr){ #endif } -void Blowfish_Decrypt(BLOWFISH_CTX *ctx, u32 *xl, u32 *xr){ +EXPORT void Blowfish_Decrypt(BLOWFISH_CTX *ctx, u32 *xl, u32 *xr){ u32 Xl; u32 Xr; @@ -470,7 +470,7 @@ void Blowfish_Decrypt(BLOWFISH_CTX *ctx, u32 *xl, u32 *xr){ } -void Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen) { +EXPORT void Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen) { int i, j, k; u32 data, datal, datar; diff --git a/src/blowfish.h b/src/blowfish.h index 618d870..9e838cb 100644 --- a/src/blowfish.h +++ b/src/blowfish.h @@ -26,9 +26,9 @@ typedef struct { u32 S[4][256]; } BLOWFISH_CTX; -void Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen); -void Blowfish_Encrypt(BLOWFISH_CTX *ctx, u32 *xl, u32 *xr); -void Blowfish_Decrypt(BLOWFISH_CTX *ctx, u32 *xl, u32 *xr); +EXPORT void Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen); +EXPORT void Blowfish_Encrypt(BLOWFISH_CTX *ctx, u32 *xl, u32 *xr); +EXPORT void Blowfish_Decrypt(BLOWFISH_CTX *ctx, u32 *xl, u32 *xr); diff --git a/src/chacha20.c b/src/chacha20.c index 594051c..c83e185 100644 --- a/src/chacha20.c +++ b/src/chacha20.c @@ -109,7 +109,7 @@ static void chacha20_block(chacha20_ctx * ctx) } } -void chacha20_transform(chacha20_ctx * ctx, +EXPORT void chacha20_transform(chacha20_ctx * ctx, const uint8_t * in, uint8_t * out, size_t len) { int n = ctx->next; @@ -120,7 +120,7 @@ void chacha20_transform(chacha20_ctx * ctx, ctx->next = n; } -void chacha20_extract(chacha20_ctx * ctx, +EXPORT void chacha20_extract(chacha20_ctx * ctx, uint8_t * out, size_t len) { int n = ctx->next; @@ -131,7 +131,7 @@ void chacha20_extract(chacha20_ctx * ctx, ctx->next = n; } -void chacha20_init(chacha20_ctx * ctx, +EXPORT void chacha20_init(chacha20_ctx * ctx, const uint8_t * key, size_t key_length, const uint8_t * iv, size_t iv_length, uint64_t counter) diff --git a/src/chacha20.h b/src/chacha20.h index f8e790f..f74ee7d 100644 --- a/src/chacha20.h +++ b/src/chacha20.h @@ -12,13 +12,13 @@ typedef struct { int iv_length; /* 8 or 12 */ } chacha20_ctx; -void chacha20_init(chacha20_ctx * ctx, - const uint8_t * key, size_t key_length, - const uint8_t * iv, size_t iv_length, - uint64_t ctr); +EXPORT void chacha20_init(chacha20_ctx * ctx, + const uint8_t * key, size_t key_length, + const uint8_t * iv, size_t iv_length, + uint64_t ctr); -void chacha20_extract(chacha20_ctx * ctx, - uint8_t * out, size_t len); +EXPORT void chacha20_extract(chacha20_ctx * ctx, + uint8_t * out, size_t len); -void chacha20_transform(chacha20_ctx * ctx, - const uint8_t * in, uint8_t * out, size_t len); +EXPORT void chacha20_transform(chacha20_ctx * ctx, + const uint8_t * in, uint8_t * out, size_t len); diff --git a/src/d3des.c b/src/d3des.c index ef58a60..7858481 100644 --- a/src/d3des.c +++ b/src/d3des.c @@ -49,7 +49,7 @@ static u8 pc2[48] = { 40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47, 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31 }; -void d3des_cook_key(u8 key[8], int edf, u32 res[32]) +EXPORT void d3des_cook_key(u8 key[8], int edf, u32 res[32]) /* Thanks to James Gillogly & Phil Karn! */ { register int i, j, l, m, n; @@ -104,7 +104,7 @@ static void cookey(u32 * raw1, u32 * cook) return; } -void d3des_transform(u32 key[32], u8 inblock[8], u8 outblock[8]) +EXPORT void d3des_transform(u32 key[32], u8 inblock[8], u8 outblock[8]) { u32 work[2]; diff --git a/src/d3des.h b/src/d3des.h index c11120f..a2d5afb 100644 --- a/src/d3des.h +++ b/src/d3des.h @@ -15,13 +15,13 @@ typedef unsigned char u8; typedef unsigned int u32; -extern void d3des_cook_key(u8 key[8], int mode, u32 res[32]); +EXPORT void d3des_cook_key(u8 key[8], int mode, u32 res[32]); /* Sets the key register [res] according to the hexadecimal * key contained in the 8 bytes of [key], according to the DES, * for encryption or decryption according to [mode]. */ -extern void d3des_transform(u32 key[32], u8 from[8], u8 to[8]); +EXPORT void d3des_transform(u32 key[32], u8 from[8], u8 to[8]); /* Encrypts/Decrypts (according to the key [key]) * one block of eight bytes at address 'from' * into the block at address 'to'. They can be the same. diff --git a/src/dune b/src/dune index c98d716..b3c8dd5 100644 --- a/src/dune +++ b/src/dune @@ -4,47 +4,28 @@ (modules CryptokitBignum Cryptokit) (foreign_stubs (language c) - (flags -DCAML_NAME_SPACE + (flags -DCAML_NAME_SPACE -DEXPORT=static -DBLAKE3_NO_SSE2 -DBLAKE3_NO_SSE41 -DBLAKE3_NO_AVX2 -DBLAKE3_NO_AVX512 -DBLAKE3_USE_NEON=0 (:include flags.sexp)) - (names aesni - arcfour - stubs-arcfour - blowfish + (names stubs-arcfour stubs-blowfish - d3des stubs-des - rijndael-alg-fst - ripemd160 stubs-ripemd160 - sha1 stubs-sha1 - sha256 stubs-sha256 - sha512 stubs-sha512 stubs-aes stubs-md5 stubs-misc stubs-rng stubs-zlib - keccak stubs-sha3 - chacha20 stubs-chacha20 - blake2 stubs-blake2 - ghash - pclmul stubs-ghash - poly1305-donna stubs-poly1305 - siphash stubs-siphash - blake3 - blake3_dispatch - blake3_portable stubs-blake3)) (c_library_flags (:include library_flags.sexp)) (flags :standard -safe-string -w -7 -w -27 -w -37)) diff --git a/src/ghash.c b/src/ghash.c index 1d5e443..e0347c4 100644 --- a/src/ghash.c +++ b/src/ghash.c @@ -46,7 +46,7 @@ static inline void put_uint64_be(uint64_t n, uint8_t * b, int i) b[i + 7] = n; } -void ghash_mult(const struct ghash_context * ctx, +EXPORT void ghash_mult(const struct ghash_context * ctx, const uint8_t input[16], uint8_t output[16]) { @@ -86,7 +86,7 @@ void ghash_mult(const struct ghash_context * ctx, put_uint64_be(zl, output, 8 ); } -void ghash_init(struct ghash_context * ctx, +EXPORT void ghash_init(struct ghash_context * ctx, const uint8_t h[16]) { int ret, i, j; diff --git a/src/ghash.h b/src/ghash.h index ee90038..16a06ad 100644 --- a/src/ghash.h +++ b/src/ghash.h @@ -18,9 +18,9 @@ struct ghash_context { uint64_t HH[16]; // precalculated hi-half HTable }; -extern void ghash_init(struct ghash_context * ctx, +EXPORT void ghash_init(struct ghash_context * ctx, const uint8_t h[16]); -extern void ghash_mult(const struct ghash_context * ctx, +EXPORT void ghash_mult(const struct ghash_context * ctx, const uint8_t input[16], uint8_t output[16]); diff --git a/src/keccak.c b/src/keccak.c index c710d68..0dc47f3 100644 --- a/src/keccak.c +++ b/src/keccak.c @@ -114,7 +114,7 @@ static void KeccakAbsorb(u64 st[25], unsigned char * p, int rsiz) /* Exported interface */ -void SHA3_init(struct SHA3Context * ctx, int hsiz) +EXPORT void SHA3_init(struct SHA3Context * ctx, int hsiz) { assert (hsiz == 224 || hsiz == 256 || hsiz == 384 || hsiz == 512); ctx->hsiz = hsiz / 8; @@ -123,7 +123,7 @@ void SHA3_init(struct SHA3Context * ctx, int hsiz) memset(ctx->state, 0, sizeof(ctx->state)); } -void SHA3_absorb(struct SHA3Context * ctx, +EXPORT void SHA3_absorb(struct SHA3Context * ctx, unsigned char * data, unsigned long len) { @@ -153,7 +153,7 @@ void SHA3_absorb(struct SHA3Context * ctx, ctx->numbytes = len; } -void SHA3_extract(unsigned char padding, +EXPORT void SHA3_extract(unsigned char padding, struct SHA3Context * ctx, unsigned char * output) { diff --git a/src/keccak.h b/src/keccak.h index 790d82a..4d9abce 100644 --- a/src/keccak.h +++ b/src/keccak.h @@ -10,12 +10,12 @@ struct SHA3Context { int hsiz; /* size of hash in bytes */ }; -extern void SHA3_init(struct SHA3Context * ctx, int hsiz); +EXPORT void SHA3_init(struct SHA3Context * ctx, int hsiz); -extern void SHA3_absorb(struct SHA3Context * ctx, +EXPORT void SHA3_absorb(struct SHA3Context * ctx, unsigned char * data, unsigned long len); -extern void SHA3_extract(unsigned char padding, +EXPORT void SHA3_extract(unsigned char padding, struct SHA3Context * ctx, unsigned char * output); diff --git a/src/pclmul.c b/src/pclmul.c index 5cbb43c..07f76e5 100644 --- a/src/pclmul.c +++ b/src/pclmul.c @@ -23,9 +23,9 @@ #include #include -int pclmul_available = -1; +EXPORT int pclmul_available = -1; -int pclmul_check_available(void) +EXPORT int pclmul_check_available(void) { unsigned int eax, ebx, ecx, edx; if(__get_cpuid(1, &eax, &ebx, &ecx, &edx)) { @@ -46,7 +46,7 @@ static void copy_reverse_16(void * dst, const void * src) #undef COPY } -void pclmul_mult(uint8_t res[16], +EXPORT void pclmul_mult(uint8_t res[16], const uint8_t arg1[16], const uint8_t arg2[16]) { __m128i tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9; @@ -104,9 +104,9 @@ void pclmul_mult(uint8_t res[16], int pclmul_available = -1; -int pclmul_check_available(void) { return 0; } +EXPORT int pclmul_check_available(void) { return 0; } -void pclmul_mult(uint8_t res[16], +EXPORT void pclmul_mult(uint8_t res[16], const uint8_t arg1[16], const uint8_t arg2[16]) { abort(); } diff --git a/src/pclmul.h b/src/pclmul.h index d4fdf02..e9e3d15 100644 --- a/src/pclmul.h +++ b/src/pclmul.h @@ -13,15 +13,15 @@ /* Hardware-accelerated implementation of GHASH multiplication */ -extern int pclmul_available; +EXPORT int pclmul_available; /* -1: unknown, call pclmul_check_available() to determine 0: not available 1: available */ -extern int pclmul_check_available(void); +EXPORT int pclmul_check_available(void); -extern void pclmul_mult(uint8_t res[16], +EXPORT void pclmul_mult(uint8_t res[16], const uint8_t arg1[16], const uint8_t arg2[16]); diff --git a/src/poly1305-donna.c b/src/poly1305-donna.c index e99943b..103bc11 100644 --- a/src/poly1305-donna.c +++ b/src/poly1305-donna.c @@ -13,7 +13,7 @@ #endif void -poly1305_update(poly1305_context *ctx, const unsigned char *m, size_t bytes) { +EXPORT poly1305_update(poly1305_context *ctx, const unsigned char *m, size_t bytes) { poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx; size_t i; diff --git a/src/poly1305-donna.h b/src/poly1305-donna.h index ce181ff..a9b08f6 100644 --- a/src/poly1305-donna.h +++ b/src/poly1305-donna.h @@ -13,9 +13,9 @@ typedef struct poly1305_context { unsigned char opaque[136]; } poly1305_context; -void poly1305_init(poly1305_context *ctx, const unsigned char key[32]); -void poly1305_update(poly1305_context *ctx, const unsigned char *m, size_t bytes); -void poly1305_finish(poly1305_context *ctx, unsigned char mac[16]); +EXPORT void poly1305_init(poly1305_context *ctx, const unsigned char key[32]); +EXPORT void poly1305_update(poly1305_context *ctx, const unsigned char *m, size_t bytes); +EXPORT void poly1305_finish(poly1305_context *ctx, unsigned char mac[16]); #endif /* POLY1305_DONNA_H */ diff --git a/src/rijndael-alg-fst.c b/src/rijndael-alg-fst.c index 8a10040..bc16f74 100644 --- a/src/rijndael-alg-fst.c +++ b/src/rijndael-alg-fst.c @@ -725,7 +725,7 @@ static const u32 rcon[] = { * * @return the number of rounds for the given cipher key size. */ -int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits) { +EXPORT int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits) { int i = 0; u32 temp; @@ -811,12 +811,12 @@ int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBit * * @return the number of rounds for the given cipher key size. */ -int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits) { +EXPORT int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits) { int Nr, i, j; u32 temp; /* expand the cipher key: */ - Nr = rijndaelKeySetupEnc(rk, cipherKey, keyBits); + Nr = rijndaelKeySetupEnc(rk, cipherKey, keyBits); /* invert the order of the round keys: */ for (i = 0, j = 4*Nr; i < j; i += 4, j -= 4) { temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp; @@ -851,7 +851,7 @@ int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBit return Nr; } -void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]) { +EXPORT void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]) { u32 s0, s1, s2, s3, t0, t1, t2, t3; #ifndef FULL_UNROLL int r; @@ -1032,7 +1032,7 @@ void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 c PUTU32(ct + 12, s3); } -void rijndaelDecrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 ct[16], u8 pt[16]) { +EXPORT void rijndaelDecrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 ct[16], u8 pt[16]) { u32 s0, s1, s2, s3, t0, t1, t2, t3; #ifndef FULL_UNROLL int r; @@ -1215,7 +1215,7 @@ void rijndaelDecrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 ct[16], u8 p #ifdef INTERMEDIATE_VALUE_KAT -void rijndaelEncryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds) { +EXPORT void rijndaelEncryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds) { int r; u32 s0, s1, s2, s3, t0, t1, t2, t3; @@ -1308,7 +1308,7 @@ void rijndaelEncryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], in PUTU32(block + 12, s3); } -void rijndaelDecryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds) { +EXPORT void rijndaelDecryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds) { int r; u32 s0, s1, s2, s3, t0, t1, t2, t3; diff --git a/src/rijndael-alg-fst.h b/src/rijndael-alg-fst.h index f093e5b..2f493ac 100644 --- a/src/rijndael-alg-fst.h +++ b/src/rijndael-alg-fst.h @@ -34,14 +34,14 @@ typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; -int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits); -int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits); -void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]); -void rijndaelDecrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 ct[16], u8 pt[16]); +EXPORT int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits); +EXPORT int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits); +EXPORT void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]); +EXPORT void rijndaelDecrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 ct[16], u8 pt[16]); #ifdef INTERMEDIATE_VALUE_KAT -void rijndaelEncryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds); -void rijndaelDecryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds); +EXPORT void rijndaelEncryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds); +EXPORT void rijndaelDecryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[16], int rounds); #endif /* INTERMEDIATE_VALUE_KAT */ #endif /* __RIJNDAEL_ALG_FST_H */ diff --git a/src/ripemd160.c b/src/ripemd160.c index b0bbf64..10cd340 100644 --- a/src/ripemd160.c +++ b/src/ripemd160.c @@ -11,8 +11,6 @@ /* */ /***********************************************************************/ -/* $Id$ */ - /* RIPEMD160 hashing */ #include @@ -320,7 +318,7 @@ static void RIPEMD160_compress(struct RIPEMD160Context * ctx) ctx->state[0] = d; } -void RIPEMD160_init(struct RIPEMD160Context * ctx) +EXPORT void RIPEMD160_init(struct RIPEMD160Context * ctx) { ctx->state[0] = 0x67452301U; ctx->state[1] = 0xEFCDAB89U; @@ -332,7 +330,7 @@ void RIPEMD160_init(struct RIPEMD160Context * ctx) ctx->length[1] = 0; } -void RIPEMD160_add_data(struct RIPEMD160Context * ctx, unsigned char * data, +EXPORT void RIPEMD160_add_data(struct RIPEMD160Context * ctx, unsigned char * data, unsigned long len) { u32 t; @@ -368,7 +366,7 @@ void RIPEMD160_add_data(struct RIPEMD160Context * ctx, unsigned char * data, ctx->numbytes = len; } -void RIPEMD160_finish(struct RIPEMD160Context * ctx, unsigned char output[20]) +EXPORT void RIPEMD160_finish(struct RIPEMD160Context * ctx, unsigned char output[20]) { int i = ctx->numbytes; diff --git a/src/ripemd160.h b/src/ripemd160.h index 9e61d93..90a24f7 100644 --- a/src/ripemd160.h +++ b/src/ripemd160.h @@ -24,9 +24,9 @@ struct RIPEMD160Context { unsigned char buffer[64]; }; -extern void RIPEMD160_init(struct RIPEMD160Context * ctx); -extern void RIPEMD160_add_data(struct RIPEMD160Context * ctx, +EXPORT void RIPEMD160_init(struct RIPEMD160Context * ctx); +EXPORT void RIPEMD160_add_data(struct RIPEMD160Context * ctx, unsigned char * data, unsigned long len); -extern void RIPEMD160_finish(struct RIPEMD160Context * ctx, +EXPORT void RIPEMD160_finish(struct RIPEMD160Context * ctx, unsigned char output[20]); diff --git a/src/sha1.c b/src/sha1.c index ff6fc7d..b544fa1 100644 --- a/src/sha1.c +++ b/src/sha1.c @@ -11,8 +11,6 @@ /* */ /***********************************************************************/ -/* $Id$ */ - /* SHA-1 hashing */ #include @@ -100,7 +98,7 @@ static void SHA1_transform(struct SHA1Context * ctx) ctx->state[4] += e; } -void SHA1_init(struct SHA1Context * ctx) +EXPORT void SHA1_init(struct SHA1Context * ctx) { ctx->state[0] = 0x67452301U; ctx->state[1] = 0xEFCDAB89U; @@ -112,7 +110,7 @@ void SHA1_init(struct SHA1Context * ctx) ctx->length[1] = 0; } -void SHA1_add_data(struct SHA1Context * ctx, unsigned char * data, +EXPORT void SHA1_add_data(struct SHA1Context * ctx, unsigned char * data, unsigned long len) { u32 t; @@ -148,7 +146,7 @@ void SHA1_add_data(struct SHA1Context * ctx, unsigned char * data, ctx->numbytes = len; } -void SHA1_finish(struct SHA1Context * ctx, unsigned char output[20]) +EXPORT void SHA1_finish(struct SHA1Context * ctx, unsigned char output[20]) { int i = ctx->numbytes; diff --git a/src/sha1.h b/src/sha1.h index 7ba2fc2..2694758 100644 --- a/src/sha1.h +++ b/src/sha1.h @@ -24,7 +24,7 @@ struct SHA1Context { unsigned char buffer[64]; }; -extern void SHA1_init(struct SHA1Context * ctx); -extern void SHA1_add_data(struct SHA1Context * ctx, unsigned char * data, +EXPORT void SHA1_init(struct SHA1Context * ctx); +EXPORT void SHA1_add_data(struct SHA1Context * ctx, unsigned char * data, unsigned long len); -extern void SHA1_finish(struct SHA1Context * ctx, unsigned char output[20]); +EXPORT void SHA1_finish(struct SHA1Context * ctx, unsigned char output[20]); diff --git a/src/sha256.c b/src/sha256.c index 298b6e9..520f5e8 100644 --- a/src/sha256.c +++ b/src/sha256.c @@ -11,8 +11,6 @@ /* */ /***********************************************************************/ -/* $Id$ */ - /* SHA-256 hashing */ #include @@ -129,7 +127,7 @@ static void SHA256_transform(struct SHA256Context * ctx) ctx->state[7] += h; } -void SHA256_init(struct SHA256Context * ctx, int bitsize) +EXPORT void SHA256_init(struct SHA256Context * ctx, int bitsize) { switch (bitsize) { case 224: @@ -163,7 +161,7 @@ void SHA256_init(struct SHA256Context * ctx, int bitsize) ctx->length[1] = 0; } -void SHA256_add_data(struct SHA256Context * ctx, unsigned char * data, +EXPORT void SHA256_add_data(struct SHA256Context * ctx, unsigned char * data, unsigned long len) { u32 t; @@ -199,7 +197,7 @@ void SHA256_add_data(struct SHA256Context * ctx, unsigned char * data, ctx->numbytes = len; } -void SHA256_finish(struct SHA256Context * ctx, int bitsize, +EXPORT void SHA256_finish(struct SHA256Context * ctx, int bitsize, unsigned char * output) { int i = ctx->numbytes; diff --git a/src/sha256.h b/src/sha256.h index 20e6d48..a890993 100644 --- a/src/sha256.h +++ b/src/sha256.h @@ -29,9 +29,9 @@ struct SHA256Context { unsigned char buffer[64]; }; -extern void SHA256_init(struct SHA256Context * ctx, int bitsize); -extern void SHA256_add_data(struct SHA256Context * ctx, unsigned char * data, +EXPORT void SHA256_init(struct SHA256Context * ctx, int bitsize); +EXPORT void SHA256_add_data(struct SHA256Context * ctx, unsigned char * data, unsigned long len); -extern void SHA256_finish(struct SHA256Context * ctx, +EXPORT void SHA256_finish(struct SHA256Context * ctx, int bitsize, unsigned char * output); diff --git a/src/sha512.c b/src/sha512.c index 980dc3b..aacb1d6 100644 --- a/src/sha512.c +++ b/src/sha512.c @@ -11,8 +11,6 @@ /* */ /***********************************************************************/ -/* $Id: sha256.c 53 2010-08-30 10:53:00Z gildor-admin $ */ - /* SHA-512 hashing */ #include @@ -199,7 +197,7 @@ static void SHA512_transform(struct SHA512Context * ctx) ctx->state[7] += h; } -void SHA512_init(struct SHA512Context * ctx, int bitsize) +EXPORT void SHA512_init(struct SHA512Context * ctx, int bitsize) { switch (bitsize) { case 512: @@ -233,7 +231,7 @@ void SHA512_init(struct SHA512Context * ctx, int bitsize) ctx->length[1] = 0; } -void SHA512_add_data(struct SHA512Context * ctx, unsigned char * data, +EXPORT void SHA512_add_data(struct SHA512Context * ctx, unsigned char * data, unsigned long len) { u64 t; @@ -269,7 +267,7 @@ void SHA512_add_data(struct SHA512Context * ctx, unsigned char * data, ctx->numbytes = len; } -void SHA512_finish(struct SHA512Context * ctx, int bitsize, +EXPORT void SHA512_finish(struct SHA512Context * ctx, int bitsize, unsigned char * output) { int i = ctx->numbytes; diff --git a/src/sha512.h b/src/sha512.h index 2c14239..c64d9c3 100644 --- a/src/sha512.h +++ b/src/sha512.h @@ -30,8 +30,8 @@ struct SHA512Context { unsigned char buffer[128]; }; -extern void SHA512_init(struct SHA512Context * ctx, int bitsize); -extern void SHA512_add_data(struct SHA512Context * ctx, unsigned char * data, +EXPORT void SHA512_init(struct SHA512Context * ctx, int bitsize); +EXPORT void SHA512_add_data(struct SHA512Context * ctx, unsigned char * data, unsigned long len); -extern void SHA512_finish(struct SHA512Context * ctx, int bitsize, +EXPORT void SHA512_finish(struct SHA512Context * ctx, int bitsize, unsigned char * output); diff --git a/src/siphash.c b/src/siphash.c index 9fe2e76..a899851 100644 --- a/src/siphash.c +++ b/src/siphash.c @@ -49,7 +49,7 @@ static inline void U64TO8_LE(unsigned char *p, uint64_t v) { p[7] = (v >> 56) & 0xff; } -void siphash_init(struct siphash * st, const unsigned char * key, int outlen) +EXPORT void siphash_init(struct siphash * st, const unsigned char * key, int outlen) { uint64_t k0 = U8TO64_LE(key); uint64_t k1 = U8TO64_LE(key + 8); @@ -92,7 +92,7 @@ static void siphash_mix(struct siphash * st, uint64_t x) st->v0 ^= x; } -void siphash_add(struct siphash * st, const unsigned char * p, size_t len) +EXPORT void siphash_add(struct siphash * st, const unsigned char * p, size_t len) { int used = st->used; int free = SIPHASH_BUFLEN - used; @@ -126,7 +126,7 @@ static uint64_t siphash_final_rounds(struct siphash * st) return st->v0 ^ st->v1 ^ st->v2 ^ st->v3; } -void siphash_final(struct siphash * st, int outlen, unsigned char * out) +EXPORT void siphash_final(struct siphash * st, int outlen, unsigned char * out) { uint64_t w; /* Finish with the remaining bytes (up to 7 bytes). diff --git a/src/siphash.h b/src/siphash.h index 31c2c90..ea617c2 100644 --- a/src/siphash.h +++ b/src/siphash.h @@ -20,10 +20,10 @@ struct siphash { uint8_t len8; /* 8 low bits of total data length */ }; -extern void siphash_init(struct siphash * st, +EXPORT void siphash_init(struct siphash * st, const unsigned char * key, int outlen); -extern void siphash_add(struct siphash * st, +EXPORT void siphash_add(struct siphash * st, const unsigned char * p, size_t len); -extern void siphash_final(struct siphash * st, +EXPORT void siphash_final(struct siphash * st, int outlen, unsigned char * out); diff --git a/src/stubs-aes.c b/src/stubs-aes.c index ecf5559..5d4362e 100644 --- a/src/stubs-aes.c +++ b/src/stubs-aes.c @@ -11,12 +11,11 @@ /* */ /***********************************************************************/ -/* $Id$ */ - /* Stub code for AES */ -#include "rijndael-alg-fst.h" -#include "aesni.h" +#include "rijndael-alg-fst.c" +#include "aesni.c" + #include #include #include diff --git a/src/stubs-arcfour.c b/src/stubs-arcfour.c index a78e6dd..82af5ca 100644 --- a/src/stubs-arcfour.c +++ b/src/stubs-arcfour.c @@ -11,11 +11,9 @@ /* */ /***********************************************************************/ -/* $Id$ */ - /* Stub code for ARC4 */ -#include "arcfour.h" +#include "arcfour.c" #include #include #include diff --git a/src/stubs-blake2.c b/src/stubs-blake2.c index d7aaff9..ee4e6c7 100644 --- a/src/stubs-blake2.c +++ b/src/stubs-blake2.c @@ -13,10 +13,11 @@ #include #include +#include "blake2.c" + #include #include #include -#include "blake2.h" #define blake2b_val(v) ((struct blake2b *) String_val(v)) diff --git a/src/stubs-blake3.c b/src/stubs-blake3.c index 6de24f7..05abae8 100644 --- a/src/stubs-blake3.c +++ b/src/stubs-blake3.c @@ -13,11 +13,14 @@ #include #include +#include "blake3.c" +#include "blake3_portable.c" +#include "blake3_dispatch.c" + #include #include #include #include -#include "blake3.h" #define Context_val(v) (*((blake3_hasher **) Data_custom_val(v))) diff --git a/src/stubs-blowfish.c b/src/stubs-blowfish.c index e51b990..ae04325 100644 --- a/src/stubs-blowfish.c +++ b/src/stubs-blowfish.c @@ -11,11 +11,9 @@ /* */ /***********************************************************************/ -/* $Id$ */ - /* Stub code for Blowfish */ -#include "blowfish.h" +#include "blowfish.c" #include #include #include diff --git a/src/stubs-chacha20.c b/src/stubs-chacha20.c index fbc9287..92995fa 100644 --- a/src/stubs-chacha20.c +++ b/src/stubs-chacha20.c @@ -13,7 +13,7 @@ /* Stub code for Chacha20 */ -#include "chacha20.h" +#include "chacha20.c" #include #include #include diff --git a/src/stubs-des.c b/src/stubs-des.c index 770fc7c..5541d5d 100644 --- a/src/stubs-des.c +++ b/src/stubs-des.c @@ -11,11 +11,9 @@ /* */ /***********************************************************************/ -/* $Id$ */ - /* Stub code for DES */ -#include "d3des.h" +#include "d3des.c" #include #include #include diff --git a/src/stubs-ghash.c b/src/stubs-ghash.c index 3f8ff8a..479f0dd 100644 --- a/src/stubs-ghash.c +++ b/src/stubs-ghash.c @@ -13,8 +13,8 @@ #include #include -#include "ghash.h" -#include "pclmul.h" +#include "ghash.c" +#include "pclmul.c" #include #include #include diff --git a/src/stubs-md5.c b/src/stubs-md5.c index cf580d9..ceccb32 100644 --- a/src/stubs-md5.c +++ b/src/stubs-md5.c @@ -11,8 +11,6 @@ /* */ /***********************************************************************/ -/* $Id$ */ - #include #include #include diff --git a/src/stubs-misc.c b/src/stubs-misc.c index 8decda1..0da93ce 100644 --- a/src/stubs-misc.c +++ b/src/stubs-misc.c @@ -11,8 +11,6 @@ /* */ /***********************************************************************/ -/* $Id$ */ - #include #include diff --git a/src/stubs-poly1305.c b/src/stubs-poly1305.c index b22077e..d14eb1d 100644 --- a/src/stubs-poly1305.c +++ b/src/stubs-poly1305.c @@ -11,7 +11,7 @@ /* */ /***********************************************************************/ -#include "poly1305-donna.h" +#include "poly1305-donna.c" #include #include #include diff --git a/src/stubs-ripemd160.c b/src/stubs-ripemd160.c index c724f45..cf3db01 100644 --- a/src/stubs-ripemd160.c +++ b/src/stubs-ripemd160.c @@ -11,9 +11,7 @@ /* */ /***********************************************************************/ -/* $Id$ */ - -#include "ripemd160.h" +#include "ripemd160.c" #include #include #include diff --git a/src/stubs-rng.c b/src/stubs-rng.c index a10f236..251786c 100644 --- a/src/stubs-rng.c +++ b/src/stubs-rng.c @@ -11,8 +11,6 @@ /* */ /***********************************************************************/ -/* $Id$ */ - /* Stub code for the system-provided RNG and for hardware RNG */ #include diff --git a/src/stubs-sha1.c b/src/stubs-sha1.c index f1ab10a..6a9bf19 100644 --- a/src/stubs-sha1.c +++ b/src/stubs-sha1.c @@ -11,9 +11,7 @@ /* */ /***********************************************************************/ -/* $Id$ */ - -#include "sha1.h" +#include "sha1.c" #include #include #include diff --git a/src/stubs-sha256.c b/src/stubs-sha256.c index 51e41c7..d064ddd 100644 --- a/src/stubs-sha256.c +++ b/src/stubs-sha256.c @@ -11,9 +11,7 @@ /* */ /***********************************************************************/ -/* $Id$ */ - -#include "sha256.h" +#include "sha256.c" #include #include #include diff --git a/src/stubs-sha3.c b/src/stubs-sha3.c index bf85aaa..a936bc2 100644 --- a/src/stubs-sha3.c +++ b/src/stubs-sha3.c @@ -11,10 +11,8 @@ /* */ /***********************************************************************/ -/* $Id: stubs-sha1.c 53 2010-08-30 10:53:00Z gildor-admin $ */ - #include -#include "keccak.h" +#include "keccak.c" #include #include #include diff --git a/src/stubs-sha512.c b/src/stubs-sha512.c index 50f88d8..e37c79c 100644 --- a/src/stubs-sha512.c +++ b/src/stubs-sha512.c @@ -11,9 +11,7 @@ /* */ /***********************************************************************/ -/* $Id: stubs-sha256.c 53 2010-08-30 10:53:00Z gildor-admin $ */ - -#include "sha512.h" +#include "sha512.c" #include #include #include diff --git a/src/stubs-siphash.c b/src/stubs-siphash.c index 8012850..63278eb 100644 --- a/src/stubs-siphash.c +++ b/src/stubs-siphash.c @@ -13,10 +13,11 @@ #include #include +#include "siphash.c" + #include #include #include -#include "siphash.h" #define siphash_val(v) ((struct siphash *) String_val(v)) diff --git a/src/stubs-zlib.c b/src/stubs-zlib.c index dd84dba..4cdf7d1 100644 --- a/src/stubs-zlib.c +++ b/src/stubs-zlib.c @@ -11,8 +11,6 @@ /* */ /***********************************************************************/ -/* $Id$ */ - /* Stub code to interface with Zlib */ #ifdef HAVE_ZLIB