diff --git a/cyassl/ctaocrypt/asn.h b/cyassl/ctaocrypt/asn.h index bd85b20e7..e88594447 100644 --- a/cyassl/ctaocrypt/asn.h +++ b/cyassl/ctaocrypt/asn.h @@ -25,6 +25,7 @@ #define CTAO_CRYPT_ASN_H #include + #ifndef WOLFSSL_PEMCERT_TODER_DEFINED #ifndef NO_FILESYSTEM #define CyaSSL_PemCertToDer wolfSSL_PemCertToDer diff --git a/cyassl/ctaocrypt/asn_public.h b/cyassl/ctaocrypt/asn_public.h index 6c7bff13f..37fbd7d6c 100644 --- a/cyassl/ctaocrypt/asn_public.h +++ b/cyassl/ctaocrypt/asn_public.h @@ -24,171 +24,48 @@ #define CTAO_CRYPT_ASN_PUBLIC_H #include -#include -#ifdef CYASSL_CERT_GEN - #include +#include +#ifdef WOLFSSL_CERT_GEN + #define InitCert wc_InitCert + #define MakeCert wc_MakeCert + + #ifdef WOLFSSL_CERT_REQ + #define MakeCertReq wc_MakeCertReq #endif + #define SignCert wc_SignCert + #define MakeSelfCert wc_MakeSelfCert + #define SetIssuer wc_SetIssuer + #define SetSubject wc_SetSubject -#ifdef __cplusplus - extern "C" { + #ifdef WOLFSSL_ALT_NAMES + #define SetAltNames wc_SetAltNames #endif - -/* Certificate file Type */ -enum CertType { - CERT_TYPE = 0, - PRIVATEKEY_TYPE, - DH_PARAM_TYPE, - CRL_TYPE, - CA_TYPE, - ECC_PRIVATEKEY_TYPE, - CERTREQ_TYPE -}; - - -/* Signature type, by OID sum */ -enum Ctc_SigType { - CTC_SHAwDSA = 517, - CTC_MD2wRSA = 646, - CTC_MD5wRSA = 648, - CTC_SHAwRSA = 649, - CTC_SHAwECDSA = 520, - CTC_SHA256wRSA = 655, - CTC_SHA256wECDSA = 524, - CTC_SHA384wRSA = 656, - CTC_SHA384wECDSA = 525, - CTC_SHA512wRSA = 657, - CTC_SHA512wECDSA = 526 -}; - -enum Ctc_Encoding { - CTC_UTF8 = 0x0c, /* utf8 */ - CTC_PRINTABLE = 0x13 /* printable */ -}; - - -#ifdef CYASSL_CERT_GEN - -#ifndef HAVE_ECC - typedef struct ecc_key ecc_key; -#endif - -enum Ctc_Misc { - CTC_NAME_SIZE = 64, - CTC_DATE_SIZE = 32, - CTC_MAX_ALT_SIZE = 16384, /* may be huge */ - CTC_SERIAL_SIZE = 8 -}; - -typedef struct CertName { - char country[CTC_NAME_SIZE]; - char countryEnc; - char state[CTC_NAME_SIZE]; - char stateEnc; - char locality[CTC_NAME_SIZE]; - char localityEnc; - char sur[CTC_NAME_SIZE]; - char surEnc; - char org[CTC_NAME_SIZE]; - char orgEnc; - char unit[CTC_NAME_SIZE]; - char unitEnc; - char commonName[CTC_NAME_SIZE]; - char commonNameEnc; - char email[CTC_NAME_SIZE]; /* !!!! email has to be last !!!! */ -} CertName; - - -/* for user to fill for certificate generation */ -typedef struct Cert { - int version; /* x509 version */ - byte serial[CTC_SERIAL_SIZE]; /* serial number */ - int sigType; /* signature algo type */ - CertName issuer; /* issuer info */ - int daysValid; /* validity days */ - int selfSigned; /* self signed flag */ - CertName subject; /* subject info */ - int isCA; /* is this going to be a CA */ - /* internal use only */ - int bodySz; /* pre sign total size */ - int keyType; /* public key type of subject */ -#ifdef CYASSL_ALT_NAMES - byte altNames[CTC_MAX_ALT_SIZE]; /* altNames copy */ - int altNamesSz; /* altNames size in bytes */ - byte beforeDate[CTC_DATE_SIZE]; /* before date copy */ - int beforeDateSz; /* size of copy */ - byte afterDate[CTC_DATE_SIZE]; /* after date copy */ - int afterDateSz; /* size of copy */ -#endif -#ifdef CYASSL_CERT_REQ - char challengePw[CTC_NAME_SIZE]; -#endif -} Cert; - - - - -/* Initialize and Set Certficate defaults: - version = 3 (0x2) - serial = 0 (Will be randomly generated) - sigType = SHA_WITH_RSA - issuer = blank - daysValid = 500 - selfSigned = 1 (true) use subject as issuer - subject = blank - isCA = 0 (false) - keyType = RSA_KEY (default) -*/ -CYASSL_API void InitCert(Cert*); -CYASSL_API int MakeCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*, - ecc_key*, RNG*); -#ifdef CYASSL_CERT_REQ - CYASSL_API int MakeCertReq(Cert*, byte* derBuffer, word32 derSz, RsaKey*, - ecc_key*); -#endif -CYASSL_API int SignCert(int requestSz, int sigType, byte* derBuffer, - word32 derSz, RsaKey*, ecc_key*, RNG*); -CYASSL_API int MakeSelfCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*, - RNG*); -CYASSL_API int SetIssuer(Cert*, const char*); -CYASSL_API int SetSubject(Cert*, const char*); -#ifdef CYASSL_ALT_NAMES - CYASSL_API int SetAltNames(Cert*, const char*); -#endif -CYASSL_API int SetIssuerBuffer(Cert*, const byte*, int); -CYASSL_API int SetSubjectBuffer(Cert*, const byte*, int); -CYASSL_API int SetAltNamesBuffer(Cert*, const byte*, int); -CYASSL_API int SetDatesBuffer(Cert*, const byte*, int); + #define SetIssuerBuffer wc_SetIssuerBuffer + #define SetSubjectBuffer wc_SetSubjectBuffer + #define SetAltNamesBuffer wc_SetAltNamesBuffer + #define SetDatesBuffer wc_SetDatesBuffer #ifdef HAVE_NTRU - CYASSL_API int MakeNtruCert(Cert*, byte* derBuffer, word32 derSz, - const byte* ntruKey, word16 keySz, RNG*); + #define MakeNtruCert wc_MakeNtruCert #endif -#endif /* CYASSL_CERT_GEN */ +#endif /* WOLFSSL_CERT_GEN */ - -#if defined(CYASSL_KEY_GEN) || defined(CYASSL_CERT_GEN) - CYASSL_API int DerToPem(const byte* der, word32 derSz, byte* output, - word32 outputSz, int type); + #if defined(WOLFSSL_KEY_GEN) || defined(WOLFSSL_CERT_GEN) + #define DerToPem wc_DerToPem #endif #ifdef HAVE_ECC /* private key helpers */ - CYASSL_API int EccPrivateKeyDecode(const byte* input,word32* inOutIdx, - ecc_key*,word32); - CYASSL_API int EccKeyToDer(ecc_key*, byte* output, word32 inLen); + #define EccPrivateKeyDecode wc_EccPrivateKeyDecode + #define EccKeyToDer wc_EccKeyToDer #endif -/* DER encode signature */ -CYASSL_API word32 EncodeSignature(byte* out, const byte* digest, word32 digSz, - int hashOID); -CYASSL_API int GetCTC_HashOID(int type); - -#ifdef __cplusplus - } /* extern "C" */ -#endif + /* DER encode signature */ + #define EncodeSignature wc_EncodeSignature + #define GetCTC_HashOID wc_GetCTC_HashOID #endif /* CTAO_CRYPT_ASN_PUBLIC_H */ diff --git a/cyassl/ctaocrypt/blake2-impl.h b/cyassl/ctaocrypt/blake2-impl.h index ce84ddc94..218bb8d14 100644 --- a/cyassl/ctaocrypt/blake2-impl.h +++ b/cyassl/ctaocrypt/blake2-impl.h @@ -36,119 +36,7 @@ #define CTAOCRYPT_BLAKE2_IMPL_H #include - -static inline word32 load32( const void *src ) -{ -#if defined(LITTLE_ENDIAN_ORDER) - return *( word32 * )( src ); -#else - const byte *p = ( byte * )src; - word32 w = *p++; - w |= ( word32 )( *p++ ) << 8; - w |= ( word32 )( *p++ ) << 16; - w |= ( word32 )( *p++ ) << 24; - return w; -#endif -} - -static inline word64 load64( const void *src ) -{ -#if defined(LITTLE_ENDIAN_ORDER) - return *( word64 * )( src ); -#else - const byte *p = ( byte * )src; - word64 w = *p++; - w |= ( word64 )( *p++ ) << 8; - w |= ( word64 )( *p++ ) << 16; - w |= ( word64 )( *p++ ) << 24; - w |= ( word64 )( *p++ ) << 32; - w |= ( word64 )( *p++ ) << 40; - w |= ( word64 )( *p++ ) << 48; - w |= ( word64 )( *p++ ) << 56; - return w; -#endif -} - -static inline void store32( void *dst, word32 w ) -{ -#if defined(LITTLE_ENDIAN_ORDER) - *( word32 * )( dst ) = w; -#else - byte *p = ( byte * )dst; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; -#endif -} - -static inline void store64( void *dst, word64 w ) -{ -#if defined(LITTLE_ENDIAN_ORDER) - *( word64 * )( dst ) = w; -#else - byte *p = ( byte * )dst; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; -#endif -} - -static inline word64 load48( const void *src ) -{ - const byte *p = ( const byte * )src; - word64 w = *p++; - w |= ( word64 )( *p++ ) << 8; - w |= ( word64 )( *p++ ) << 16; - w |= ( word64 )( *p++ ) << 24; - w |= ( word64 )( *p++ ) << 32; - w |= ( word64 )( *p++ ) << 40; - return w; -} - -static inline void store48( void *dst, word64 w ) -{ - byte *p = ( byte * )dst; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; w >>= 8; - *p++ = ( byte )w; -} - -static inline word32 rotl32( const word32 w, const unsigned c ) -{ - return ( w << c ) | ( w >> ( 32 - c ) ); -} - -static inline word64 rotl64( const word64 w, const unsigned c ) -{ - return ( w << c ) | ( w >> ( 64 - c ) ); -} - -static inline word32 rotr32( const word32 w, const unsigned c ) -{ - return ( w >> c ) | ( w << ( 32 - c ) ); -} - -static inline word64 rotr64( const word64 w, const unsigned c ) -{ - return ( w >> c ) | ( w << ( 64 - c ) ); -} - -/* prevents compiler optimizing out memset() */ -static inline void secure_zero_memory( void *v, word64 n ) -{ - volatile byte *p = ( volatile byte * )v; - - while( n-- ) *p++ = 0; -} +#include #endif /* CTAOCRYPT_BLAKE2_IMPL_H */ diff --git a/cyassl/ctaocrypt/blake2-int.h b/cyassl/ctaocrypt/blake2-int.h index ac039e510..b176b3578 100644 --- a/cyassl/ctaocrypt/blake2-int.h +++ b/cyassl/ctaocrypt/blake2-int.h @@ -37,147 +37,7 @@ #define CTAOCRYPT_BLAKE2_INT_H #include - - -#if defined(_MSC_VER) - #define ALIGN(x) __declspec(align(x)) -#elif defined(__GNUC__) - #define ALIGN(x) __attribute__((aligned(x))) -#else - #define ALIGN(x) -#endif - - -#if defined(__cplusplus) - extern "C" { -#endif - - enum blake2s_constant - { - BLAKE2S_BLOCKBYTES = 64, - BLAKE2S_OUTBYTES = 32, - BLAKE2S_KEYBYTES = 32, - BLAKE2S_SALTBYTES = 8, - BLAKE2S_PERSONALBYTES = 8 - }; - - enum blake2b_constant - { - BLAKE2B_BLOCKBYTES = 128, - BLAKE2B_OUTBYTES = 64, - BLAKE2B_KEYBYTES = 64, - BLAKE2B_SALTBYTES = 16, - BLAKE2B_PERSONALBYTES = 16 - }; - -#pragma pack(push, 1) - typedef struct __blake2s_param - { - byte digest_length; /* 1 */ - byte key_length; /* 2 */ - byte fanout; /* 3 */ - byte depth; /* 4 */ - word32 leaf_length; /* 8 */ - byte node_offset[6];/* 14 */ - byte node_depth; /* 15 */ - byte inner_length; /* 16 */ - /* byte reserved[0]; */ - byte salt[BLAKE2B_SALTBYTES]; /* 24 */ - byte personal[BLAKE2S_PERSONALBYTES]; /* 32 */ - } blake2s_param; - - ALIGN( 64 ) typedef struct __blake2s_state - { - word32 h[8]; - word32 t[2]; - word32 f[2]; - byte buf[2 * BLAKE2S_BLOCKBYTES]; - word64 buflen; - byte last_node; - } blake2s_state ; - - typedef struct __blake2b_param - { - byte digest_length; /* 1 */ - byte key_length; /* 2 */ - byte fanout; /* 3 */ - byte depth; /* 4 */ - word32 leaf_length; /* 8 */ - word64 node_offset; /* 16 */ - byte node_depth; /* 17 */ - byte inner_length; /* 18 */ - byte reserved[14]; /* 32 */ - byte salt[BLAKE2B_SALTBYTES]; /* 48 */ - byte personal[BLAKE2B_PERSONALBYTES]; /* 64 */ - } blake2b_param; - - ALIGN( 64 ) typedef struct __blake2b_state - { - word64 h[8]; - word64 t[2]; - word64 f[2]; - byte buf[2 * BLAKE2B_BLOCKBYTES]; - word64 buflen; - byte last_node; - } blake2b_state; - - typedef struct __blake2sp_state - { - blake2s_state S[8][1]; - blake2s_state R[1]; - byte buf[8 * BLAKE2S_BLOCKBYTES]; - word64 buflen; - } blake2sp_state; - - typedef struct __blake2bp_state - { - blake2b_state S[4][1]; - blake2b_state R[1]; - byte buf[4 * BLAKE2B_BLOCKBYTES]; - word64 buflen; - } blake2bp_state; -#pragma pack(pop) - - /* Streaming API */ - int blake2s_init( blake2s_state *S, const byte outlen ); - int blake2s_init_key( blake2s_state *S, const byte outlen, const void *key, const byte keylen ); - int blake2s_init_param( blake2s_state *S, const blake2s_param *P ); - int blake2s_update( blake2s_state *S, const byte *in, word64 inlen ); - int blake2s_final( blake2s_state *S, byte *out, byte outlen ); - - int blake2b_init( blake2b_state *S, const byte outlen ); - int blake2b_init_key( blake2b_state *S, const byte outlen, const void *key, const byte keylen ); - int blake2b_init_param( blake2b_state *S, const blake2b_param *P ); - int blake2b_update( blake2b_state *S, const byte *in, word64 inlen ); - int blake2b_final( blake2b_state *S, byte *out, byte outlen ); - - int blake2sp_init( blake2sp_state *S, const byte outlen ); - int blake2sp_init_key( blake2sp_state *S, const byte outlen, const void *key, const byte keylen ); - int blake2sp_update( blake2sp_state *S, const byte *in, word64 inlen ); - int blake2sp_final( blake2sp_state *S, byte *out, byte outlen ); - - int blake2bp_init( blake2bp_state *S, const byte outlen ); - int blake2bp_init_key( blake2bp_state *S, const byte outlen, const void *key, const byte keylen ); - int blake2bp_update( blake2bp_state *S, const byte *in, word64 inlen ); - int blake2bp_final( blake2bp_state *S, byte *out, byte outlen ); - - /* Simple API */ - int blake2s( byte *out, const void *in, const void *key, const byte outlen, const word64 inlen, byte keylen ); - int blake2b( byte *out, const void *in, const void *key, const byte outlen, const word64 inlen, byte keylen ); - - int blake2sp( byte *out, const void *in, const void *key, const byte outlen, const word64 inlen, byte keylen ); - int blake2bp( byte *out, const void *in, const void *key, const byte outlen, const word64 inlen, byte keylen ); - - static inline int blake2( byte *out, const void *in, const void *key, const byte outlen, const word64 inlen, byte keylen ) - { - return blake2b( out, in, key, outlen, inlen, keylen ); - } - - - -#if defined(__cplusplus) - } -#endif +#include #endif /* CTAOCRYPT_BLAKE2_INT_H */ diff --git a/cyassl/ctaocrypt/dh.h b/cyassl/ctaocrypt/dh.h index 8daffe234..cd44f0636 100644 --- a/cyassl/ctaocrypt/dh.h +++ b/cyassl/ctaocrypt/dh.h @@ -25,15 +25,15 @@ #ifndef CTAO_CRYPT_DH_H #define CTAO_CRYPT_DH_H - /* for dh reverse compatibility */ - #include - #define InitDhKey wc_InitDhKey - #define FreeDhKey wc_FreeDhKey - #define DhGenerateKeyPair wc_DhGenerateKeyPair - #define DhAgree wc_DhAgree - #define DhKeyDecode wc_DhKeyDecode - #define DhSetKey wc_DhSetKey - #define DhParamsLoad wc_DhParamsLoad +/* for dh reverse compatibility */ +#include +#define InitDhKey wc_InitDhKey +#define FreeDhKey wc_FreeDhKey +#define DhGenerateKeyPair wc_DhGenerateKeyPair +#define DhAgree wc_DhAgree +#define DhKeyDecode wc_DhKeyDecode +#define DhSetKey wc_DhSetKey +#define DhParamsLoad wc_DhParamsLoad #endif /* CTAO_CRYPT_DH_H */ diff --git a/cyassl/ctaocrypt/ecc.h b/cyassl/ctaocrypt/ecc.h index f75ba8ef9..1882a24ad 100644 --- a/cyassl/ctaocrypt/ecc.h +++ b/cyassl/ctaocrypt/ecc.h @@ -58,172 +58,6 @@ #endif /* HAVE_ECC_ENCRYPT */ #endif -// -//#include -//#include -//#include -// -//#ifdef __cplusplus -// extern "C" { -//#endif -// -// -//enum { -// ECC_PUBLICKEY = 1, -// ECC_PRIVATEKEY = 2, -// ECC_MAXNAME = 16, /* MAX CURVE NAME LENGTH */ -// SIG_HEADER_SZ = 6, /* ECC signature header size */ -// ECC_BUFSIZE = 256, /* for exported keys temp buffer */ -// ECC_MINSIZE = 20, /* MIN Private Key size */ -// ECC_MAXSIZE = 66 /* MAX Private Key size */ -//}; -// -// -///* ECC set type defined a NIST GF(p) curve */ -//typedef struct { -// int size; /* The size of the curve in octets */ -// const char* name; /* name of this curve */ -// const char* prime; /* prime that defines the field, curve is in (hex) */ -// const char* Af; /* fields A param (hex) */ -// const char* Bf; /* fields B param (hex) */ -// const char* order; /* order of the curve (hex) */ -// const char* Gx; /* x coordinate of the base point on curve (hex) */ -// const char* Gy; /* y coordinate of the base point on curve (hex) */ -//} ecc_set_type; -// -// -///* A point on an ECC curve, stored in Jacbobian format such that (x,y,z) => -// (x/z^2, y/z^3, 1) when interpreted as affine */ -//typedef struct { -// mp_int x; /* The x coordinate */ -// mp_int y; /* The y coordinate */ -// mp_int z; /* The z coordinate */ -//} ecc_point; -// -// -///* An ECC Key */ -//typedef struct { -// int type; /* Public or Private */ -// int idx; /* Index into the ecc_sets[] for the parameters of -// this curve if -1, this key is using user supplied -// curve in dp */ -// const ecc_set_type* dp; /* domain parameters, either points to NIST -// curves (idx >= 0) or user supplied */ -// ecc_point pubkey; /* public key */ -// mp_int k; /* private key */ -//} ecc_key; -// -// -///* ECC predefined curve sets */ -//extern const ecc_set_type ecc_sets[]; -// -// -//CYASSL_API -//int ecc_make_key(RNG* rng, int keysize, ecc_key* key); -//CYASSL_API -//int ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte* out, -// word32* outlen); -//CYASSL_API -//int ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen, -// RNG* rng, ecc_key* key); -//CYASSL_API -//int ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash, -// word32 hashlen, int* stat, ecc_key* key); -//CYASSL_API -//void ecc_init(ecc_key* key); -//CYASSL_API -//void ecc_free(ecc_key* key); -//CYASSL_API -//void ecc_fp_free(void); -// -// -///* ASN key helpers */ -//CYASSL_API -//int ecc_export_x963(ecc_key*, byte* out, word32* outLen); -//CYASSL_API -//int ecc_export_x963_ex(ecc_key*, byte* out, word32* outLen, int compressed); -// /* extended functionality with compressed option */ -//CYASSL_API -//int ecc_import_x963(const byte* in, word32 inLen, ecc_key* key); -//CYASSL_API -//int ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub, -// word32 pubSz, ecc_key* key); -//CYASSL_API -//int ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* outlen); -//CYASSL_API -//int ecc_import_raw(ecc_key* key, const char* qx, const char* qy, -// const char* d, const char* curveName); -// -//CYASSL_API -//int ecc_export_private_only(ecc_key* key, byte* out, word32* outLen); -// -///* size helper */ -//CYASSL_API -//int ecc_size(ecc_key* key); -//CYASSL_API -//int ecc_sig_size(ecc_key* key); -// -// -//#ifdef HAVE_ECC_ENCRYPT -///* ecc encrypt */ -// -//enum ecEncAlgo { -// ecAES_128_CBC = 1, /* default */ -// ecAES_256_CBC = 2 -//}; -// -//enum ecKdfAlgo { -// ecHKDF_SHA256 = 1, /* default */ -// ecHKDF_SHA1 = 2 -//}; -// -//enum ecMacAlgo { -// ecHMAC_SHA256 = 1, /* default */ -// ecHMAC_SHA1 = 2 -//}; -// -//enum { -// KEY_SIZE_128 = 16, -// KEY_SIZE_256 = 32, -// IV_SIZE_64 = 8, -// EXCHANGE_SALT_SZ = 16, -// EXCHANGE_INFO_SZ = 23 -//}; -// -//enum ecFlags { -// REQ_RESP_CLIENT = 1, -// REQ_RESP_SERVER = 2 -//}; -// -// -//typedef struct ecEncCtx ecEncCtx; -// -//CYASSL_API -//ecEncCtx* ecc_ctx_new(int flags, RNG* rng); -//CYASSL_API -//void ecc_ctx_free(ecEncCtx*); -//CYASSL_API -//int ecc_ctx_reset(ecEncCtx*, RNG*); /* reset for use again w/o alloc/free */ -// -//CYASSL_API -//const byte* ecc_ctx_get_own_salt(ecEncCtx*); -//CYASSL_API -//int ecc_ctx_set_peer_salt(ecEncCtx*, const byte* salt); -//CYASSL_API -//int ecc_ctx_set_info(ecEncCtx*, const byte* info, int sz); -// -//CYASSL_API -//int ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg, -// word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx); -//CYASSL_API -//int ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg, -// word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx); -// -//#endif /* HAVE_ECC_ENCRYPT */ - -#ifdef __cplusplus - } /* extern "C" */ -#endif - #endif /* CTAO_CRYPT_ECC_H */ #endif /* HAVE_ECC */ + diff --git a/cyassl/ctaocrypt/mpi_class.h b/cyassl/ctaocrypt/mpi_class.h index 58111d8e8..aec6af4d8 100644 --- a/cyassl/ctaocrypt/mpi_class.h +++ b/cyassl/ctaocrypt/mpi_class.h @@ -19,1000 +19,5 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - -#if !(defined(LTM1) && defined(LTM2) && defined(LTM3)) -#if defined(LTM2) -#define LTM3 -#endif -#if defined(LTM1) -#define LTM2 -#endif -#define LTM1 - -#if defined(LTM_ALL) -#define BN_ERROR_C -#define BN_FAST_MP_INVMOD_C -#define BN_FAST_MP_MONTGOMERY_REDUCE_C -#define BN_FAST_S_MP_MUL_DIGS_C -#define BN_FAST_S_MP_MUL_HIGH_DIGS_C -#define BN_FAST_S_MP_SQR_C -#define BN_MP_2EXPT_C -#define BN_MP_ABS_C -#define BN_MP_ADD_C -#define BN_MP_ADD_D_C -#define BN_MP_ADDMOD_C -#define BN_MP_AND_C -#define BN_MP_CLAMP_C -#define BN_MP_CLEAR_C -#define BN_MP_CLEAR_MULTI_C -#define BN_MP_CMP_C -#define BN_MP_CMP_D_C -#define BN_MP_CMP_MAG_C -#define BN_MP_CNT_LSB_C -#define BN_MP_COPY_C -#define BN_MP_COUNT_BITS_C -#define BN_MP_DIV_C -#define BN_MP_DIV_2_C -#define BN_MP_DIV_2D_C -#define BN_MP_DIV_3_C -#define BN_MP_DIV_D_C -#define BN_MP_DR_IS_MODULUS_C -#define BN_MP_DR_REDUCE_C -#define BN_MP_DR_SETUP_C -#define BN_MP_EXCH_C -#define BN_MP_EXPT_D_C -#define BN_MP_EXPTMOD_C -#define BN_MP_EXPTMOD_FAST_C -#define BN_MP_EXTEUCLID_C -#define BN_MP_FREAD_C -#define BN_MP_FWRITE_C -#define BN_MP_GCD_C -#define BN_MP_GET_INT_C -#define BN_MP_GROW_C -#define BN_MP_INIT_C -#define BN_MP_INIT_COPY_C -#define BN_MP_INIT_MULTI_C -#define BN_MP_INIT_SET_C -#define BN_MP_INIT_SET_INT_C -#define BN_MP_INIT_SIZE_C -#define BN_MP_INVMOD_C -#define BN_MP_INVMOD_SLOW_C -#define BN_MP_IS_SQUARE_C -#define BN_MP_JACOBI_C -#define BN_MP_KARATSUBA_MUL_C -#define BN_MP_KARATSUBA_SQR_C -#define BN_MP_LCM_C -#define BN_MP_LSHD_C -#define BN_MP_MOD_C -#define BN_MP_MOD_2D_C -#define BN_MP_MOD_D_C -#define BN_MP_MONTGOMERY_CALC_NORMALIZATION_C -#define BN_MP_MONTGOMERY_REDUCE_C -#define BN_MP_MONTGOMERY_SETUP_C -#define BN_MP_MUL_C -#define BN_MP_MUL_2_C -#define BN_MP_MUL_2D_C -#define BN_MP_MUL_D_C -#define BN_MP_MULMOD_C -#define BN_MP_N_ROOT_C -#define BN_MP_NEG_C -#define BN_MP_OR_C -#define BN_MP_PRIME_FERMAT_C -#define BN_MP_PRIME_IS_DIVISIBLE_C -#define BN_MP_PRIME_IS_PRIME_C -#define BN_MP_PRIME_MILLER_RABIN_C -#define BN_MP_PRIME_NEXT_PRIME_C -#define BN_MP_PRIME_RABIN_MILLER_TRIALS_C -#define BN_MP_PRIME_RANDOM_EX_C -#define BN_MP_RADIX_SIZE_C -#define BN_MP_RADIX_SMAP_C -#define BN_MP_RAND_C -#define BN_MP_READ_RADIX_C -#define BN_MP_READ_SIGNED_BIN_C -#define BN_MP_READ_UNSIGNED_BIN_C -#define BN_MP_REDUCE_C -#define BN_MP_REDUCE_2K_C -#define BN_MP_REDUCE_2K_L_C -#define BN_MP_REDUCE_2K_SETUP_C -#define BN_MP_REDUCE_2K_SETUP_L_C -#define BN_MP_REDUCE_IS_2K_C -#define BN_MP_REDUCE_IS_2K_L_C -#define BN_MP_REDUCE_SETUP_C -#define BN_MP_RSHD_C -#define BN_MP_SET_C -#define BN_MP_SET_INT_C -#define BN_MP_SHRINK_C -#define BN_MP_SIGNED_BIN_SIZE_C -#define BN_MP_SQR_C -#define BN_MP_SQRMOD_C -#define BN_MP_SQRT_C -#define BN_MP_SUB_C -#define BN_MP_SUB_D_C -#define BN_MP_SUBMOD_C -#define BN_MP_TO_SIGNED_BIN_C -#define BN_MP_TO_SIGNED_BIN_N_C -#define BN_MP_TO_UNSIGNED_BIN_C -#define BN_MP_TO_UNSIGNED_BIN_N_C -#define BN_MP_TOOM_MUL_C -#define BN_MP_TOOM_SQR_C -#define BN_MP_TORADIX_C -#define BN_MP_TORADIX_N_C -#define BN_MP_UNSIGNED_BIN_SIZE_C -#define BN_MP_XOR_C -#define BN_MP_ZERO_C -#define BN_PRIME_TAB_C -#define BN_REVERSE_C -#define BN_S_MP_ADD_C -#define BN_S_MP_EXPTMOD_C -#define BN_S_MP_MUL_DIGS_C -#define BN_S_MP_MUL_HIGH_DIGS_C -#define BN_S_MP_SQR_C -#define BN_S_MP_SUB_C -#define BNCORE_C -#endif - -#if defined(BN_ERROR_C) - #define BN_MP_ERROR_TO_STRING_C -#endif - -#if defined(BN_FAST_MP_INVMOD_C) - #define BN_MP_ISEVEN_C - #define BN_MP_INIT_MULTI_C - #define BN_MP_COPY_C - #define BN_MP_MOD_C - #define BN_MP_SET_C - #define BN_MP_DIV_2_C - #define BN_MP_ISODD_C - #define BN_MP_SUB_C - #define BN_MP_CMP_C - #define BN_MP_ISZERO_C - #define BN_MP_CMP_D_C - #define BN_MP_ADD_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_MULTI_C -#endif - -#if defined(BN_FAST_MP_MONTGOMERY_REDUCE_C) - #define BN_MP_GROW_C - #define BN_MP_RSHD_C - #define BN_MP_CLAMP_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C -#endif - -#if defined(BN_FAST_S_MP_MUL_DIGS_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_FAST_S_MP_MUL_HIGH_DIGS_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_FAST_S_MP_SQR_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_2EXPT_C) - #define BN_MP_ZERO_C - #define BN_MP_GROW_C -#endif - -#if defined(BN_MP_ABS_C) - #define BN_MP_COPY_C -#endif - -#if defined(BN_MP_ADD_C) - #define BN_S_MP_ADD_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C -#endif - -#if defined(BN_MP_ADD_D_C) - #define BN_MP_GROW_C - #define BN_MP_SUB_D_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_ADDMOD_C) - #define BN_MP_INIT_C - #define BN_MP_ADD_C - #define BN_MP_CLEAR_C - #define BN_MP_MOD_C -#endif - -#if defined(BN_MP_AND_C) - #define BN_MP_INIT_COPY_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_CLAMP_C) -#endif - -#if defined(BN_MP_CLEAR_C) -#endif - -#if defined(BN_MP_CLEAR_MULTI_C) - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_CMP_C) - #define BN_MP_CMP_MAG_C -#endif - -#if defined(BN_MP_CMP_D_C) -#endif - -#if defined(BN_MP_CMP_MAG_C) -#endif - -#if defined(BN_MP_CNT_LSB_C) - #define BN_MP_ISZERO_C -#endif - -#if defined(BN_MP_COPY_C) - #define BN_MP_GROW_C -#endif - -#if defined(BN_MP_COUNT_BITS_C) -#endif - -#if defined(BN_MP_DIV_C) - #define BN_MP_ISZERO_C - #define BN_MP_CMP_MAG_C - #define BN_MP_COPY_C - #define BN_MP_ZERO_C - #define BN_MP_INIT_MULTI_C - #define BN_MP_SET_C - #define BN_MP_COUNT_BITS_C - #define BN_MP_ABS_C - #define BN_MP_MUL_2D_C - #define BN_MP_CMP_C - #define BN_MP_SUB_C - #define BN_MP_ADD_C - #define BN_MP_DIV_2D_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_MULTI_C - #define BN_MP_INIT_SIZE_C - #define BN_MP_INIT_C - #define BN_MP_INIT_COPY_C - #define BN_MP_LSHD_C - #define BN_MP_RSHD_C - #define BN_MP_MUL_D_C - #define BN_MP_CLAMP_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_DIV_2_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_DIV_2D_C) - #define BN_MP_COPY_C - #define BN_MP_ZERO_C - #define BN_MP_INIT_C - #define BN_MP_MOD_2D_C - #define BN_MP_CLEAR_C - #define BN_MP_RSHD_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C -#endif - -#if defined(BN_MP_DIV_3_C) - #define BN_MP_INIT_SIZE_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_DIV_D_C) - #define BN_MP_ISZERO_C - #define BN_MP_COPY_C - #define BN_MP_DIV_2D_C - #define BN_MP_DIV_3_C - #define BN_MP_INIT_SIZE_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_DR_IS_MODULUS_C) -#endif - -#if defined(BN_MP_DR_REDUCE_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C -#endif - -#if defined(BN_MP_DR_SETUP_C) -#endif - -#if defined(BN_MP_EXCH_C) -#endif - -#if defined(BN_MP_EXPT_D_C) - #define BN_MP_INIT_COPY_C - #define BN_MP_SET_C - #define BN_MP_SQR_C - #define BN_MP_CLEAR_C - #define BN_MP_MUL_C -#endif - -#if defined(BN_MP_EXPTMOD_C) - #define BN_MP_INIT_C - #define BN_MP_INVMOD_C - #define BN_MP_CLEAR_C - #define BN_MP_ABS_C - #define BN_MP_CLEAR_MULTI_C - #define BN_MP_REDUCE_IS_2K_L_C - #define BN_S_MP_EXPTMOD_C - #define BN_MP_DR_IS_MODULUS_C - #define BN_MP_REDUCE_IS_2K_C - #define BN_MP_ISODD_C - #define BN_MP_EXPTMOD_FAST_C -#endif - -#if defined(BN_MP_EXPTMOD_FAST_C) - #define BN_MP_COUNT_BITS_C - #define BN_MP_INIT_C - #define BN_MP_CLEAR_C - #define BN_MP_MONTGOMERY_SETUP_C - #define BN_FAST_MP_MONTGOMERY_REDUCE_C - #define BN_MP_MONTGOMERY_REDUCE_C - #define BN_MP_DR_SETUP_C - #define BN_MP_DR_REDUCE_C - #define BN_MP_REDUCE_2K_SETUP_C - #define BN_MP_REDUCE_2K_C - #define BN_MP_MONTGOMERY_CALC_NORMALIZATION_C - #define BN_MP_MULMOD_C - #define BN_MP_SET_C - #define BN_MP_MOD_C - #define BN_MP_COPY_C - #define BN_MP_SQR_C - #define BN_MP_MUL_C - #define BN_MP_EXCH_C -#endif - -#if defined(BN_MP_EXTEUCLID_C) - #define BN_MP_INIT_MULTI_C - #define BN_MP_SET_C - #define BN_MP_COPY_C - #define BN_MP_ISZERO_C - #define BN_MP_DIV_C - #define BN_MP_MUL_C - #define BN_MP_SUB_C - #define BN_MP_NEG_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_MULTI_C -#endif - -#if defined(BN_MP_FREAD_C) - #define BN_MP_ZERO_C - #define BN_MP_S_RMAP_C - #define BN_MP_MUL_D_C - #define BN_MP_ADD_D_C - #define BN_MP_CMP_D_C -#endif - -#if defined(BN_MP_FWRITE_C) - #define BN_MP_RADIX_SIZE_C - #define BN_MP_TORADIX_C -#endif - -#if defined(BN_MP_GCD_C) - #define BN_MP_ISZERO_C - #define BN_MP_ABS_C - #define BN_MP_ZERO_C - #define BN_MP_INIT_COPY_C - #define BN_MP_CNT_LSB_C - #define BN_MP_DIV_2D_C - #define BN_MP_CMP_MAG_C - #define BN_MP_EXCH_C - #define BN_S_MP_SUB_C - #define BN_MP_MUL_2D_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_GET_INT_C) -#endif - -#if defined(BN_MP_GROW_C) -#endif - -#if defined(BN_MP_INIT_C) -#endif - -#if defined(BN_MP_INIT_COPY_C) - #define BN_MP_COPY_C -#endif - -#if defined(BN_MP_INIT_MULTI_C) - #define BN_MP_ERR_C - #define BN_MP_INIT_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_INIT_SET_C) - #define BN_MP_INIT_C - #define BN_MP_SET_C -#endif - -#if defined(BN_MP_INIT_SET_INT_C) - #define BN_MP_INIT_C - #define BN_MP_SET_INT_C -#endif - -#if defined(BN_MP_INIT_SIZE_C) - #define BN_MP_INIT_C -#endif - -#if defined(BN_MP_INVMOD_C) - #define BN_MP_ISZERO_C - #define BN_MP_ISODD_C - #define BN_FAST_MP_INVMOD_C - #define BN_MP_INVMOD_SLOW_C -#endif - -#if defined(BN_MP_INVMOD_SLOW_C) - #define BN_MP_ISZERO_C - #define BN_MP_INIT_MULTI_C - #define BN_MP_MOD_C - #define BN_MP_COPY_C - #define BN_MP_ISEVEN_C - #define BN_MP_SET_C - #define BN_MP_DIV_2_C - #define BN_MP_ISODD_C - #define BN_MP_ADD_C - #define BN_MP_SUB_C - #define BN_MP_CMP_C - #define BN_MP_CMP_D_C - #define BN_MP_CMP_MAG_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_MULTI_C -#endif - -#if defined(BN_MP_IS_SQUARE_C) - #define BN_MP_MOD_D_C - #define BN_MP_INIT_SET_INT_C - #define BN_MP_MOD_C - #define BN_MP_GET_INT_C - #define BN_MP_SQRT_C - #define BN_MP_SQR_C - #define BN_MP_CMP_MAG_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_JACOBI_C) - #define BN_MP_CMP_D_C - #define BN_MP_ISZERO_C - #define BN_MP_INIT_COPY_C - #define BN_MP_CNT_LSB_C - #define BN_MP_DIV_2D_C - #define BN_MP_MOD_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_KARATSUBA_MUL_C) - #define BN_MP_MUL_C - #define BN_MP_INIT_SIZE_C - #define BN_MP_CLAMP_C - #define BN_MP_SUB_C - #define BN_MP_ADD_C - #define BN_MP_LSHD_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_KARATSUBA_SQR_C) - #define BN_MP_INIT_SIZE_C - #define BN_MP_CLAMP_C - #define BN_MP_SQR_C - #define BN_MP_SUB_C - #define BN_S_MP_ADD_C - #define BN_MP_LSHD_C - #define BN_MP_ADD_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_LCM_C) - #define BN_MP_INIT_MULTI_C - #define BN_MP_GCD_C - #define BN_MP_CMP_MAG_C - #define BN_MP_DIV_C - #define BN_MP_MUL_C - #define BN_MP_CLEAR_MULTI_C -#endif - -#if defined(BN_MP_LSHD_C) - #define BN_MP_GROW_C - #define BN_MP_RSHD_C -#endif - -#if defined(BN_MP_MOD_C) - #define BN_MP_INIT_C - #define BN_MP_DIV_C - #define BN_MP_CLEAR_C - #define BN_MP_ADD_C - #define BN_MP_EXCH_C -#endif - -#if defined(BN_MP_MOD_2D_C) - #define BN_MP_ZERO_C - #define BN_MP_COPY_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_MOD_D_C) - #define BN_MP_DIV_D_C -#endif - -#if defined(BN_MP_MONTGOMERY_CALC_NORMALIZATION_C) - #define BN_MP_COUNT_BITS_C - #define BN_MP_2EXPT_C - #define BN_MP_SET_C - #define BN_MP_MUL_2_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C -#endif - -#if defined(BN_MP_MONTGOMERY_REDUCE_C) - #define BN_FAST_MP_MONTGOMERY_REDUCE_C - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C - #define BN_MP_RSHD_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C -#endif - -#if defined(BN_MP_MONTGOMERY_SETUP_C) -#endif - -#if defined(BN_MP_MUL_C) - #define BN_MP_TOOM_MUL_C - #define BN_MP_KARATSUBA_MUL_C - #define BN_FAST_S_MP_MUL_DIGS_C - #define BN_S_MP_MUL_C - #define BN_S_MP_MUL_DIGS_C -#endif - -#if defined(BN_MP_MUL_2_C) - #define BN_MP_GROW_C -#endif - -#if defined(BN_MP_MUL_2D_C) - #define BN_MP_COPY_C - #define BN_MP_GROW_C - #define BN_MP_LSHD_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_MUL_D_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_MULMOD_C) - #define BN_MP_INIT_C - #define BN_MP_MUL_C - #define BN_MP_CLEAR_C - #define BN_MP_MOD_C -#endif - -#if defined(BN_MP_N_ROOT_C) - #define BN_MP_INIT_C - #define BN_MP_SET_C - #define BN_MP_COPY_C - #define BN_MP_EXPT_D_C - #define BN_MP_MUL_C - #define BN_MP_SUB_C - #define BN_MP_MUL_D_C - #define BN_MP_DIV_C - #define BN_MP_CMP_C - #define BN_MP_SUB_D_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_NEG_C) - #define BN_MP_COPY_C - #define BN_MP_ISZERO_C -#endif - -#if defined(BN_MP_OR_C) - #define BN_MP_INIT_COPY_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_PRIME_FERMAT_C) - #define BN_MP_CMP_D_C - #define BN_MP_INIT_C - #define BN_MP_EXPTMOD_C - #define BN_MP_CMP_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_PRIME_IS_DIVISIBLE_C) - #define BN_MP_MOD_D_C -#endif - -#if defined(BN_MP_PRIME_IS_PRIME_C) - #define BN_MP_CMP_D_C - #define BN_MP_PRIME_IS_DIVISIBLE_C - #define BN_MP_INIT_C - #define BN_MP_SET_C - #define BN_MP_PRIME_MILLER_RABIN_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_PRIME_MILLER_RABIN_C) - #define BN_MP_CMP_D_C - #define BN_MP_INIT_COPY_C - #define BN_MP_SUB_D_C - #define BN_MP_CNT_LSB_C - #define BN_MP_DIV_2D_C - #define BN_MP_EXPTMOD_C - #define BN_MP_CMP_C - #define BN_MP_SQRMOD_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_PRIME_NEXT_PRIME_C) - #define BN_MP_CMP_D_C - #define BN_MP_SET_C - #define BN_MP_SUB_D_C - #define BN_MP_ISEVEN_C - #define BN_MP_MOD_D_C - #define BN_MP_INIT_C - #define BN_MP_ADD_D_C - #define BN_MP_PRIME_MILLER_RABIN_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_PRIME_RABIN_MILLER_TRIALS_C) -#endif - -#if defined(BN_MP_PRIME_RANDOM_EX_C) - #define BN_MP_READ_UNSIGNED_BIN_C - #define BN_MP_PRIME_IS_PRIME_C - #define BN_MP_SUB_D_C - #define BN_MP_DIV_2_C - #define BN_MP_MUL_2_C - #define BN_MP_ADD_D_C -#endif - -#if defined(BN_MP_RADIX_SIZE_C) - #define BN_MP_COUNT_BITS_C - #define BN_MP_INIT_COPY_C - #define BN_MP_ISZERO_C - #define BN_MP_DIV_D_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_RADIX_SMAP_C) - #define BN_MP_S_RMAP_C -#endif - -#if defined(BN_MP_RAND_C) - #define BN_MP_ZERO_C - #define BN_MP_ADD_D_C - #define BN_MP_LSHD_C -#endif - -#if defined(BN_MP_READ_RADIX_C) - #define BN_MP_ZERO_C - #define BN_MP_S_RMAP_C - #define BN_MP_RADIX_SMAP_C - #define BN_MP_MUL_D_C - #define BN_MP_ADD_D_C - #define BN_MP_ISZERO_C -#endif - -#if defined(BN_MP_READ_SIGNED_BIN_C) - #define BN_MP_READ_UNSIGNED_BIN_C -#endif - -#if defined(BN_MP_READ_UNSIGNED_BIN_C) - #define BN_MP_GROW_C - #define BN_MP_ZERO_C - #define BN_MP_MUL_2D_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_REDUCE_C) - #define BN_MP_REDUCE_SETUP_C - #define BN_MP_INIT_COPY_C - #define BN_MP_RSHD_C - #define BN_MP_MUL_C - #define BN_S_MP_MUL_HIGH_DIGS_C - #define BN_FAST_S_MP_MUL_HIGH_DIGS_C - #define BN_MP_MOD_2D_C - #define BN_S_MP_MUL_DIGS_C - #define BN_MP_SUB_C - #define BN_MP_CMP_D_C - #define BN_MP_SET_C - #define BN_MP_LSHD_C - #define BN_MP_ADD_C - #define BN_MP_CMP_C - #define BN_S_MP_SUB_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_REDUCE_2K_C) - #define BN_MP_INIT_C - #define BN_MP_COUNT_BITS_C - #define BN_MP_DIV_2D_C - #define BN_MP_MUL_D_C - #define BN_S_MP_ADD_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_REDUCE_2K_L_C) - #define BN_MP_INIT_C - #define BN_MP_COUNT_BITS_C - #define BN_MP_DIV_2D_C - #define BN_MP_MUL_C - #define BN_S_MP_ADD_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_REDUCE_2K_SETUP_C) - #define BN_MP_INIT_C - #define BN_MP_COUNT_BITS_C - #define BN_MP_2EXPT_C - #define BN_MP_CLEAR_C - #define BN_S_MP_SUB_C -#endif - -#if defined(BN_MP_REDUCE_2K_SETUP_L_C) - #define BN_MP_INIT_C - #define BN_MP_2EXPT_C - #define BN_MP_COUNT_BITS_C - #define BN_S_MP_SUB_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_REDUCE_IS_2K_C) - #define BN_MP_REDUCE_2K_C - #define BN_MP_COUNT_BITS_C -#endif - -#if defined(BN_MP_REDUCE_IS_2K_L_C) -#endif - -#if defined(BN_MP_REDUCE_SETUP_C) - #define BN_MP_2EXPT_C - #define BN_MP_DIV_C -#endif - -#if defined(BN_MP_RSHD_C) - #define BN_MP_ZERO_C -#endif - -#if defined(BN_MP_SET_C) - #define BN_MP_ZERO_C -#endif - -#if defined(BN_MP_SET_INT_C) - #define BN_MP_ZERO_C - #define BN_MP_MUL_2D_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_SHRINK_C) -#endif - -#if defined(BN_MP_SIGNED_BIN_SIZE_C) - #define BN_MP_UNSIGNED_BIN_SIZE_C -#endif - -#if defined(BN_MP_SQR_C) - #define BN_MP_TOOM_SQR_C - #define BN_MP_KARATSUBA_SQR_C - #define BN_FAST_S_MP_SQR_C - #define BN_S_MP_SQR_C -#endif - -#if defined(BN_MP_SQRMOD_C) - #define BN_MP_INIT_C - #define BN_MP_SQR_C - #define BN_MP_CLEAR_C - #define BN_MP_MOD_C -#endif - -#if defined(BN_MP_SQRT_C) - #define BN_MP_N_ROOT_C - #define BN_MP_ISZERO_C - #define BN_MP_ZERO_C - #define BN_MP_INIT_COPY_C - #define BN_MP_RSHD_C - #define BN_MP_DIV_C - #define BN_MP_ADD_C - #define BN_MP_DIV_2_C - #define BN_MP_CMP_MAG_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_SUB_C) - #define BN_S_MP_ADD_C - #define BN_MP_CMP_MAG_C - #define BN_S_MP_SUB_C -#endif - -#if defined(BN_MP_SUB_D_C) - #define BN_MP_GROW_C - #define BN_MP_ADD_D_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_MP_SUBMOD_C) - #define BN_MP_INIT_C - #define BN_MP_SUB_C - #define BN_MP_CLEAR_C - #define BN_MP_MOD_C -#endif - -#if defined(BN_MP_TO_SIGNED_BIN_C) - #define BN_MP_TO_UNSIGNED_BIN_C -#endif - -#if defined(BN_MP_TO_SIGNED_BIN_N_C) - #define BN_MP_SIGNED_BIN_SIZE_C - #define BN_MP_TO_SIGNED_BIN_C -#endif - -#if defined(BN_MP_TO_UNSIGNED_BIN_C) - #define BN_MP_INIT_COPY_C - #define BN_MP_ISZERO_C - #define BN_MP_DIV_2D_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_TO_UNSIGNED_BIN_N_C) - #define BN_MP_UNSIGNED_BIN_SIZE_C - #define BN_MP_TO_UNSIGNED_BIN_C -#endif - -#if defined(BN_MP_TOOM_MUL_C) - #define BN_MP_INIT_MULTI_C - #define BN_MP_MOD_2D_C - #define BN_MP_COPY_C - #define BN_MP_RSHD_C - #define BN_MP_MUL_C - #define BN_MP_MUL_2_C - #define BN_MP_ADD_C - #define BN_MP_SUB_C - #define BN_MP_DIV_2_C - #define BN_MP_MUL_2D_C - #define BN_MP_MUL_D_C - #define BN_MP_DIV_3_C - #define BN_MP_LSHD_C - #define BN_MP_CLEAR_MULTI_C -#endif - -#if defined(BN_MP_TOOM_SQR_C) - #define BN_MP_INIT_MULTI_C - #define BN_MP_MOD_2D_C - #define BN_MP_COPY_C - #define BN_MP_RSHD_C - #define BN_MP_SQR_C - #define BN_MP_MUL_2_C - #define BN_MP_ADD_C - #define BN_MP_SUB_C - #define BN_MP_DIV_2_C - #define BN_MP_MUL_2D_C - #define BN_MP_MUL_D_C - #define BN_MP_DIV_3_C - #define BN_MP_LSHD_C - #define BN_MP_CLEAR_MULTI_C -#endif - -#if defined(BN_MP_TORADIX_C) - #define BN_MP_ISZERO_C - #define BN_MP_INIT_COPY_C - #define BN_MP_DIV_D_C - #define BN_MP_CLEAR_C - #define BN_MP_S_RMAP_C -#endif - -#if defined(BN_MP_TORADIX_N_C) - #define BN_MP_ISZERO_C - #define BN_MP_INIT_COPY_C - #define BN_MP_DIV_D_C - #define BN_MP_CLEAR_C - #define BN_MP_S_RMAP_C -#endif - -#if defined(BN_MP_UNSIGNED_BIN_SIZE_C) - #define BN_MP_COUNT_BITS_C -#endif - -#if defined(BN_MP_XOR_C) - #define BN_MP_INIT_COPY_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_MP_ZERO_C) -#endif - -#if defined(BN_PRIME_TAB_C) -#endif - -#if defined(BN_REVERSE_C) -#endif - -#if defined(BN_S_MP_ADD_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BN_S_MP_EXPTMOD_C) - #define BN_MP_COUNT_BITS_C - #define BN_MP_INIT_C - #define BN_MP_CLEAR_C - #define BN_MP_REDUCE_SETUP_C - #define BN_MP_REDUCE_C - #define BN_MP_REDUCE_2K_SETUP_L_C - #define BN_MP_REDUCE_2K_L_C - #define BN_MP_MOD_C - #define BN_MP_COPY_C - #define BN_MP_SQR_C - #define BN_MP_MUL_C - #define BN_MP_SET_C - #define BN_MP_EXCH_C -#endif - -#if defined(BN_S_MP_MUL_DIGS_C) - #define BN_FAST_S_MP_MUL_DIGS_C - #define BN_MP_INIT_SIZE_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_S_MP_MUL_HIGH_DIGS_C) - #define BN_FAST_S_MP_MUL_HIGH_DIGS_C - #define BN_MP_INIT_SIZE_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_S_MP_SQR_C) - #define BN_MP_INIT_SIZE_C - #define BN_MP_CLAMP_C - #define BN_MP_EXCH_C - #define BN_MP_CLEAR_C -#endif - -#if defined(BN_S_MP_SUB_C) - #define BN_MP_GROW_C - #define BN_MP_CLAMP_C -#endif - -#if defined(BNCORE_C) -#endif - -#ifdef LTM3 -#define LTM_LAST -#endif -#include "mpi_superclass.h" -#include "mpi_class.h" -#else -#define LTM_LAST -#endif +#include diff --git a/cyassl/ctaocrypt/mpi_superclass.h b/cyassl/ctaocrypt/mpi_superclass.h index a86eb0e2c..725849c1b 100644 --- a/cyassl/ctaocrypt/mpi_superclass.h +++ b/cyassl/ctaocrypt/mpi_superclass.h @@ -22,74 +22,5 @@ /* super class file for PK algos */ -/* default ... include all MPI */ -#define LTM_ALL - -/* RSA only (does not support DH/DSA/ECC) */ -/* #define SC_RSA_1 */ - -/* For reference.... On an Athlon64 optimizing for speed... - - LTM's mpi.o with all functions [striped] is 142KiB in size. - -*/ - -/* Works for RSA only, mpi.o is 68KiB */ -#ifdef SC_RSA_1 - #define BN_MP_SHRINK_C - #define BN_MP_LCM_C - #define BN_MP_PRIME_RANDOM_EX_C - #define BN_MP_INVMOD_C - #define BN_MP_GCD_C - #define BN_MP_MOD_C - #define BN_MP_MULMOD_C - #define BN_MP_ADDMOD_C - #define BN_MP_EXPTMOD_C - #define BN_MP_SET_INT_C - #define BN_MP_INIT_MULTI_C - #define BN_MP_CLEAR_MULTI_C - #define BN_MP_UNSIGNED_BIN_SIZE_C - #define BN_MP_TO_UNSIGNED_BIN_C - #define BN_MP_MOD_D_C - #define BN_MP_PRIME_RABIN_MILLER_TRIALS_C - #define BN_REVERSE_C - #define BN_PRIME_TAB_C - - /* other modifiers */ - #define BN_MP_DIV_SMALL /* Slower division, not critical */ - - /* here we are on the last pass so we turn things off. The functions classes are still there - * but we remove them specifically from the build. This also invokes tweaks in functions - * like removing support for even moduli, etc... - */ -#ifdef LTM_LAST - #undef BN_MP_TOOM_MUL_C - #undef BN_MP_TOOM_SQR_C - #undef BN_MP_KARATSUBA_MUL_C - #undef BN_MP_KARATSUBA_SQR_C - #undef BN_MP_REDUCE_C - #undef BN_MP_REDUCE_SETUP_C - #undef BN_MP_DR_IS_MODULUS_C - #undef BN_MP_DR_SETUP_C - #undef BN_MP_DR_REDUCE_C - #undef BN_MP_REDUCE_IS_2K_C - #undef BN_MP_REDUCE_2K_SETUP_C - #undef BN_MP_REDUCE_2K_C - #undef BN_S_MP_EXPTMOD_C - #undef BN_MP_DIV_3_C - #undef BN_S_MP_MUL_HIGH_DIGS_C - #undef BN_FAST_S_MP_MUL_HIGH_DIGS_C - #undef BN_FAST_MP_INVMOD_C - - /* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold - * which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines] - * which means roughly speaking you can handle upto 2536-bit RSA keys with these defined without - * trouble. - */ - #undef BN_S_MP_MUL_DIGS_C - #undef BN_S_MP_SQR_C - #undef BN_MP_MONTGOMERY_REDUCE_C -#endif - -#endif +#include diff --git a/cyassl/ctaocrypt/pwdbased.h b/cyassl/ctaocrypt/pwdbased.h index 4d9dee21f..8bf295ae1 100644 --- a/cyassl/ctaocrypt/pwdbased.h +++ b/cyassl/ctaocrypt/pwdbased.h @@ -33,3 +33,4 @@ #endif /* CTAO_CRYPT_PWDBASED_H */ #endif /* NO_PWDBASED */ + diff --git a/cyassl/ctaocrypt/ripemd.h b/cyassl/ctaocrypt/ripemd.h index 61d84b984..4ceb7be2a 100644 --- a/cyassl/ctaocrypt/ripemd.h +++ b/cyassl/ctaocrypt/ripemd.h @@ -20,7 +20,6 @@ */ -#ifdef CYASSL_RIPEMD #ifndef CTAO_CRYPT_RIPEMD_H #define CTAO_CRYPT_RIPEME_H @@ -29,12 +28,10 @@ /* for ripemd reverse compatibility */ #ifdef WOLFSSL_RIPEMD - #define CYASSL_RIPEMD /* @TODO */ #define InitRipeMd wc_InitRipeMd #define RipeMdUpdate wc_RipeMdUpdate #define RipeMdFinal wc_RipeMdFinal #endif #endif /* CTAO_CRYPT_RIPEMD_H */ -#endif /* CYASSL_RIPEMD */ diff --git a/cyassl/ctaocrypt/settings_comp.h b/cyassl/ctaocrypt/settings_comp.h index 9fa1c2734..bd96da2a2 100644 --- a/cyassl/ctaocrypt/settings_comp.h +++ b/cyassl/ctaocrypt/settings_comp.h @@ -22,6 +22,11 @@ #ifndef CTAO_CRYPT_SETTINGS_C_H #define CTAO_CRYPT_SETTINGS_C_H +/* asn.c compatibility */ +#define RsaPrivateKeyDecode wc_RsaPrivateKeyDecode +#define RsaPublicKeyDecode wc_RsaPublicKeyDecode +#define RsaPublicKeyDecodeRaw wc_RsaPublicKeyDecodeRaw + /* Macro redefinitions for compatibility */ #if defined(WOLFSSL_SHA512) && !defined(CYASSL_SHA512) #define CYASSL_SHA512 @@ -36,11 +41,6 @@ #define NO_CYASSL_MEMORY #endif -/* asn.c compatibility */ -#define RsaPrivateKeyDecode wc_RsaPrivateKeyDecode -#define RsaPublicKeyDecode wc_RsaPublicKeyDecode -#define RsaPublicKeyDecodeRaw wc_RsaPublicKeyDecodeRaw - /* These are compatibility from fips protected headers * When using non-fips mode and including old headers this allows for * using old function calls diff --git a/cyassl/ctaocrypt/types.h b/cyassl/ctaocrypt/types.h index 6932aa325..700e56eac 100644 --- a/cyassl/ctaocrypt/types.h +++ b/cyassl/ctaocrypt/types.h @@ -25,20 +25,16 @@ #include #include - #include - /* compatibility macros */ - #define CYASSL_WORD_SIZE WOLFSSL_WORD_SIZE - #define CYASSL_BIT_SIZE WOLFSSL_BIT_SIZE - #define CYASSL_MAX_16BIT WOLFSSL_MAX_16BIT - #define CYASSL_MAX_ERROR_SZ WOLFSSL_MAX_ERROR_SZ - #define cyassl_word wolfssl_word -// /* set old macros since this is often called for visibility also */ -// #ifndef WOLFSSL_API -// #define WOLFSSL_API CYASSL_API -// #endif -// #ifndef WOLFSSL_LOCAL -// #define WOLFSSL_LOCAL CYASSL_LOCAL -// #endif +#include + +/* compatibility macros */ +#define CYASSL_WORD_SIZE WOLFSSL_WORD_SIZE +#define CYASSL_BIT_SIZE WOLFSSL_BIT_SIZE +#define CYASSL_MAX_16BIT WOLFSSL_MAX_16BIT +#define CYASSL_MAX_ERROR_SZ WOLFSSL_MAX_ERROR_SZ +#define cyassl_word wolfssl_word + +/* if macros need to be reverted back to previous name for fips */ // #define WOLFSSL_MAX_ERROR_SZ CYASSL_MAX_ERROR_SZ // // #define WOLFSSL_WORD_SIZE CYASSL_WORD_SIZE @@ -52,10 +48,11 @@ // #define wolfSSL_Free_cb CyaSSL_Free_cb // #define wolfSSL_Realloc_cb CyaSSL_Realloc_cb // #define wolfSSL_SetAllocators CyaSSL_SetAllocators -// +// // /* Public in case user app wants to use XMALLOC/XFREE */ // #define wolfSSL_Malloc CyaSSL_Malloc // #define wolfSSL_Free CyaSSL_Free // #define wolfSSL_Realloc CyaSSL_Realloc + #endif /* CTAO_CRYPT_TYPES_H */ diff --git a/sslSniffer/sslSnifferTest/snifftest.c b/sslSniffer/sslSnifferTest/snifftest.c index af3bd1dc6..ffb724493 100755 --- a/sslSniffer/sslSnifferTest/snifftest.c +++ b/sslSniffer/sslSnifferTest/snifftest.c @@ -23,13 +23,13 @@ #include #endif -#include +#include #ifdef _WIN32 - #define CYASSL_SNIFFER + #define WOLFSSL_SNIFFER #endif -#ifndef CYASSL_SNIFFER +#ifndef WOLFSSL_SNIFFER /* blank build */ #include diff --git a/wolfssl/wolfcrypt/asn_public.h b/wolfssl/wolfcrypt/asn_public.h index 579861378..e0d3da156 100644 --- a/wolfssl/wolfcrypt/asn_public.h +++ b/wolfssl/wolfcrypt/asn_public.h @@ -29,57 +29,10 @@ #include #endif -/* compatibility for fips @wc_fips */ -#ifdef HAVE_FIPS - #include - #ifdef WOLFSSL_CERT_GEN - #define wc_InitCert InitCert - #define wc_MakeCert MakeCert - - #ifdef WOLFSSL_CERT_REQ - #define wc_MakeCertReq MakeCertReq - #endif - - #define wc_SignCert SignCert - #define wc_MakeSelfCert MakeSelfCert - #define wc_SetIssuer SetIssuer - #define wc_SetSubject SetSubject - - #ifdef WOLFSSL_ALT_NAMES - #define wc_SetAltNames SetAltNames - #endif - - #define wc_SetIssuerBuffer SetIssuerBuffer - #define wc_SetSubjectBuffer SetSubjectBuffer - #define wc_SetAltNamesBuffer SetAltNamesBuffer - #define wc_SetDatesBuffer SetDatesBuffer - - #ifdef HAVE_NTRU - #define wc_MakeNtruCert MakeNtruCert - #endif - - #endif /* WOLFSSL_CERT_GEN */ - - #if defined(WOLFSSL_KEY_GEN) || defined(WOLFSSL_CERT_GEN) - #define wc_DerToPem DerToPem - #endif - - #ifdef HAVE_ECC - /* private key helpers */ - #define wc_EccPrivateKeyDecode EccPrivateKeyDecode - #define wc_EccKeyToDer EccKeyToDer - #endif - - /* DER encode signature */ - #define wc_EncodeSignature EncodeSignature - #define wc_GetCTC_HashOID GetCTC_HashOID -#endif /* HAVE_FIPS */ - #ifdef __cplusplus extern "C" { #endif -#ifndef HAVE_FIPS /* Certificate file Type */ enum CertType { CERT_TYPE = 0, @@ -171,7 +124,6 @@ typedef struct Cert { #endif } Cert; #endif /* WOLFSSL_CERT_GEN */ -#endif /* HAVE_FIPS */ #ifdef WOLFSSL_CERT_GEN