include/crypto: add a few missing #pragma once directives Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/14096)
diff --git a/include/crypto/aes_platform.h b/include/crypto/aes_platform.h index 1d8c06c..acd263f 100644 --- a/include/crypto/aes_platform.h +++ b/include/crypto/aes_platform.h
@@ -9,6 +9,7 @@ #ifndef OSSL_AES_PLATFORM_H # define OSSL_AES_PLATFORM_H +# pragma once # include "openssl/aes.h"
diff --git a/include/crypto/aria.h b/include/crypto/aria.h index 3bbb30e..dfd0701 100644 --- a/include/crypto/aria.h +++ b/include/crypto/aria.h
@@ -12,6 +12,7 @@ #ifndef OSSL_CRYPTO_ARIA_H # define OSSL_CRYPTO_ARIA_H +# pragma once # include <openssl/opensslconf.h>
diff --git a/include/crypto/asn1.h b/include/crypto/asn1.h index 7284412..7d9dec1 100644 --- a/include/crypto/asn1.h +++ b/include/crypto/asn1.h
@@ -7,7 +7,11 @@ * https://www.openssl.org/source/license.html */ -#include <openssl/asn1.h> +#ifndef OSSL_CRYPTO_ASN1_H +# define OSSL_CRYPTO_ASN1_H +# pragma once + +# include <openssl/asn1.h> /* Internal ASN1 structures and functions: not for application use */ @@ -139,3 +143,5 @@ X509_ALGOR *x509_algor_mgf1_decode(X509_ALGOR *alg); int x509_algor_md_to_mgf1(X509_ALGOR **palg, const EVP_MD *mgf1md); int asn1_time_print_ex(BIO *bp, const ASN1_TIME *tm); + +#endif /* ndef OSSL_CRYPTO_ASN1_H */
diff --git a/include/crypto/asn1_dsa.h b/include/crypto/asn1_dsa.h index df6ca0f..4d2399a 100644 --- a/include/crypto/asn1_dsa.h +++ b/include/crypto/asn1_dsa.h
@@ -9,6 +9,7 @@ #ifndef OSSL_CRYPTO_ASN1_DSA_H # define OSSL_CRYPTO_ASN1_DSA_H +# pragma once #include "internal/packet.h"
diff --git a/include/crypto/async.h b/include/crypto/async.h index e9a89da..6911488 100644 --- a/include/crypto/async.h +++ b/include/crypto/async.h
@@ -7,8 +7,13 @@ * https://www.openssl.org/source/license.html */ -#include <openssl/async.h> +#ifndef OSSL_CRYPTO_ASYNC_H +# define OSSL_CRYPTO_ASYNC_H +# pragma once + +# include <openssl/async.h> int async_init(void); void async_deinit(void); +#endif
diff --git a/include/crypto/bn.h b/include/crypto/bn.h index 4060541..730854d 100644 --- a/include/crypto/bn.h +++ b/include/crypto/bn.h
@@ -9,6 +9,7 @@ #ifndef OSSL_CRYPTO_BN_H # define OSSL_CRYPTO_BN_H +# pragma once # include <openssl/bn.h> # include <limits.h>
diff --git a/include/crypto/bn_conf.h.in b/include/crypto/bn_conf.h.in index c8fdf36..9d244d5 100644 --- a/include/crypto/bn_conf.h.in +++ b/include/crypto/bn_conf.h.in
@@ -10,6 +10,7 @@ #ifndef OSSL_CRYPTO_BN_CONF_H # define OSSL_CRYPTO_BN_CONF_H +# pragma once /* * The contents of this file are not used in the UEFI build, as
diff --git a/include/crypto/chacha.h b/include/crypto/chacha.h index 77cfd3b..b789515 100644 --- a/include/crypto/chacha.h +++ b/include/crypto/chacha.h
@@ -9,6 +9,7 @@ #ifndef OSSL_CRYPTO_CHACHA_H #define OSSL_CRYPTO_CHACHA_H +# pragma once #include <stddef.h>
diff --git a/include/crypto/cmll_platform.h b/include/crypto/cmll_platform.h index c82cf9f..34fac61 100644 --- a/include/crypto/cmll_platform.h +++ b/include/crypto/cmll_platform.h
@@ -9,6 +9,7 @@ #ifndef OSSL_CMLL_PLATFORM_H # define OSSL_CMLL_PLATFORM_H +# pragma once # if defined(CMLL_ASM) && (defined(__sparc) || defined(__sparc__))
diff --git a/include/crypto/cms.h b/include/crypto/cms.h index 67263fa..5a58407 100644 --- a/include/crypto/cms.h +++ b/include/crypto/cms.h
@@ -7,7 +7,11 @@ * https://www.openssl.org/source/license.html */ -#ifndef OPENSSL_NO_CMS +#ifndef OSSL_CRYPTO_CMS_H +# define OSSL_CRYPTO_CMS_H +# pragma once + +# ifndef OPENSSL_NO_CMS /* internal CMS-ESS related stuff */ @@ -18,4 +22,6 @@ ESS_SIGNING_CERT_V2 **psc); int cms_signerinfo_get_signing_cert(CMS_SignerInfo *si, ESS_SIGNING_CERT **psc); +# endif /* OPENSSL_NO_CMS */ + #endif
diff --git a/include/crypto/cryptlib.h b/include/crypto/cryptlib.h index 8fd04fa..d70cd78 100644 --- a/include/crypto/cryptlib.h +++ b/include/crypto/cryptlib.h
@@ -7,8 +7,12 @@ * https://www.openssl.org/source/license.html */ -#include <openssl/core.h> -#include "internal/cryptlib.h" +#ifndef OSSL_CRYPTO_CRYPTLIB_H +# define OSSL_CRYPTO_CRYPTLIB_H +# pragma once + +# include <openssl/core.h> +# include "internal/cryptlib.h" /* This file is not scanned by mkdef.pl, whereas cryptlib.h is */ @@ -32,3 +36,5 @@ int ossl_crypto_alloc_ex_data_intern(int class_index, void *obj, CRYPTO_EX_DATA *ad, int idx); + +#endif /* OSSL_CRYPTO_CRYPTLIB_H */
diff --git a/include/crypto/ctype.h b/include/crypto/ctype.h index f3ab678..7117281 100644 --- a/include/crypto/ctype.h +++ b/include/crypto/ctype.h
@@ -20,6 +20,7 @@ */ #ifndef OSSL_CRYPTO_CTYPE_H # define OSSL_CRYPTO_CTYPE_H +# pragma once # define CTYPE_MASK_lower 0x1 # define CTYPE_MASK_upper 0x2
diff --git a/include/crypto/decoder.h b/include/crypto/decoder.h index f19e8bf..5d055fe 100644 --- a/include/crypto/decoder.h +++ b/include/crypto/decoder.h
@@ -9,6 +9,7 @@ #ifndef OSSL_CRYPTO_DECODER_H # define OSSL_CRYPTO_DECODER_H +# pragma once # include <openssl/decoder.h>
diff --git a/include/crypto/des_platform.h b/include/crypto/des_platform.h index 28e319f..18bd2f8 100644 --- a/include/crypto/des_platform.h +++ b/include/crypto/des_platform.h
@@ -9,6 +9,7 @@ #ifndef OSSL_DES_PLATFORM_H # define OSSL_DES_PLATFORM_H +# pragma once # if defined(DES_ASM) && (defined(__sparc) || defined(__sparc__))
diff --git a/include/crypto/dh.h b/include/crypto/dh.h index 290cc7c..91a2db2 100644 --- a/include/crypto/dh.h +++ b/include/crypto/dh.h
@@ -7,10 +7,14 @@ * https://www.openssl.org/source/license.html */ -#include <openssl/core.h> -#include <openssl/params.h> -#include <openssl/dh.h> -#include "internal/ffc.h" +#ifndef OSSL_CRYPTO_DH_H +# define OSSL_CRYPTO_DH_H +# pragma once + +# include <openssl/core.h> +# include <openssl/params.h> +# include <openssl/dh.h> +# include "internal/ffc.h" DH *dh_new_by_nid_ex(OSSL_LIB_CTX *libctx, int nid); DH *dh_new_ex(OSSL_LIB_CTX *libctx); @@ -46,3 +50,5 @@ const char *cek_alg, const unsigned char *ukm, size_t ukmlen, const EVP_MD *md, OSSL_LIB_CTX *libctx, const char *propq); + +#endif /* OSSL_CRYPTO_DH_H */
diff --git a/include/crypto/dsa.h b/include/crypto/dsa.h index 775a83c..8d282ab 100644 --- a/include/crypto/dsa.h +++ b/include/crypto/dsa.h
@@ -7,9 +7,13 @@ * https://www.openssl.org/source/license.html */ -#include <openssl/core.h> -#include <openssl/dsa.h> -#include "internal/ffc.h" +#ifndef OSSL_CRYPTO_DSAERR_H +# define OSSL_CRYPTO_DSAERR_H +# pragma once + +# include <openssl/core.h> +# include <openssl/dsa.h> +# include "internal/ffc.h" #define DSA_PARAMGEN_TYPE_FIPS_186_4 0 /* Use FIPS186-4 standard */ #define DSA_PARAMGEN_TYPE_FIPS_186_2 1 /* Use legacy FIPS186-2 standard */ @@ -34,3 +38,5 @@ int dsa_check_pub_key_partial(const DSA *dsa, const BIGNUM *pub_key, int *ret); int dsa_check_priv_key(const DSA *dsa, const BIGNUM *priv_key, int *ret); int dsa_check_pairwise(const DSA *dsa); + +#endif
diff --git a/include/crypto/dso_conf.h.in b/include/crypto/dso_conf.h.in index fd0e16b..eba3deb 100644 --- a/include/crypto/dso_conf.h.in +++ b/include/crypto/dso_conf.h.in
@@ -10,6 +10,8 @@ #ifndef OSSL_CRYPTO_DSO_CONF_H # define OSSL_CRYPTO_DSO_CONF_H +# pragma once + {- # The DSO code currently always implements all functions so that no # applications will have to worry about that from a compilation point # of view. However, the "method"s may return zero unless that platform
diff --git a/include/crypto/ec.h b/include/crypto/ec.h index 80f76d6..682311b 100644 --- a/include/crypto/ec.h +++ b/include/crypto/ec.h
@@ -11,6 +11,8 @@ #ifndef OSSL_CRYPTO_EC_H # define OSSL_CRYPTO_EC_H +# pragma once + # include <openssl/opensslconf.h> # include <openssl/evp.h>
diff --git a/include/crypto/ecx.h b/include/crypto/ecx.h index df04cdb..663cdfc 100644 --- a/include/crypto/ecx.h +++ b/include/crypto/ecx.h
@@ -11,6 +11,8 @@ #ifndef OSSL_CRYPTO_ECX_H # define OSSL_CRYPTO_ECX_H +# pragma once + # include <openssl/opensslconf.h> # ifndef OPENSSL_NO_EC
diff --git a/include/crypto/err.h b/include/crypto/err.h index b59367e..9e72b56 100644 --- a/include/crypto/err.h +++ b/include/crypto/err.h
@@ -9,6 +9,7 @@ #ifndef OSSL_CRYPTO_ERR_H # define OSSL_CRYPTO_ERR_H +# pragma once int err_load_ERR_strings_int(void); int err_load_crypto_strings_int(void);
diff --git a/include/crypto/ess.h b/include/crypto/ess.h index 6ae9a81..74833f2 100644 --- a/include/crypto/ess.h +++ b/include/crypto/ess.h
@@ -7,6 +7,10 @@ * https://www.openssl.org/source/license.html */ +#ifndef OSSL_CRYPTO_ESS_H +# define OSSL_CRYPTO_ESS_H +# pragma once + /* internal ESS related stuff */ ESS_SIGNING_CERT *ESS_SIGNING_CERT_get(PKCS7_SIGNER_INFO *si); @@ -89,3 +93,5 @@ STACK_OF(ESS_CERT_ID_V2) *cert_ids; STACK_OF(POLICYINFO) *policy_info; }; + +#endif /* OSSL_CRYPTO_ESS_H */
diff --git a/include/crypto/evp.h b/include/crypto/evp.h index 60f07c7..b78535a 100644 --- a/include/crypto/evp.h +++ b/include/crypto/evp.h
@@ -7,10 +7,14 @@ * https://www.openssl.org/source/license.html */ -#include <openssl/evp.h> -#include <openssl/core_dispatch.h> -#include "internal/refcount.h" -#include "crypto/ecx.h" +#ifndef OSSL_CRYPTO_EVP_H +# define OSSL_CRYPTO_EVP_H +# pragma once + +# include <openssl/evp.h> +# include <openssl/core_dispatch.h> +# include "internal/refcount.h" +# include "crypto/ecx.h" /* * Don't free up md_ctx->pctx in EVP_MD_CTX_reset, use the reserved flag @@ -793,10 +797,10 @@ /* Pulling defines out of C source files */ -#define EVP_RC4_KEY_SIZE 16 -#ifndef TLS1_1_VERSION -# define TLS1_1_VERSION 0x0302 -#endif +# define EVP_RC4_KEY_SIZE 16 +# ifndef TLS1_1_VERSION +# define TLS1_1_VERSION 0x0302 +# endif void evp_encode_ctx_set_flags(EVP_ENCODE_CTX *ctx, unsigned int flags); @@ -816,7 +820,7 @@ const EVP_MD *digest, int keylen, unsigned char *out, OSSL_LIB_CTX *libctx, const char *propq); -#ifndef FIPS_MODULE +# ifndef FIPS_MODULE /* * Internal helpers for stricter EVP_PKEY_CTX_{set,get}_params(). * @@ -842,9 +846,12 @@ int evp_pkey_ctx_get1_id_len_prov(EVP_PKEY_CTX *ctx, size_t *id_len); int evp_pkey_ctx_use_cached_data(EVP_PKEY_CTX *ctx); -#endif /* !defined(FIPS_MODULE) */ +# endif /* !defined(FIPS_MODULE) */ + void evp_method_store_flush(OSSL_LIB_CTX *libctx); int evp_set_default_properties_int(OSSL_LIB_CTX *libctx, const char *propq, int loadconfig); void evp_md_ctx_clear_digest(EVP_MD_CTX *ctx, int force); + +#endif /* OSSL_CRYPTO_EVP_H */
diff --git a/include/crypto/lhash.h b/include/crypto/lhash.h index 9629936..d7bd2c1 100644 --- a/include/crypto/lhash.h +++ b/include/crypto/lhash.h
@@ -9,7 +9,8 @@ #ifndef OSSL_CRYPTO_LHASH_H # define OSSL_CRYPTO_LHASH_H +# pragma once unsigned long openssl_lh_strcasehash(const char *); -#endif +#endif /* OSSL_CRYPTO_LHASH_H */
diff --git a/include/crypto/pem.h b/include/crypto/pem.h index e3ec8b2..24e4787 100644 --- a/include/crypto/pem.h +++ b/include/crypto/pem.h
@@ -9,6 +9,7 @@ #ifndef OSSL_INTERNAL_PEM_H # define OSSL_INTERNAL_PEM_H +# pragma once # include <openssl/pem.h>
diff --git a/include/crypto/pkcs7.h b/include/crypto/pkcs7.h index 60e01e5..17bb3cd 100644 --- a/include/crypto/pkcs7.h +++ b/include/crypto/pkcs7.h
@@ -7,4 +7,10 @@ * https://www.openssl.org/source/license.html */ +#ifndef OSSL_CRYPTO_PKCS7_H +# define OSSL_CRYPTO_PKCS7_H +# pragma once + void pkcs7_resolve_libctx(PKCS7 *p7); + +#endif
diff --git a/include/crypto/poly1305.h b/include/crypto/poly1305.h index a73c231..86317bc 100644 --- a/include/crypto/poly1305.h +++ b/include/crypto/poly1305.h
@@ -7,6 +7,10 @@ * https://www.openssl.org/source/license.html */ +#ifndef OSSL_CRYPTO_POLY1305_H +# define OSSL_CRYPTO_POLY1305_H +# pragma once + #include <stddef.h> #define POLY1305_BLOCK_SIZE 16 @@ -38,3 +42,5 @@ void Poly1305_Init(POLY1305 *ctx, const unsigned char key[32]); void Poly1305_Update(POLY1305 *ctx, const unsigned char *inp, size_t len); void Poly1305_Final(POLY1305 *ctx, unsigned char mac[16]); + +#endif /* OSSL_CRYPTO_POLY1305_H */
diff --git a/include/crypto/punycode.h b/include/crypto/punycode.h index ab31494..5b3074a 100644 --- a/include/crypto/punycode.h +++ b/include/crypto/punycode.h
@@ -9,7 +9,7 @@ #ifndef OSSL_CRYPTO_PUNYCODE_H # define OSSL_CRYPTO_PUNYCODE_H - +# pragma once int ossl_punycode_decode ( const char *pEncoded,
diff --git a/include/crypto/rand.h b/include/crypto/rand.h index c870245..89505aa 100644 --- a/include/crypto/rand.h +++ b/include/crypto/rand.h
@@ -17,6 +17,7 @@ #ifndef OSSL_CRYPTO_RAND_H # define OSSL_CRYPTO_RAND_H +# pragma once # include <openssl/rand.h> # include "crypto/rand_pool.h"
diff --git a/include/crypto/rand_pool.h b/include/crypto/rand_pool.h index 9c5c92e..26e65c0 100644 --- a/include/crypto/rand_pool.h +++ b/include/crypto/rand_pool.h
@@ -9,6 +9,7 @@ #ifndef OSSL_PROVIDER_RAND_POOL_H # define OSSL_PROVIDER_RAND_POOL_H +# pragma once # include <stdio.h> # include <openssl/rand.h>
diff --git a/include/crypto/rsa.h b/include/crypto/rsa.h index 599978d..62087b3 100644 --- a/include/crypto/rsa.h +++ b/include/crypto/rsa.h
@@ -9,6 +9,7 @@ #ifndef OSSL_INTERNAL_RSA_H # define OSSL_INTERNAL_RSA_H +# pragma once # include <openssl/core.h> # include <openssl/rsa.h>
diff --git a/include/crypto/security_bits.h b/include/crypto/security_bits.h index c62d89b..90cb7d6 100644 --- a/include/crypto/security_bits.h +++ b/include/crypto/security_bits.h
@@ -9,6 +9,7 @@ #ifndef OSSL_SECURITY_BITS_H # define OSSL_SECURITY_BITS_H +# pragma once uint16_t ifc_ffc_compute_security_bits(int n);
diff --git a/include/crypto/sha.h b/include/crypto/sha.h index 9a86599..7c0276a 100644 --- a/include/crypto/sha.h +++ b/include/crypto/sha.h
@@ -10,6 +10,7 @@ #ifndef OSSL_CRYPTO_SHA_H # define OSSL_CRYPTO_SHA_H +# pragma once # include <openssl/opensslconf.h>
diff --git a/include/crypto/siphash.h b/include/crypto/siphash.h index 1575141..bb4d614 100644 --- a/include/crypto/siphash.h +++ b/include/crypto/siphash.h
@@ -7,12 +7,16 @@ * https://www.openssl.org/source/license.html */ -#include <stddef.h> +#ifndef OSSL_CRYPTO_SIPHASH_H +# define OSSL_CRYPTO_SIPHASH_H +# pragma once -#define SIPHASH_BLOCK_SIZE 8 -#define SIPHASH_KEY_SIZE 16 -#define SIPHASH_MIN_DIGEST_SIZE 8 -#define SIPHASH_MAX_DIGEST_SIZE 16 +# include <stddef.h> + +# define SIPHASH_BLOCK_SIZE 8 +# define SIPHASH_KEY_SIZE 16 +# define SIPHASH_MIN_DIGEST_SIZE 8 +# define SIPHASH_MAX_DIGEST_SIZE 16 typedef struct siphash_st SIPHASH; @@ -23,3 +27,5 @@ int crounds, int drounds); void SipHash_Update(SIPHASH *ctx, const unsigned char *in, size_t inlen); int SipHash_Final(SIPHASH *ctx, unsigned char *out, size_t outlen); + +#endif
diff --git a/include/crypto/sm2.h b/include/crypto/sm2.h index 78fd4db..2bd0af0 100644 --- a/include/crypto/sm2.h +++ b/include/crypto/sm2.h
@@ -11,6 +11,8 @@ #ifndef OSSL_CRYPTO_SM2_H # define OSSL_CRYPTO_SM2_H +# pragma once + # include <openssl/opensslconf.h> # ifndef OPENSSL_NO_SM2
diff --git a/include/crypto/sm4.h b/include/crypto/sm4.h index fb5253d..87be6da 100644 --- a/include/crypto/sm4.h +++ b/include/crypto/sm4.h
@@ -10,6 +10,7 @@ #ifndef OSSL_CRYPTO_SM4_H # define OSSL_CRYPTO_SM4_H +# pragma once # include <openssl/opensslconf.h> # include <openssl/e_os2.h>
diff --git a/include/crypto/sparse_array.h b/include/crypto/sparse_array.h index a8031cd..ee49105 100644 --- a/include/crypto/sparse_array.h +++ b/include/crypto/sparse_array.h
@@ -10,6 +10,7 @@ #ifndef OSSL_CRYPTO_SPARSE_ARRAY_H # define OSSL_CRYPTO_SPARSE_ARRAY_H +# pragma once # include <openssl/e_os2.h>
diff --git a/include/crypto/store.h b/include/crypto/store.h index 8bd2bc0..72d5a01 100644 --- a/include/crypto/store.h +++ b/include/crypto/store.h
@@ -9,6 +9,7 @@ #ifndef OSSL_CRYPTO_STORE_H # define OSSL_CRYPTO_STORE_H +# pragma once # include <openssl/bio.h> # include <openssl/store.h>
diff --git a/include/crypto/x509.h b/include/crypto/x509.h index 542a3d6..93cb814 100644 --- a/include/crypto/x509.h +++ b/include/crypto/x509.h
@@ -7,9 +7,13 @@ * https://www.openssl.org/source/license.html */ -#include "internal/refcount.h" -#include <openssl/asn1.h> -#include <openssl/x509.h> +#ifndef OSSL_CRYPTO_X509_H +# define OSSL_CRYPTO_X509_H +# pragma once + +# include "internal/refcount.h" +# include <openssl/asn1.h> +# include <openssl/x509.h> /* Internal X509 structures and functions: not for application use */ @@ -320,3 +324,5 @@ const X509_PUBKEY *key); /* Calculate default key identifier according to RFC 5280 section 4.2.1.2 (1) */ ASN1_OCTET_STRING *x509_pubkey_hash(X509_PUBKEY *pubkey); + +#endif