From a24eed01d5efce669b502bc37644ebb5e95860f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= Date: Sun, 2 Feb 2020 19:46:36 +0100 Subject: [PATCH] Explicitly declare all non-static functions as 'extern'. Although the compiler treats function declarations in header files to be world-visible inside the whole program implicitly, they should be declared as 'extern', for the sake of explicitness, as all of the unchanged function prototypes already were declared that way. --- lib/alg-gost3411-2012-core.h | 13 +++++++------ lib/alg-gost3411-2012-hmac.h | 4 ++-- lib/alg-hmac-sha1.h | 7 ++++--- lib/alg-sha256.h | 18 +++++++++--------- lib/alg-sha512.h | 8 ++++---- lib/crypt-port.h | 4 ++-- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/lib/alg-gost3411-2012-core.h b/lib/alg-gost3411-2012-core.h index 2464cdf..80b1c1a 100644 --- a/lib/alg-gost3411-2012-core.h +++ b/lib/alg-gost3411-2012-core.h @@ -37,14 +37,15 @@ typedef struct GOST34112012Context unsigned int digest_size; } GOST34112012Context; -void GOST34112012Init(GOST34112012Context *CTX, - const unsigned int digest_size); +extern void GOST34112012Init(GOST34112012Context *CTX, + const unsigned int digest_size); -void GOST34112012Update(GOST34112012Context *CTX, const unsigned char *data, - size_t len); +extern void GOST34112012Update(GOST34112012Context *CTX, + const unsigned char *data, size_t len); -void GOST34112012Final(GOST34112012Context *CTX, unsigned char *digest); +extern void GOST34112012Final(GOST34112012Context *CTX, + unsigned char *digest); -void GOST34112012Cleanup(GOST34112012Context *CTX); +extern void GOST34112012Cleanup(GOST34112012Context *CTX); #endif /* alg-gost3411-2012-core.h */ diff --git a/lib/alg-gost3411-2012-hmac.h b/lib/alg-gost3411-2012-hmac.h index d9fcc8e..314deed 100644 --- a/lib/alg-gost3411-2012-hmac.h +++ b/lib/alg-gost3411-2012-hmac.h @@ -35,11 +35,11 @@ typedef struct unsigned char digest[GOSTR3411_2012_L]; } gost_hmac_256_t; -void +extern void gost_hash256 (const uint8_t *t, size_t n, uint8_t *out32, GOST34112012Context *ctx); -void +extern void gost_hmac256 (const uint8_t *k, size_t n, const uint8_t *t, size_t len, uint8_t *out32, gost_hmac_256_t *gostbuf); diff --git a/lib/alg-hmac-sha1.h b/lib/alg-hmac-sha1.h index c5db9ab..78e08f0 100644 --- a/lib/alg-hmac-sha1.h +++ b/lib/alg-hmac-sha1.h @@ -29,6 +29,7 @@ /* Generate the keyed-hash message authentication code of TEXT and KEY. The resulting HMAC is writen into RESBUF, which should point to 20 bytes of storage. */ -void hmac_sha1_process_data (const uint8_t *text, size_t text_len, - const uint8_t *key, size_t key_len, - void *resbuf); +extern void +hmac_sha1_process_data (const uint8_t *text, size_t text_len, + const uint8_t *key, size_t key_len, + void *resbuf); diff --git a/lib/alg-sha256.h b/lib/alg-sha256.h index b30748b..89beedf 100644 --- a/lib/alg-sha256.h +++ b/lib/alg-sha256.h @@ -58,26 +58,26 @@ typedef struct { * SHA256_Init(ctx): * Initialize the SHA256 context ${ctx}. */ -void SHA256_Init(SHA256_CTX *); +extern void SHA256_Init(SHA256_CTX *); /** * SHA256_Update(ctx, in, len): * Input ${len} bytes from ${in} into the SHA256 context ${ctx}. */ -void SHA256_Update(SHA256_CTX *, const void *, size_t); +extern void SHA256_Update(SHA256_CTX *, const void *, size_t); /** * SHA256_Final(digest, ctx): * Output the SHA256 hash of the data input to the context ${ctx} into the * buffer ${digest}. */ -void SHA256_Final(uint8_t[32], SHA256_CTX *); +extern void SHA256_Final(uint8_t[32], SHA256_CTX *); /** * SHA256_Buf(in, len, digest): * Compute the SHA256 hash of ${len} bytes from ${in} and write it to ${digest}. */ -void SHA256_Buf(const void *, size_t, uint8_t[32]); +extern void SHA256_Buf(const void *, size_t, uint8_t[32]); /* Context structure for HMAC-SHA256 operations. */ typedef struct { @@ -90,34 +90,34 @@ typedef struct { * Initialize the HMAC-SHA256 context ${ctx} with ${Klen} bytes of key from * ${K}. */ -void HMAC_SHA256_Init(HMAC_SHA256_CTX *, const void *, size_t); +extern void HMAC_SHA256_Init(HMAC_SHA256_CTX *, const void *, size_t); /** * HMAC_SHA256_Update(ctx, in, len): * Input ${len} bytes from ${in} into the HMAC-SHA256 context ${ctx}. */ -void HMAC_SHA256_Update(HMAC_SHA256_CTX *, const void *, size_t); +extern void HMAC_SHA256_Update(HMAC_SHA256_CTX *, const void *, size_t); /** * HMAC_SHA256_Final(digest, ctx): * Output the HMAC-SHA256 of the data input to the context ${ctx} into the * buffer ${digest}. */ -void HMAC_SHA256_Final(uint8_t[32], HMAC_SHA256_CTX *); +extern void HMAC_SHA256_Final(uint8_t[32], HMAC_SHA256_CTX *); /** * HMAC_SHA256_Buf(K, Klen, in, len, digest): * Compute the HMAC-SHA256 of ${len} bytes from ${in} using the key ${K} of * length ${Klen}, and write the result to ${digest}. */ -void HMAC_SHA256_Buf(const void *, size_t, const void *, size_t, uint8_t[32]); +extern void HMAC_SHA256_Buf(const void *, size_t, const void *, size_t, uint8_t[32]); /** * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen): * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and * write the output to buf. The value dkLen must be at most 32 * (2^32 - 1). */ -void PBKDF2_SHA256(const uint8_t *, size_t, const uint8_t *, size_t, +extern void PBKDF2_SHA256(const uint8_t *, size_t, const uint8_t *, size_t, uint64_t, uint8_t *, size_t); #endif /* !_SHA256_H_ */ diff --git a/lib/alg-sha512.h b/lib/alg-sha512.h index c2516a9..dc44da0 100644 --- a/lib/alg-sha512.h +++ b/lib/alg-sha512.h @@ -55,27 +55,27 @@ typedef struct { * SHA512_Init(ctx): * Initialize the SHA512 context ${ctx}. */ -void SHA512_Init(SHA512_CTX *); +extern void SHA512_Init(SHA512_CTX *); /** * SHA512_Update(ctx, in, len): * Input ${len} bytes from ${in} into the SHA512 context ${ctx}. */ -void SHA512_Update(SHA512_CTX *, const void *, size_t); +extern void SHA512_Update(SHA512_CTX *, const void *, size_t); /** * SHA512_Final(digest, ctx): * Output the SHA512 hash of the data input to the context ${ctx} into the * buffer ${digest}. */ -void SHA512_Final(unsigned char[MIN_SIZE(SHA512_DIGEST_LENGTH)], +extern void SHA512_Final(unsigned char[MIN_SIZE(SHA512_DIGEST_LENGTH)], SHA512_CTX *); /** * SHA512_Buf(in, len, digest): * Compute the SHA512 hash of ${len} bytes from ${in} and write it to ${digest}. */ -void SHA512_Buf(const void *, size_t, +extern void SHA512_Buf(const void *, size_t, unsigned char[MIN_SIZE(SHA512_DIGEST_LENGTH)]); #endif /* !_SHA512_H_ */ diff --git a/lib/crypt-port.h b/lib/crypt-port.h index 1e4d4b6..0d91da4 100644 --- a/lib/crypt-port.h +++ b/lib/crypt-port.h @@ -383,11 +383,11 @@ extern void crypt_yescrypt_rn (const char *, size_t, const char *, /* We need a prototype for fcrypt for some tests. */ #if ENABLE_OBSOLETE_API -char *fcrypt (const char *key, const char *setting); +extern char *fcrypt (const char *key, const char *setting); #endif /* Utility functions */ -bool get_random_bytes (void *buf, size_t buflen); +extern bool get_random_bytes (void *buf, size_t buflen); extern void gensalt_sha_rn (char tag, size_t maxsalt, unsigned long defcount, unsigned long mincount, unsigned long maxcount,