
#ifndef USER_SETTINGS_H
#define USER_SETTINGS_H

#ifdef __cplusplus
extern "C" {
#endif

/* Default build with fast math */

/* Slower build but uses less memory */
//#define BUILD_B

/* Performant build but uses more memory */
//#define BUILD_C

// uncomment and add wolfSSL_Debugging_ON() to app for debug messages
#undef DEBUG_WOLFSSL
#undef NO_ERROR_STRINGS
//#define DEBUG_WOLFSSL

//#define WOLFSSL_CALLBACKS

//#define NO_TIMEVAL

/* ------------------------------------------------------------------------- */
/* Platform */
/* ------------------------------------------------------------------------- */

/* Properly sets endian order and data type sizes */
#define BIG_ENDIAN_ORDER

#undef  SINGLE_THREADED

/* with USE_FAST_MATH smallstack is used to fit in the default stack size */
#define WOLFSSL_SMALL_STACK

// We provide IO callbacks
#define WOLFSSL_USER_IO

/* ------------------------------------------------------------------------- */
/* Math Configuration */
/* ------------------------------------------------------------------------- */
#ifndef SIZEOF_LONG
    #define SIZEOF_LONG 4
#endif
#ifndef SIZEOF_LONG_LONG
    #define SIZEOF_LONG_LONG 8
#endif

#define USE_FAST_MATH

/* hardening against side channel attacks */
#if defined(USE_FAST_MATH)
    #define TFM_TIMING_RESISTANT
#endif /* USE_FAST_MATH */

// OPENSSL_EXTRA uses a lot more memory but is needed in order to enable
// compatibility layer API
//#define OPENSSL_EXTRA

/* enable features - added to match MODM7AE70 */

// additional RSA padding schemes
#undef NO_RSA
#ifndef NO_RSA
    #if defined(USE_FAST_MATH)
        /* Maximum math bits (Max RSA key bits * 2) */
        #undef  FP_MAX_BITS
        #define FP_MAX_BITS     8192
    #endif

    /* this slows down RSA operations but increases side channel resistance */
    #define WC_RSA_BLINDING

    /* RSA PSS Support */
    #define WC_RSA_NO_PADDING
    #define WC_RSA_PSS
#endif

#undef NO_AES
#ifndef NO_AES
    #define HAVE_AES_CBC
    #define HAVE_AESGCM
    #define GCM_SMALL
    #define HAVE_AESCCM
#endif

#define HAVE_ECC
#ifdef HAVE_ECC
    #undef ECC_TIMING_RESISTANT
    //#define ECC_TIMING_RESISTANT // Currently disabled for performance

    // Manually add support for curves.
    #undef  ECC_USER_CURVES
    #define ECC_USER_CURVES

    #ifdef ECC_USER_CURVES
        /* Manual Curve Selection */
        #define HAVE_ECC192
        #define HAVE_ECC128
        #define HAVE_ECC224
        #undef NO_ECC256
        #define HAVE_ECC320
        #define HAVE_ECC384
        //#define HAVE_ECC521 // - Disabled until we can get better performance 
    #endif

    /* Fixed point cache (speeds repeated operations against same private key) */
    #undef  FP_ECC
    #define FP_ECC
    #ifdef FP_ECC
        /* Bits / Entries */
        #undef  FP_ENTRIES
        #define FP_ENTRIES  15
        #undef  FP_LUT
        #define FP_LUT      4
    #endif

    #define ECC_SHAMIR

    #if defined(USE_FAST_MATH)
        #define ALT_ECC_SIZE
    #endif

    #ifndef NO_ECC256
        #define TFM_ECC256
    #endif
#endif

#define HAVE_CHACHA
#define HAVE_POLY1305
#define HAVE_ONE_TIME_AUTH
#define HAVE_CURVE25519
#define HAVE_ED25519 /* ED25519 Requires SHA512 */
#define CURVED25519_SMALL

/* Hashing */

#undef NO_SHA256
#define WOLFSSL_SHA512
#define WOLFSSL_SHA384
#undef WOLFSSL_SHA3
#define NO_MD5
#undef HAVE_HKDF
#undef WOLFSSL_CMAC

#ifdef BUILD_B
    #define RSA_LOW_MEM
    #define RSA_LOW_MEM
    #define USE_SLOW_SHA
    #define USE_SLOW_SHA256
    #define NO_ERROR_STRINGS
    #define USE_FAST_MATH
#endif

#ifdef BUILD_C
    #define WOLFSSL_SP
    #define WOLFSSL_HAVE_SP_RSA
    #define WOLFSSL_HAVE_SP_ECC
    #define WOLFSSL_HAVE_SP_DH
    #define SP_WORD_SIZE 32
#endif

/* ------------------------------------------------------------------------- */
/* Port */
/* ------------------------------------------------------------------------- */

/* Override Current Time */
/* Allows custom "custom_time()" function to be used for benchmark */
#define WOLFSSL_USER_CURRTIME
#define WOLFSSL_GMTIME
#define USER_TICKS
extern unsigned long my_time(unsigned long* timer);
#define XTIME my_time


/* ------------------------------------------------------------------------- */
/* RNG */
/* ------------------------------------------------------------------------- */

/* Seed Source */
/* Size of returned HW RNG value */
#define CUSTOM_RAND_TYPE      unsigned int
extern unsigned int my_rng_seed_gen(void);
#undef  CUSTOM_RAND_GENERATE
#define CUSTOM_RAND_GENERATE  my_rng_seed_gen


// From MODM7 User Settings
/* ------------------------------------------------------------------------- */
/* Enable Features */
/* ------------------------------------------------------------------------- */
#define KEEP_PEER_CERT

#undef  HAVE_COMP_KEY
//#define HAVE_COMP_KEY

#define HAVE_TLS_EXTENSIONS

#define HAVE_SUPPORTED_CURVES

#define WOLFSSL_BASE64_ENCODE

#define SMALL_SESSION_CACHE

/* ------------------------------------------------------------------------- */
/* Disable Features */
/* ------------------------------------------------------------------------- */
#undef  NO_WOLFSSL_SERVER
//#define NO_WOLFSSL_SERVER

#undef  NO_WOLFSSL_CLIENT
//#define NO_WOLFSSL_CLIENT

#undef  NO_CRYPT_TEST
#define NO_CRYPT_TEST

#undef  NO_CRYPT_BENCHMARK
#define NO_CRYPT_BENCHMARK

#undef  WOLFCRYPT_ONLY
//#define WOLFCRYPT_ONLY

//#define WOLFSSL_STATIC_MEMORY
#ifndef WOLFSSL_STATIC_MEMORY
    #define NO_WOLFSSL_MEMORY
#endif

#undef STRING_USER

#undef WOLFSSL_KEY_GEN

/* In-lining of misc.c functions */
/* If defined, must include wolfcrypt/src/misc.c in build */
/* Slower, but about 1k smaller */
#undef  NO_INLINE
//#define NO_INLINE

#undef WOLFSSL_NO_SOCK
#define WOLFSSL_NO_SOCK

#undef NO_WOLFSSL_DIR
#define NO_WOLFSSL_DIR

#undef  NO_FILESYSTEM
// #define NO_FILESYSTEM

#undef  NO_WRITEV
#define NO_WRITEV

#undef  NO_MAIN_DRIVER
#define NO_MAIN_DRIVER

#undef  NO_DEV_RANDOM
#define NO_DEV_RANDOM

#undef  NO_DSA
#define NO_DSA

#undef  NO_RC4
//#define NO_RC4

#undef  NO_OLD_TLS
#define NO_OLD_TLS

#undef  NO_HC128
#define NO_HC128

#undef  NO_RABBIT
#define NO_RABBIT

#undef  NO_PSK
#define NO_PSK

#undef  NO_MD4
#define NO_MD4

#undef  NO_PWDBASED
#define NO_PWDBASED

#undef  NO_CODING
//#define NO_CODING

#undef  NO_ASN_TIME
//#define NO_ASN_TIME

#undef  NO_CERTS
//#define NO_CERTS

#undef  NO_SIG_WRAPPER
//#define NO_SIG_WRAPPER

#undef NO_TLS

#undef NO_DES3

#undef NO_DH

// Settings made for compatibility
#define WOLFSSL_STATIC_RSA // Needed to support TLS_RSA_WITH_AES_128_CBC_SHA
#define WOLFSSL_AES_128 // Needed to support TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA256
#define WOLFSSL_AES_256 // Needed to support TLS_RSA_WITH_AES_256_CBC_SHA256
#define WOLFSSL_STATIC_DH // Needed to support TLS_ECDH_ECDSA_WITH_RC4_128_SHA

#define WOLFSSL_CERT_REQ
#define WOLFSSL_CERT_GEN
#define WOLFSSL_KEY_GEN
#define WOLFSSL_ALT_NAMES

#define ENABLE_ECCKEY_CREATE // Custom define, maybe should move to predef?
#define ENABLE_RSAKEY_CREATE // Custom define, maybe should move to predef?

#ifdef __cplusplus
}
#endif

#endif /* USER_SETTINGS_H */

