Skip to content

Commit

Permalink
Fix missing header guard
Browse files Browse the repository at this point in the history
  • Loading branch information
tjoly-ledger committed Sep 20, 2023
1 parent ca36c50 commit 0797523
Show file tree
Hide file tree
Showing 36 changed files with 209 additions and 121 deletions.
9 changes: 5 additions & 4 deletions lib_cxng/include/lcx_aead.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stddef.h>
#if defined(HAVE_AES_GCM)
Expand Down Expand Up @@ -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 // HAVE_AEAD

#endif // LCX_AED_H
9 changes: 4 additions & 5 deletions lib_cxng/include/lcx_aes.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
* </a> 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"
Expand Down Expand Up @@ -234,6 +234,5 @@ 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 // HAVE_AES
#endif // LCX_AES_H
10 changes: 6 additions & 4 deletions lib_cxng/include/lcx_aes_gcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stddef.h>

Expand Down Expand Up @@ -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 // HAVE_AES && HAVE_AES_GCM

#endif // LCX_AES_GCM_H
7 changes: 4 additions & 3 deletions lib_cxng/include/lcx_blake2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stddef.h>
Expand Down Expand Up @@ -133,6 +134,6 @@ DEPRECATED static inline int cx_blake2b_init2(cx_blake2b_t *hash,
return CX_BLAKE2B;
}

#endif
#endif // HAVE_BLAKE2

#endif // HAVE_BLAKE2
#endif // LCX_BLAKE2_H
6 changes: 4 additions & 2 deletions lib_cxng/include/lcx_chacha.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,6 +33,8 @@
#ifndef LCX_CHACHA_H
#define LCX_CHACHA_H

#if defined(HAVE_CHACHA)

#include "ox.h"
#include <stddef.h>

Expand Down Expand Up @@ -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 */
7 changes: 4 additions & 3 deletions lib_cxng/include/lcx_chacha_poly.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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 */
7 changes: 3 additions & 4 deletions lib_cxng/include/lcx_crc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stddef.h>
#include <stdint.h>

Expand Down Expand Up @@ -60,6 +60,5 @@ 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
4 changes: 2 additions & 2 deletions lib_cxng/include/lcx_ecdh.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions lib_cxng/include/lcx_ecdsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
* <a href="https://tools.ietf.org/html/rfc6979"> RFC6979 </a> 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"

Expand Down Expand Up @@ -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
7 changes: 4 additions & 3 deletions lib_cxng/include/lcx_ecfp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
10 changes: 5 additions & 5 deletions lib_cxng/include/lcx_eddsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions lib_cxng/include/lcx_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
7 changes: 4 additions & 3 deletions lib_cxng/include/lcx_hmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions lib_cxng/include/lcx_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions lib_cxng/include/lcx_pbkdf2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
6 changes: 4 additions & 2 deletions lib_cxng/include/lcx_poly1305.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,6 +34,8 @@
#ifndef LCX_POLY1305_H
#define LCX_POLY1305_H

#if defined(HAVE_POLY1305)

#include "ox.h"
#include <stddef.h>

Expand All @@ -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
8 changes: 4 additions & 4 deletions lib_cxng/include/lcx_ripemd160.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
* "https://homes.esat.kuleuven.be/~bosselae/ripemd160.html"> RIPEMD-160 </a> 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"

Expand Down Expand Up @@ -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
Loading

0 comments on commit 0797523

Please sign in to comment.