old cyassl header files adjusted

pull/1/head
Jacob Barthelmeh 2015-01-07 13:11:37 -07:00
parent 4008bec496
commit f516bcf1ce
14 changed files with 62 additions and 1719 deletions

View File

@ -25,6 +25,7 @@
#define CTAO_CRYPT_ASN_H
#include <wolfssl/wolfcrypt/asn.h>
#ifndef WOLFSSL_PEMCERT_TODER_DEFINED
#ifndef NO_FILESYSTEM
#define CyaSSL_PemCertToDer wolfSSL_PemCertToDer

View File

@ -24,171 +24,48 @@
#define CTAO_CRYPT_ASN_PUBLIC_H
#include <cyassl/ctaocrypt/types.h>
#include <cyassl/ctaocrypt/ecc.h>
#ifdef CYASSL_CERT_GEN
#include <cyassl/ctaocrypt/rsa.h>
#include <wolfssl/wolfrypt/asn_public.h>
#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 */

View File

@ -36,119 +36,7 @@
#define CTAOCRYPT_BLAKE2_IMPL_H
#include <cyassl/ctaocrypt/types.h>
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 <wolfssl/wolfcrypt/blake2_impl.h>
#endif /* CTAOCRYPT_BLAKE2_IMPL_H */

View File

@ -37,147 +37,7 @@
#define CTAOCRYPT_BLAKE2_INT_H
#include <cyassl/ctaocrypt/types.h>
#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 <wolfssl/wolfcrypt/blake2_int.h>
#endif /* CTAOCRYPT_BLAKE2_INT_H */

View File

@ -25,15 +25,15 @@
#ifndef CTAO_CRYPT_DH_H
#define CTAO_CRYPT_DH_H
/* for dh reverse compatibility */
#include <wolfssl/wolfcrypt/dh.h>
#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 <wolfssl/wolfcrypt/dh.h>
#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 */

View File

@ -58,172 +58,6 @@
#endif /* HAVE_ECC_ENCRYPT */
#endif
//
//#include <cyassl/ctaocrypt/types.h>
//#include <cyassl/ctaocrypt/integer.h>
//#include <cyassl/ctaocrypt/random.h>
//
//#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 */

File diff suppressed because it is too large Load Diff

View File

@ -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 <wolfssl/wolfcrypt/mpi_superclass.h>

View File

@ -33,3 +33,4 @@
#endif /* CTAO_CRYPT_PWDBASED_H */
#endif /* NO_PWDBASED */

View File

@ -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 */

View File

@ -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

View File

@ -25,20 +25,16 @@
#include <cyassl/ctaocrypt/wc_port.h>
#include <cyassl/ctaocrypt/settings.h>
#include <wolfssl/wolfcrypt/types.h>
/* 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 <wolfssl/wolfcrypt/types.h>
/* 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 */

View File

@ -23,13 +23,13 @@
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#include <wolfssl/wolfcrypt/settings.h>
#ifdef _WIN32
#define CYASSL_SNIFFER
#define WOLFSSL_SNIFFER
#endif
#ifndef CYASSL_SNIFFER
#ifndef WOLFSSL_SNIFFER
/* blank build */
#include <stdio.h>

View File

@ -29,57 +29,10 @@
#include <wolfssl/wolfcrypt/rsa.h>
#endif
/* compatibility for fips @wc_fips */
#ifdef HAVE_FIPS
#include <cyassl/ctaocrypt/asn_public.h>
#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