From 4d19979872807b1a0e2bfff01ef9bca106fc50bf Mon Sep 17 00:00:00 2001 From: Thomas Joly Date: Wed, 20 Sep 2023 10:23:47 +0200 Subject: [PATCH] Fix missing header guard --- lib_cxng/include/lcx_aead.h | 7 ++++--- lib_cxng/include/lcx_aes.h | 8 ++++---- lib_cxng/include/lcx_aes_gcm.h | 8 +++++--- lib_cxng/include/lcx_blake2.h | 7 ++++--- lib_cxng/include/lcx_chacha.h | 6 ++++-- lib_cxng/include/lcx_chacha_poly.h | 7 ++++--- lib_cxng/include/lcx_crc.h | 8 ++++---- lib_cxng/include/lcx_ecdh.h | 4 ++-- lib_cxng/include/lcx_ecdsa.h | 8 ++++---- lib_cxng/include/lcx_ecfp.h | 7 ++++--- lib_cxng/include/lcx_eddsa.h | 10 +++++----- lib_cxng/include/lcx_hash.h | 8 ++++---- lib_cxng/include/lcx_hmac.h | 7 ++++--- lib_cxng/include/lcx_math.h | 8 ++++---- lib_cxng/include/lcx_pbkdf2.h | 8 ++++---- lib_cxng/include/lcx_poly1305.h | 6 ++++-- lib_cxng/include/lcx_ripemd160.h | 8 ++++---- lib_cxng/include/lcx_rng.h | 8 ++++---- lib_cxng/include/lcx_sha256.h | 8 ++++---- lib_cxng/include/lcx_sha3.h | 8 ++++---- lib_cxng/include/lcx_sha512.h | 8 ++++---- lib_cxng/src/cx_blake2.h | 7 ++++--- lib_cxng/src/cx_blake2b.h | 8 ++++---- lib_cxng/src/cx_crc.h | 8 ++++---- lib_cxng/src/cx_ecfp.h | 8 ++++---- lib_cxng/src/cx_eddsa.h | 8 ++++---- lib_cxng/src/cx_hash.h | 8 ++++---- lib_cxng/src/cx_pbkdf2.h | 7 ++++--- lib_cxng/src/cx_poly1305.h | 6 ++++-- lib_cxng/src/cx_ripemd160.h | 20 +++++++++++++++++++- lib_cxng/src/cx_rng.h | 7 ++++--- lib_cxng/src/cx_rng_rfc6979.h | 7 ++++--- lib_cxng/src/cx_sha256.h | 23 +++++++++++++++++++++-- lib_cxng/src/cx_sha3.h | 24 +++++++++++++++++++++--- lib_cxng/src/cx_sha512.h | 24 +++++++++++++++++++++--- lib_cxng/src/cx_utils.h | 4 ++-- 36 files changed, 208 insertions(+), 118 deletions(-) diff --git a/lib_cxng/include/lcx_aead.h b/lib_cxng/include/lcx_aead.h index dfaead27f..1c8d7c1e7 100644 --- a/lib_cxng/include/lcx_aead.h +++ b/lib_cxng/include/lcx_aead.h @@ -31,11 +31,11 @@ * @version 1.0 **/ -#if defined(HAVE_AEAD) - #ifndef LCX_AEAD_H #define LCX_AEAD_H +#if defined(HAVE_AEAD) + #include "cx_errors.h" #include #if defined(HAVE_AES_GCM) @@ -350,5 +350,6 @@ cx_err_t cx_aead_decrypt(cx_aead_context_t *ctx, const uint8_t *tag, size_t tag_len); -#endif #endif // HAVE_AEAD + +#endif // LCX_AED_H diff --git a/lib_cxng/include/lcx_aes.h b/lib_cxng/include/lcx_aes.h index 017dcaa3b..b1f740e9f 100644 --- a/lib_cxng/include/lcx_aes.h +++ b/lib_cxng/include/lcx_aes.h @@ -28,11 +28,11 @@ * for more details. */ -#ifdef HAVE_AES - #ifndef LCX_AES_H #define LCX_AES_H +#ifdef HAVE_AES + #include "cx_errors.h" #include "lcx_wrappers.h" #include "lcx_common.h" @@ -234,6 +234,6 @@ cx_err_t cx_aes_enc_block(const cx_aes_key_t *key, const uint8_t *inblock, uint8 */ cx_err_t cx_aes_dec_block(const cx_aes_key_t *key, const uint8_t *inblock, uint8_t *outblock); -#endif - #endif // HAVE_AES + +#endif // LCX_AES_H diff --git a/lib_cxng/include/lcx_aes_gcm.h b/lib_cxng/include/lcx_aes_gcm.h index d7fd233ab..2e3454522 100644 --- a/lib_cxng/include/lcx_aes_gcm.h +++ b/lib_cxng/include/lcx_aes_gcm.h @@ -30,11 +30,11 @@ * @version 1.0 **/ -#if defined(HAVE_AES) && defined(HAVE_AES_GCM) - #ifndef LCX_AES_GCM_H #define LCX_AES_GCM_H +#if defined(HAVE_AES) && defined(HAVE_AES_GCM) + #include "ox.h" #include @@ -83,5 +83,7 @@ cx_err_t cx_aes_gcm_decrypt_and_auth(cx_aes_gcm_context_t *ctx, const uint8_t *tag, size_t tag_len); cx_err_t cx_aes_gcm_check_tag(cx_aes_gcm_context_t *ctx, const uint8_t *tag, size_t tag_len); -#endif + #endif // HAVE_AES && HAVE_AES_GCM + +#endif // LCX_AES_GCM_H diff --git a/lib_cxng/include/lcx_blake2.h b/lib_cxng/include/lcx_blake2.h index f93a517d0..8a947d09a 100644 --- a/lib_cxng/include/lcx_blake2.h +++ b/lib_cxng/include/lcx_blake2.h @@ -24,10 +24,11 @@ * produces digests of any size between 1 and 64 bytes. It is specified at https://blake2.net. */ -#ifdef HAVE_BLAKE2 #ifndef LCX_BLAKE2_H #define LCX_BLAKE2_H +#ifdef HAVE_BLAKE2 + #include "lcx_wrappers.h" #include "lcx_hash.h" #include @@ -133,6 +134,6 @@ DEPRECATED static inline int cx_blake2b_init2(cx_blake2b_t *hash, return CX_BLAKE2B; } -#endif - #endif // HAVE_BLAKE2 + +#endif // LCX_BLAKE2_H diff --git a/lib_cxng/include/lcx_chacha.h b/lib_cxng/include/lcx_chacha.h index 171fa6a09..259e1a5c9 100644 --- a/lib_cxng/include/lcx_chacha.h +++ b/lib_cxng/include/lcx_chacha.h @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. ********************************************************************************/ -#if defined(HAVE_CHACHA) /** * @file lcx_chacha.h @@ -34,6 +33,8 @@ #ifndef LCX_CHACHA_H #define LCX_CHACHA_H +#if defined(HAVE_CHACHA) + #include "ox.h" #include @@ -159,5 +160,6 @@ cx_err_t cx_chacha_cipher(uint32_t nrounds, uint8_t *output, size_t len); -#endif /* LCX_CHACHA_H */ #endif // HAVE_CHACHA + +#endif // LCX_CHACHA_H diff --git a/lib_cxng/include/lcx_chacha_poly.h b/lib_cxng/include/lcx_chacha_poly.h index 74f2eec87..289ae1f57 100644 --- a/lib_cxng/include/lcx_chacha_poly.h +++ b/lib_cxng/include/lcx_chacha_poly.h @@ -15,8 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. ********************************************************************************/ -#if defined(HAVE_CHACHA_POLY) -#if defined(HAVE_POLY1305) && defined(HAVE_CHACHA) /** * @file lcx_chacha_poly.h @@ -31,6 +29,9 @@ #ifndef LCX_CHACHA_POLY_H #define LCX_CHACHA_POLY_H +#if defined(HAVE_CHACHA_POLY) +#if defined(HAVE_POLY1305) && defined(HAVE_CHACHA) + #include "lcx_chacha.h" #include "lcx_poly1305.h" #include "ox.h" @@ -87,6 +88,6 @@ cx_err_t cx_chachapoly_decrypt_and_auth(cx_chachapoly_context_t *ctx, cx_err_t cx_chachapoly_check_tag(cx_chachapoly_context_t *ctx, const uint8_t *tag, size_t tag_len); -#endif /* LCX_CHACHA_POLY_H */ #endif // HAVE_POLY1305 && HAVE_CHACHA #endif // HAVE_CHACHA_POLY +#endif /* LCX_CHACHA_POLY_H */ diff --git a/lib_cxng/include/lcx_crc.h b/lib_cxng/include/lcx_crc.h index 884d5fb99..98fb545fb 100644 --- a/lib_cxng/include/lcx_crc.h +++ b/lib_cxng/include/lcx_crc.h @@ -23,11 +23,11 @@ * CRC-16 is a variant of CRC, an error-detecting code, with a 16-bit long check value. */ -#ifdef HAVE_CRC - #ifndef LCX_CRC_H #define LCX_CRC_H +#ifdef HAVE_CRC + #include #include @@ -60,6 +60,6 @@ uint16_t cx_crc16(const void *buffer, size_t len); */ uint16_t cx_crc16_update(uint16_t crc, const void *buffer, size_t len); -#endif - #endif // HAVE_CRC + +#endif // LCX_CRC_H diff --git a/lib_cxng/include/lcx_ecdh.h b/lib_cxng/include/lcx_ecdh.h index 77aaa6830..2d19265a1 100644 --- a/lib_cxng/include/lcx_ecdh.h +++ b/lib_cxng/include/lcx_ecdh.h @@ -25,11 +25,11 @@ * are elements of a chosen elliptic curve. */ -#ifdef HAVE_ECDH - #ifndef LCX_ECDH_H #define LCX_ECDH_H +#ifdef HAVE_ECDH + #if defined(HAVE_ECDH) || defined(HAVE_X25519) || defined(HAVE_X448) #include "lcx_wrappers.h" diff --git a/lib_cxng/include/lcx_ecdsa.h b/lib_cxng/include/lcx_ecdsa.h index cd934a5aa..d8be8e305 100644 --- a/lib_cxng/include/lcx_ecdsa.h +++ b/lib_cxng/include/lcx_ecdsa.h @@ -25,11 +25,11 @@ * RFC6979 for more details. */ -#ifdef HAVE_ECDSA - #ifndef LCX_ECDSA_H #define LCX_ECDSA_H +#ifdef HAVE_ECDSA + #include "lcx_wrappers.h" #include "lcx_ecfp.h" @@ -171,6 +171,6 @@ static inline bool cx_ecdsa_verify(const cx_ecfp_public_key_t *pukey, return cx_ecdsa_verify_no_throw(pukey, hash, hash_len, sig, sig_len); } -#endif - #endif // HAVE_ECDSA + +#endif // LCX_ECDSA_H diff --git a/lib_cxng/include/lcx_ecfp.h b/lib_cxng/include/lcx_ecfp.h index 0c8941e22..f8005550f 100644 --- a/lib_cxng/include/lcx_ecfp.h +++ b/lib_cxng/include/lcx_ecfp.h @@ -23,10 +23,11 @@ * Private and public keys initialization and key pair generation based on elliptic curves. */ -#ifdef HAVE_ECC #ifndef LCX_ECFP_H #define LCX_ECFP_H +#ifdef HAVE_ECC + #include "lcx_wrappers.h" #include "lcx_hash.h" #include "ox_ec.h" @@ -549,6 +550,6 @@ DEPRECATED static inline void cx_edward_decompress_point(cx_curve_t curve, uint8 #endif // HAVE_ECC_TWISTED_EDWARDS -#endif - #endif // HAVE_ECC + +#endif // LCX_ECFP_H diff --git a/lib_cxng/include/lcx_eddsa.h b/lib_cxng/include/lcx_eddsa.h index b9212693b..6f1f8d483 100644 --- a/lib_cxng/include/lcx_eddsa.h +++ b/lib_cxng/include/lcx_eddsa.h @@ -25,13 +25,13 @@ * for more details. */ -#ifdef HAVE_EDDSA +#ifndef LCX_EDDSA_H +#define LCX_EDDSA_H #include "lcx_ecfp.h" #include "lcx_wrappers.h" -#ifndef LCX_EDDSA_H -#define LCX_EDDSA_H +#ifdef HAVE_EDDSA /** * @brief Signs a message digest. @@ -211,6 +211,6 @@ void cx_encode_coord(uint8_t *coord, int len, int sign); */ int cx_decode_coord(uint8_t *coord, int len); -#endif - #endif // HAVE_EDDSA + +#endif // LCX_EDDSA_H diff --git a/lib_cxng/include/lcx_hash.h b/lib_cxng/include/lcx_hash.h index d05098366..edede03ee 100644 --- a/lib_cxng/include/lcx_hash.h +++ b/lib_cxng/include/lcx_hash.h @@ -36,11 +36,11 @@ * - SHA512 */ -#ifdef HAVE_HASH - #ifndef LCX_HASH_H #define LCX_HASH_H +#ifdef HAVE_HASH + #include "cx_errors.h" #include "lcx_wrappers.h" #include "lcx_common.h" @@ -235,6 +235,6 @@ cx_err_t cx_hash_update(cx_hash_t *hash, const uint8_t *in, size_t in_len); */ cx_err_t cx_hash_final(cx_hash_t *hash, uint8_t *digest); -#endif - #endif // HAVE_HASH + +#endif // LCX_HASH_H diff --git a/lib_cxng/include/lcx_hmac.h b/lib_cxng/include/lcx_hmac.h index 80010b2b5..0d1204660 100644 --- a/lib_cxng/include/lcx_hmac.h +++ b/lib_cxng/include/lcx_hmac.h @@ -24,11 +24,12 @@ * which involves a hash function and a secret key. It enables * the verification of the integrity and the authenticity of a message. */ -#ifdef HAVE_HMAC #ifndef LCX_HMAC_H #define LCX_HMAC_H +#ifdef HAVE_HMAC + #include "lcx_wrappers.h" #include "lcx_hash.h" #include "lcx_ripemd160.h" @@ -416,6 +417,6 @@ cx_err_t cx_hmac_update(cx_hmac_t *hmac, const uint8_t *in, size_t in_len); */ cx_err_t cx_hmac_final(cx_hmac_t *ctx, uint8_t *out, size_t *out_len); -#endif - #endif // HAVE_HMAC + +#endif // LCX_HMAC_H diff --git a/lib_cxng/include/lcx_math.h b/lib_cxng/include/lcx_math.h index 1cff13894..56c5e8536 100644 --- a/lib_cxng/include/lcx_math.h +++ b/lib_cxng/include/lcx_math.h @@ -21,11 +21,11 @@ * @brief Basic arithmetic. */ -#ifdef HAVE_MATH - #ifndef LCX_MATH_H #define LCX_MATH_H +#ifdef HAVE_MATH + #include "lcx_wrappers.h" #include "ox_bn.h" @@ -562,6 +562,6 @@ static inline bool cx_math_is_zero(const uint8_t *a, size_t len) return 1; } -#endif // LCX_MATH_H - #endif // HAVE_MATH + +#endif // LCX_MATH_H diff --git a/lib_cxng/include/lcx_pbkdf2.h b/lib_cxng/include/lcx_pbkdf2.h index 85615d456..957ae3699 100644 --- a/lib_cxng/include/lcx_pbkdf2.h +++ b/lib_cxng/include/lcx_pbkdf2.h @@ -26,11 +26,11 @@ * It consists in iteratively deriving HMAC. */ -#ifdef HAVE_PBKDF2 - #ifndef LCX_PBKDF2_H #define LCX_PBKDF2_H +#ifdef HAVE_PBKDF2 + #include "lcx_wrappers.h" #include "lcx_hash.h" @@ -118,6 +118,6 @@ DEPRECATED static inline void cx_pbkdf2(cx_md_t md_type, #define cx_pbkdf2_sha512(password, password_len, salt, salt_len, iterations, out, out_len) \ cx_pbkdf2_no_throw(CX_SHA512, password, password_len, salt, salt_len, iterations, out, out_len) -#endif // LCX_PBKDF2_H - #endif // HAVE_PBKDF2 + +#endif // LCX_PBKDF2_H diff --git a/lib_cxng/include/lcx_poly1305.h b/lib_cxng/include/lcx_poly1305.h index 704264ba7..686b9430f 100644 --- a/lib_cxng/include/lcx_poly1305.h +++ b/lib_cxng/include/lcx_poly1305.h @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. ********************************************************************************/ -#if defined(HAVE_POLY1305) /** * @file lcx_poly1305.h @@ -35,6 +34,8 @@ #ifndef LCX_POLY1305_H #define LCX_POLY1305_H +#if defined(HAVE_POLY1305) + #include "ox.h" #include @@ -49,5 +50,6 @@ typedef struct { size_t block_len; ///< The number of bytes stored in 'block' } cx_poly1305_context_t; -#endif /* LCX_POLY1305_H */ #endif // HAVE_POLY1305 + +#endif // LCX_POLY1305_H diff --git a/lib_cxng/include/lcx_ripemd160.h b/lib_cxng/include/lcx_ripemd160.h index 1ca99eaf1..d8c18cdcb 100644 --- a/lib_cxng/include/lcx_ripemd160.h +++ b/lib_cxng/include/lcx_ripemd160.h @@ -24,11 +24,11 @@ * "https://homes.esat.kuleuven.be/~bosselae/ripemd160.html"> RIPEMD-160 for more details. */ -#ifdef HAVE_RIPEMD160 - #ifndef LCX_RIPEMD160_H #define LCX_RIPEMD160_H +#ifdef HAVE_RIPEMD160 + #include "lcx_wrappers.h" #include "lcx_hash.h" @@ -90,6 +90,6 @@ static inline int cx_ripemd160_init(cx_ripemd160_t *hash) */ size_t cx_hash_ripemd160(const uint8_t *in, size_t in_len, uint8_t *out, size_t out_len); -#endif - #endif // HAVE_RIPEMD160 + +#endif // LCX_RIPEMD160_H diff --git a/lib_cxng/include/lcx_rng.h b/lib_cxng/include/lcx_rng.h index 087273862..f154c9206 100644 --- a/lib_cxng/include/lcx_rng.h +++ b/lib_cxng/include/lcx_rng.h @@ -25,11 +25,11 @@ * random bytes. The random number can also be generated within a specific range. */ -#ifdef HAVE_RNG - #ifndef LCX_RNG_H #define LCX_RNG_H +#ifdef HAVE_RNG + #include "lcx_wrappers.h" #include "lcx_hash.h" @@ -157,6 +157,6 @@ cx_err_t cx_rng_rfc6979(cx_md_t hash_id, uint8_t *out, size_t out_len); -#endif // LCX_RNG_H - #endif // HAVE_RNG + +#endif // LCX_RNG_H diff --git a/lib_cxng/include/lcx_sha256.h b/lib_cxng/include/lcx_sha256.h index d1472c5a5..95cb957c6 100644 --- a/lib_cxng/include/lcx_sha256.h +++ b/lib_cxng/include/lcx_sha256.h @@ -27,11 +27,11 @@ * for more details. */ -#if defined(HAVE_SHA256) || defined(HAVE_SHA224) - #ifndef LCX_SHA256_H #define LCX_SHA256_H +#if defined(HAVE_SHA256) || defined(HAVE_SHA224) + #include "lcx_wrappers.h" #include "lcx_hash.h" #include @@ -124,6 +124,6 @@ static inline int cx_sha256_init(cx_sha256_t *hash) */ size_t cx_hash_sha256(const uint8_t *in, size_t len, uint8_t *out, size_t out_len); -#endif - #endif // defined(HAVE_SHA256) || defined(HAVE_SHA224) + +#endif // LCX_SHA256_H diff --git a/lib_cxng/include/lcx_sha3.h b/lib_cxng/include/lcx_sha3.h index 50c1573d1..e55593d51 100644 --- a/lib_cxng/include/lcx_sha3.h +++ b/lib_cxng/include/lcx_sha3.h @@ -26,11 +26,11 @@ * for more details. */ -#ifdef HAVE_SHA3 - #ifndef LCX_SHA3_H #define LCX_SHA3_H +#ifdef HAVE_SHA3 + #include "lcx_common.h" #include "lcx_hash.h" #include @@ -210,6 +210,6 @@ DEPRECATED static inline int cx_sha3_xof_init(cx_sha3_t *hash, } } -#endif - #endif // HAVE_SHA3 + +#endif // LCX_SHA3_H diff --git a/lib_cxng/include/lcx_sha512.h b/lib_cxng/include/lcx_sha512.h index 4b9790102..fe558dd12 100644 --- a/lib_cxng/include/lcx_sha512.h +++ b/lib_cxng/include/lcx_sha512.h @@ -27,11 +27,11 @@ * for more details. */ -#if defined(HAVE_SHA384) || defined(HAVE_SHA512) - #ifndef LCX_SHA512_H #define LCX_SHA512_H +#if defined(HAVE_SHA384) || defined(HAVE_SHA512) + /** SHA-384 message digest size */ #define CX_SHA384_SIZE 48 /** SHA-512 message digest size */ @@ -113,6 +113,6 @@ static inline int cx_sha512_init(cx_sha512_t *hash) */ size_t cx_hash_sha512(const uint8_t *in, size_t in_len, uint8_t *out, size_t out_len); -#endif - #endif // defined(HAVE_SHA384) || defined(HAVE_SHA512) + +#endif // LCX_SHA512_H diff --git a/lib_cxng/src/cx_blake2.h b/lib_cxng/src/cx_blake2.h index d5e957418..c2a4f9bc8 100644 --- a/lib_cxng/src/cx_blake2.h +++ b/lib_cxng/src/cx_blake2.h @@ -12,11 +12,12 @@ More information about the BLAKE2 hash function can be found at https://blake2.net. */ -#ifdef HAVE_BLAKE2 #ifndef CX_BLAKE2_H #define CX_BLAKE2_H +#ifdef HAVE_BLAKE2 + #include "lcx_blake2.h" #include #include @@ -213,6 +214,6 @@ int blake2(void *out, size_t outlen, const void *in, size_t inlen, const void *k } #endif -#endif - #endif // HAVE_BLAKE2 + +#endif // CX_BLAKE2_H diff --git a/lib_cxng/src/cx_blake2b.h b/lib_cxng/src/cx_blake2b.h index e8657ed13..ddabd5d9a 100644 --- a/lib_cxng/src/cx_blake2b.h +++ b/lib_cxng/src/cx_blake2b.h @@ -16,11 +16,11 @@ * limitations under the License. ********************************************************************************/ -#ifdef HAVE_BLAKE2 - #ifndef CX_BLAKE2B_H #define CX_BLAKE2B_H +#ifdef HAVE_BLAKE2 + #include "lcx_wrappers.h" #include "lcx_blake2.h" #include @@ -41,6 +41,6 @@ struct cx_xblake_s { }; typedef struct cx_xblake_s cx_xblake_t; -#endif // CX_BLAKE2B_H - #endif // HAVE_BLAKE2 + +#endif // CX_BLAKE2B_H diff --git a/lib_cxng/src/cx_crc.h b/lib_cxng/src/cx_crc.h index ac1da5691..12fcda7aa 100644 --- a/lib_cxng/src/cx_crc.h +++ b/lib_cxng/src/cx_crc.h @@ -16,16 +16,16 @@ * limitations under the License. ********************************************************************************/ -#ifdef HAVE_CRC - #ifndef CX_CRC_H #define CX_CRC_H +#ifdef HAVE_CRC + #include #include uint32_t cx_crc32(const void *buf, size_t len); -#endif +#endif // HAVE_CRC -#endif +#endif // CX_CRC_H diff --git a/lib_cxng/src/cx_ecfp.h b/lib_cxng/src/cx_ecfp.h index 46fd5a8b9..b344655f1 100644 --- a/lib_cxng/src/cx_ecfp.h +++ b/lib_cxng/src/cx_ecfp.h @@ -16,11 +16,11 @@ * limitations under the License. ********************************************************************************/ -#ifdef HAVE_ECC - #ifndef CX_ECFP_H #define CX_ECFP_H +#ifdef HAVE_ECC + #include #include #include "lcx_ecfp.h" @@ -49,6 +49,6 @@ int cx_ecfp_decode_sig_der(const uint8_t *sig, const uint8_t **s, size_t *s_len); -#endif // CX_ECFP_H - #endif // HAVE_ECC + +#endif // CX_ECFP_H diff --git a/lib_cxng/src/cx_eddsa.h b/lib_cxng/src/cx_eddsa.h index e611f8e7d..bec1c4ee9 100644 --- a/lib_cxng/src/cx_eddsa.h +++ b/lib_cxng/src/cx_eddsa.h @@ -16,11 +16,11 @@ * limitations under the License. ********************************************************************************/ -#ifdef HAVE_EDDSA - #ifndef CX_EDDSA_H #define CX_EDDSA_H +#ifdef HAVE_EDDSA + cx_err_t cx_eddsa_get_public_key_internal(const cx_ecfp_private_key_t *pv_key, cx_md_t hashID, cx_ecfp_public_key_t *pu_key, @@ -30,6 +30,6 @@ cx_err_t cx_eddsa_get_public_key_internal(const cx_ecfp_private_key_t *pv_key, size_t h_len, uint8_t *scal /*temp uint8[114]*/); -#endif +#endif // HAVE_EDDSA -#endif +#endif // CX_EDDSA_H diff --git a/lib_cxng/src/cx_hash.h b/lib_cxng/src/cx_hash.h index 9eea396f3..06f60953c 100644 --- a/lib_cxng/src/cx_hash.h +++ b/lib_cxng/src/cx_hash.h @@ -16,11 +16,11 @@ * limitations under the License. ********************************************************************************/ -#ifdef HAVE_HASH - #ifndef CX_HASH_H #define CX_HASH_H +#ifdef HAVE_HASH + #include "lcx_hash.h" #include @@ -52,6 +52,6 @@ const cx_hash_info_t *cx_hash_get_info(cx_md_t md_type); */ void cx_hash_destroy(cx_hash_t *hash_ctx); -#endif - #endif // HAVE_HASH + +#endif // CX_HASH_H diff --git a/lib_cxng/src/cx_pbkdf2.h b/lib_cxng/src/cx_pbkdf2.h index 183e1bbc7..e14eb6e0a 100644 --- a/lib_cxng/src/cx_pbkdf2.h +++ b/lib_cxng/src/cx_pbkdf2.h @@ -16,11 +16,11 @@ * limitations under the License. ********************************************************************************/ -#ifdef HAVE_PBKDF2 - #ifndef CX_PBKDF2_H #define CX_PBKDF2_H +#ifdef HAVE_PBKDF2 + #include "lcx_hmac.h" #include @@ -63,5 +63,6 @@ cx_err_t cx_pbkdf2_hmac(cx_md_t md_type, uint8_t *key, size_t key_len); -#endif // CX_PBKDF2_H #endif // HAVE_PBKDF2 + +#endif // CX_PBKDF2_H diff --git a/lib_cxng/src/cx_poly1305.h b/lib_cxng/src/cx_poly1305.h index c85ef272f..19d6202ed 100644 --- a/lib_cxng/src/cx_poly1305.h +++ b/lib_cxng/src/cx_poly1305.h @@ -15,11 +15,12 @@ * See the License for the specific language governing permissions and * limitations under the License. ********************************************************************************/ -#if defined(HAVE_POLY1305) #ifndef CX_POLY1305_H #define CX_POLY1305_H +#if defined(HAVE_POLY1305) + #include "lcx_poly1305.h" #include "ox.h" #include @@ -108,5 +109,6 @@ cx_err_t cx_poly1305_finish(cx_poly1305_context_t *ctx, uint8_t *tag); */ cx_err_t cx_poly1305_mac(const uint8_t *key, const uint8_t *input, size_t in_len, uint8_t *tag); -#endif /* CX_POLY1305_H */ #endif // HAVE_POLY1305 + +#endif // CX_POLY1305_H diff --git a/lib_cxng/src/cx_ripemd160.h b/lib_cxng/src/cx_ripemd160.h index 96621601a..4736f40ae 100644 --- a/lib_cxng/src/cx_ripemd160.h +++ b/lib_cxng/src/cx_ripemd160.h @@ -1,8 +1,26 @@ -#ifdef HAVE_RIPEMD160 + +/******************************************************************************* + * Ledger Nano S - Secure firmware + * (c) 2022 Ledger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ********************************************************************************/ #ifndef CX_RIPEMD160_H #define CX_RIPEMD160_H +#ifdef HAVE_RIPEMD160 + #include "lcx_ripemd160.h" #include #include diff --git a/lib_cxng/src/cx_rng.h b/lib_cxng/src/cx_rng.h index 06941e0f7..611c4a31a 100644 --- a/lib_cxng/src/cx_rng.h +++ b/lib_cxng/src/cx_rng.h @@ -15,11 +15,12 @@ * See the License for the specific language governing permissions and * limitations under the License. ********************************************************************************/ -#ifdef HAVE_RNG #ifndef CX_RNG_H #define CX_RNG_H +#ifdef HAVE_RNG + #include void cx_rng_init(void); @@ -31,6 +32,6 @@ uint32_t cx_trng_u32(void); void cx_trng_lengthtest(void); #endif -#endif - #endif // HAVE_RNG + +#endif // CX_RNG_G diff --git a/lib_cxng/src/cx_rng_rfc6979.h b/lib_cxng/src/cx_rng_rfc6979.h index b7e37b411..678acf086 100644 --- a/lib_cxng/src/cx_rng_rfc6979.h +++ b/lib_cxng/src/cx_rng_rfc6979.h @@ -16,11 +16,11 @@ * limitations under the License. ********************************************************************************/ -#ifdef HAVE_RNG_RFC6979 - #ifndef CX_RNG_RFC6979_H #define CX_RNG_RFC6979_H +#ifdef HAVE_RNG_RFC6979 + #include "libcxng.h" #include "cx_hash.h" #include @@ -69,6 +69,7 @@ cx_err_t cx_rng_rfc6979_init(cx_rnd_rfc6979_ctx_t *rfc_ctx, /*const uint8_t *additional_input, size_t additional_input_len*/); cx_err_t cx_rng_rfc6979_next(cx_rnd_rfc6979_ctx_t *rfc_ctx, uint8_t *out, size_t out_len); -#endif // CX_HMAC_DRBG_H #endif // HAVE_RNG_RFC6979 + +#endif // CX_RNG_RFC6979_H diff --git a/lib_cxng/src/cx_sha256.h b/lib_cxng/src/cx_sha256.h index a89a5cdff..f7b54465b 100644 --- a/lib_cxng/src/cx_sha256.h +++ b/lib_cxng/src/cx_sha256.h @@ -1,8 +1,26 @@ -#if defined(HAVE_SHA256) || defined(HAVE_SHA224) + +/******************************************************************************* + * Ledger Nano S - Secure firmware + * (c) 2022 Ledger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ********************************************************************************/ #ifndef CX_SHA256_H #define CX_SHA256_H +#if defined(HAVE_SHA256) || defined(HAVE_SHA224) + #include "lcx_sha256.h" #include #include @@ -19,5 +37,6 @@ extern const cx_hash_info_t cx_sha256_info; cx_err_t cx_sha256_update(cx_sha256_t *ctx, const uint8_t *data, size_t len); cx_err_t cx_sha256_final(cx_sha256_t *ctx, uint8_t *digest); -#endif // CX_SHA256_H #endif // HAVE_SHA256 + +#endif // CX_SHA256_H diff --git a/lib_cxng/src/cx_sha3.h b/lib_cxng/src/cx_sha3.h index 96bab3f4c..e9729b180 100644 --- a/lib_cxng/src/cx_sha3.h +++ b/lib_cxng/src/cx_sha3.h @@ -1,8 +1,26 @@ -#ifdef HAVE_SHA3 + +/******************************************************************************* + * Ledger Nano S - Secure firmware + * (c) 2022 Ledger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ********************************************************************************/ #ifndef CX_SHA3_H #define CX_SHA3_H +#ifdef HAVE_SHA3 + #include "lcx_sha3.h" extern const cx_hash_info_t cx_sha3_info; @@ -14,6 +32,6 @@ cx_err_t cx_sha3_update(cx_sha3_t *ctx, const uint8_t *data, size_t len); cx_err_t cx_sha3_final(cx_sha3_t *ctx, uint8_t *digest); size_t cx_sha3_get_output_size(const cx_sha3_t *ctx); -#endif // CX_SHA3_H - #endif // HAVE_SHA3 + +#endif // CX_SHA3_H diff --git a/lib_cxng/src/cx_sha512.h b/lib_cxng/src/cx_sha512.h index ee2c2e289..6abdbc8a0 100644 --- a/lib_cxng/src/cx_sha512.h +++ b/lib_cxng/src/cx_sha512.h @@ -1,8 +1,26 @@ -#if defined(HAVE_SHA512) || defined(HAVE_SHA384) + +/******************************************************************************* + * Ledger Nano S - Secure firmware + * (c) 2022 Ledger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ********************************************************************************/ #ifndef CX_SHA512_H #define CX_SHA512_H +#if defined(HAVE_SHA512) || defined(HAVE_SHA384) + #include #include #include "lcx_sha512.h" @@ -18,6 +36,6 @@ extern const cx_hash_info_t cx_sha512_info; cx_err_t cx_sha512_update(cx_sha512_t *ctx, const uint8_t *data, size_t len); cx_err_t cx_sha512_final(cx_sha512_t *ctx, uint8_t *digest); -#endif // CX_SHA512_H - #endif // defined(HAVE_SHA512) || defined(HAVE_SHA384) + +#endif // CX_SHA512_H diff --git a/lib_cxng/src/cx_utils.h b/lib_cxng/src/cx_utils.h index 7c805b520..679de2e88 100644 --- a/lib_cxng/src/cx_utils.h +++ b/lib_cxng/src/cx_utils.h @@ -91,6 +91,6 @@ void cx_swap_buffer64(uint64bits_t *v, int len); void cx_memxor(uint8_t *buf1, const uint8_t *buf2, size_t len); -#endif - uint8_t cx_constant_time_eq(const uint8_t *buf1, uint8_t *buf2, size_t len); + +#endif // CX_UTILS_H