adjust cyassl headders

This commit is contained in:
Jacob Barthelmeh 2015-01-07 14:30:28 -07:00
parent 02f16b9232
commit 455db9f84b
16 changed files with 11 additions and 894 deletions

View File

@ -25,171 +25,7 @@
#ifndef CTAO_CRYPT_AES_H
#define CTAO_CRYPT_AES_H
#include <cyassl/ctaocrypt/types.h>
#ifdef HAVE_CAVIUM
#include <cyassl/ctaocrypt/logging.h>
#include "cavium_common.h"
#endif
#ifdef CYASSL_AESNI
#include <wmmintrin.h>
#if !defined (ALIGN16)
#if defined (__GNUC__)
#define ALIGN16 __attribute__ ( (aligned (16)))
#elif defined(_MSC_VER)
/* disable align warning, we want alignment ! */
#pragma warning(disable: 4324)
#define ALIGN16 __declspec (align (16))
#else
#define ALIGN16
#endif
#endif
#endif /* CYASSL_AESNI */
#if !defined (ALIGN16)
#define ALIGN16
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define CYASSL_AES_CAVIUM_MAGIC 0xBEEF0002
enum {
AES_ENC_TYPE = 1, /* cipher unique type */
AES_ENCRYPTION = 0,
AES_DECRYPTION = 1,
AES_BLOCK_SIZE = 16
};
typedef struct Aes {
/* AESNI needs key first, rounds 2nd, not sure why yet */
ALIGN16 word32 key[60];
word32 rounds;
ALIGN16 word32 reg[AES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
ALIGN16 word32 tmp[AES_BLOCK_SIZE / sizeof(word32)]; /* same */
#ifdef HAVE_AESGCM
ALIGN16 byte H[AES_BLOCK_SIZE];
#ifdef GCM_TABLE
/* key-based fast multiplication table. */
ALIGN16 byte M0[256][AES_BLOCK_SIZE];
#endif /* GCM_TABLE */
#endif /* HAVE_AESGCM */
#ifdef CYASSL_AESNI
byte use_aesni;
#endif /* CYASSL_AESNI */
#ifdef HAVE_CAVIUM
AesType type; /* aes key type */
int devId; /* nitrox device id */
word32 magic; /* using cavium magic */
word64 contextHandle; /* nitrox context memory handle */
#endif
#ifdef CYASSL_AES_COUNTER
word32 left; /* unsued bytes left from last call */
#endif
#ifdef CYASSL_PIC32MZ_CRYPT
word32 key_ce[AES_BLOCK_SIZE*2/sizeof(word32)] ;
word32 iv_ce [AES_BLOCK_SIZE /sizeof(word32)] ;
int keylen ;
#endif
} Aes;
CYASSL_API int AesSetKey(Aes* aes, const byte* key, word32 len, const byte* iv,
int dir);
CYASSL_API int AesSetIV(Aes* aes, const byte* iv);
CYASSL_API int AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
CYASSL_API int AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz);
CYASSL_API int AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
const byte* key, word32 keySz, const byte* iv);
CYASSL_API void AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
CYASSL_API void AesEncryptDirect(Aes* aes, byte* out, const byte* in);
CYASSL_API void AesDecryptDirect(Aes* aes, byte* out, const byte* in);
CYASSL_API int AesSetKeyDirect(Aes* aes, const byte* key, word32 len,
const byte* iv, int dir);
#ifdef HAVE_AESGCM
CYASSL_API int AesGcmSetKey(Aes* aes, const byte* key, word32 len);
CYASSL_API int AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
const byte* iv, word32 ivSz,
byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);
CYASSL_API int AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
const byte* iv, word32 ivSz,
const byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);
typedef struct Gmac {
Aes aes;
} Gmac;
CYASSL_API int GmacSetKey(Gmac* gmac, const byte* key, word32 len);
CYASSL_API int GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
const byte* authIn, word32 authInSz,
byte* authTag, word32 authTagSz);
#endif /* HAVE_AESGCM */
#ifdef HAVE_AESCCM
CYASSL_API void AesCcmSetKey(Aes* aes, const byte* key, word32 keySz);
CYASSL_API void AesCcmEncrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
const byte* nonce, word32 nonceSz,
byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);
CYASSL_API int AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
const byte* nonce, word32 nonceSz,
const byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);
#endif /* HAVE_AESCCM */
#ifdef HAVE_CAVIUM
CYASSL_API int AesInitCavium(Aes*, int);
CYASSL_API void AesFreeCavium(Aes*);
#endif
#ifdef HAVE_FIPS
/* fips wrapper calls, user can call direct */
CYASSL_API int AesSetKey_fips(Aes* aes, const byte* key, word32 len,
const byte* iv, int dir);
CYASSL_API int AesSetIV_fips(Aes* aes, const byte* iv);
CYASSL_API int AesCbcEncrypt_fips(Aes* aes, byte* out, const byte* in,
word32 sz);
CYASSL_API int AesCbcDecrypt_fips(Aes* aes, byte* out, const byte* in,
word32 sz);
CYASSL_API int AesGcmSetKey_fips(Aes* aes, const byte* key, word32 len);
CYASSL_API int AesGcmEncrypt_fips(Aes* aes, byte* out, const byte* in,
word32 sz, const byte* iv, word32 ivSz,
byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);
CYASSL_API int AesGcmDecrypt_fips(Aes* aes, byte* out, const byte* in,
word32 sz, const byte* iv, word32 ivSz,
const byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define AesSetKey AesSetKey_fips
#define AesSetIV AesSetIV_fips
#define AesCbcEncrypt AesCbcEncrypt_fips
#define AesCbcDecrypt AesCbcDecrypt_fips
#define AesGcmSetKey AesGcmSetKey_fips
#define AesGcmEncrypt AesGcmEncrypt_fips
#define AesGcmDecrypt AesGcmDecrypt_fips
#endif /* FIPS_NO_WRAPPERS */
#endif /* HAVE_FIPS */
#ifdef __cplusplus
} /* extern "C" */
#endif
#include <wolfssl/wolfcrypt/aes.h>
#endif /* CTAO_CRYPT_AES_H */
#endif /* NO_AES */

View File

@ -26,105 +26,7 @@
#define CTAO_CRYPT_DES3_H
#include <cyassl/ctaocrypt/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define CYASSL_3DES_CAVIUM_MAGIC 0xBEEF0003
enum {
DES_ENC_TYPE = 2, /* cipher unique type */
DES3_ENC_TYPE = 3, /* cipher unique type */
DES_BLOCK_SIZE = 8,
DES_KS_SIZE = 32,
DES_ENCRYPTION = 0,
DES_DECRYPTION = 1
};
#define DES_IVLEN 8
#define DES_KEYLEN 8
#define DES3_IVLEN 8
#define DES3_KEYLEN 24
#ifdef STM32F2_CRYPTO
enum {
DES_CBC = 0,
DES_ECB = 1
};
#endif
/* DES encryption and decryption */
typedef struct Des {
word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */
word32 key[DES_KS_SIZE];
} Des;
/* DES3 encryption and decryption */
typedef struct Des3 {
word32 key[3][DES_KS_SIZE];
word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */
#ifdef HAVE_CAVIUM
int devId; /* nitrox device id */
word32 magic; /* using cavium magic */
word64 contextHandle; /* nitrox context memory handle */
#endif
} Des3;
CYASSL_API int Des_SetKey(Des* des, const byte* key, const byte* iv, int dir);
CYASSL_API void Des_SetIV(Des* des, const byte* iv);
CYASSL_API int Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz);
CYASSL_API int Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz);
CYASSL_API int Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz);
CYASSL_API int Des_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
const byte* key, const byte* iv);
CYASSL_API int Des3_SetKey(Des3* des, const byte* key, const byte* iv,int dir);
CYASSL_API int Des3_SetIV(Des3* des, const byte* iv);
CYASSL_API int Des3_CbcEncrypt(Des3* des, byte* out, const byte* in,word32 sz);
CYASSL_API int Des3_CbcDecrypt(Des3* des, byte* out, const byte* in,word32 sz);
CYASSL_API int Des3_CbcDecryptWithKey(byte* out, const byte* in, word32 sz,
const byte* key, const byte* iv);
#ifdef HAVE_CAVIUM
CYASSL_API int Des3_InitCavium(Des3*, int);
CYASSL_API void Des3_FreeCavium(Des3*);
#endif
#ifdef HAVE_FIPS
/* fips wrapper calls, user can call direct */
CYASSL_API int Des3_SetKey_fips(Des3* des, const byte* key, const byte* iv,
int dir);
CYASSL_API int Des3_SetIV_fips(Des3* des, const byte* iv);
CYASSL_API int Des3_CbcEncrypt_fips(Des3* des, byte* out, const byte* in,
word32 sz);
CYASSL_API int Des3_CbcDecrypt_fips(Des3* des, byte* out, const byte* in,
word32 sz);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define Des3_SetKey Des3_SetKey_fips
#define Des3_SetIV Des3_SetIV_fips
#define Des3_CbcEncrypt Des3_CbcEncrypt_fips
#define Des3_CbcDecrypt Des3_CbcDecrypt_fips
#endif /* FIPS_NO_WRAPPERS */
#endif /* HAVE_FIPS */
#ifdef __cplusplus
} /* extern "C" */
#endif
#include <wolfssl/wolfcrypt/des3.h>
#endif /* NO_DES3 */
#endif /* CTAO_CRYPT_DES3_H */

View File

@ -25,175 +25,7 @@
#ifndef CTAO_CRYPT_HMAC_H
#define CTAO_CRYPT_HMAC_H
#include <cyassl/ctaocrypt/types.h>
#ifndef NO_MD5
#include <cyassl/ctaocrypt/md5.h>
#endif
#ifndef NO_SHA
#include <cyassl/ctaocrypt/sha.h>
#endif
#ifndef NO_SHA256
#include <cyassl/ctaocrypt/sha256.h>
#endif
#ifdef CYASSL_SHA512
#include <cyassl/ctaocrypt/sha512.h>
#endif
#ifdef HAVE_BLAKE2
#include <cyassl/ctaocrypt/blake2.h>
#endif
#ifdef HAVE_CAVIUM
#include <cyassl/ctaocrypt/logging.h>
#include "cavium_common.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define CYASSL_HMAC_CAVIUM_MAGIC 0xBEEF0005
enum {
HMAC_FIPS_MIN_KEY = 14, /* 112 bit key length minimum */
IPAD = 0x36,
OPAD = 0x5C,
/* If any hash is not enabled, add the ID here. */
#ifdef NO_MD5
MD5 = 0,
#endif
#ifdef NO_SHA
SHA = 1,
#endif
#ifdef NO_SHA256
SHA256 = 2,
#endif
#ifndef CYASSL_SHA512
SHA512 = 4,
#endif
#ifndef CYASSL_SHA384
SHA384 = 5,
#endif
#ifndef HAVE_BLAKE2
BLAKE2B_ID = 7,
#endif
/* Select the largest available hash for the buffer size. */
#if defined(CYASSL_SHA512)
MAX_DIGEST_SIZE = SHA512_DIGEST_SIZE,
HMAC_BLOCK_SIZE = SHA512_BLOCK_SIZE
#elif defined(HAVE_BLAKE2)
MAX_DIGEST_SIZE = BLAKE2B_OUTBYTES,
HMAC_BLOCK_SIZE = BLAKE2B_BLOCKBYTES,
#elif defined(CYASSL_SHA384)
MAX_DIGEST_SIZE = SHA384_DIGEST_SIZE,
HMAC_BLOCK_SIZE = SHA384_BLOCK_SIZE
#elif !defined(NO_SHA256)
MAX_DIGEST_SIZE = SHA256_DIGEST_SIZE,
HMAC_BLOCK_SIZE = SHA256_BLOCK_SIZE
#elif !defined(NO_SHA)
MAX_DIGEST_SIZE = SHA_DIGEST_SIZE,
HMAC_BLOCK_SIZE = SHA_BLOCK_SIZE
#elif !defined(NO_MD5)
MAX_DIGEST_SIZE = MD5_DIGEST_SIZE,
HMAC_BLOCK_SIZE = MD5_BLOCK_SIZE
#else
#error "You have to have some kind of hash if you want to use HMAC."
#endif
};
/* hash union */
typedef union {
#ifndef NO_MD5
Md5 md5;
#endif
#ifndef NO_SHA
Sha sha;
#endif
#ifndef NO_SHA256
Sha256 sha256;
#endif
#ifdef CYASSL_SHA384
Sha384 sha384;
#endif
#ifdef CYASSL_SHA512
Sha512 sha512;
#endif
#ifdef HAVE_BLAKE2
Blake2b blake2b;
#endif
} Hash;
/* Hmac digest */
typedef struct Hmac {
Hash hash;
word32 ipad[HMAC_BLOCK_SIZE / sizeof(word32)]; /* same block size all*/
word32 opad[HMAC_BLOCK_SIZE / sizeof(word32)];
word32 innerHash[MAX_DIGEST_SIZE / sizeof(word32)];
byte macType; /* md5 sha or sha256 */
byte innerHashKeyed; /* keyed flag */
#ifdef HAVE_CAVIUM
word16 keyLen; /* hmac key length */
word16 dataLen;
HashType type; /* hmac key type */
int devId; /* nitrox device id */
word32 magic; /* using cavium magic */
word64 contextHandle; /* nitrox context memory handle */
byte* data; /* buffered input data for one call */
#endif
} Hmac;
/* does init */
CYASSL_API int HmacSetKey(Hmac*, int type, const byte* key, word32 keySz);
CYASSL_API int HmacUpdate(Hmac*, const byte*, word32);
CYASSL_API int HmacFinal(Hmac*, byte*);
#ifdef HAVE_CAVIUM
CYASSL_API int HmacInitCavium(Hmac*, int);
CYASSL_API void HmacFreeCavium(Hmac*);
#endif
CYASSL_API int CyaSSL_GetHmacMaxSize(void);
#ifdef HAVE_HKDF
CYASSL_API int HKDF(int type, const byte* inKey, word32 inKeySz,
const byte* salt, word32 saltSz,
const byte* info, word32 infoSz,
byte* out, word32 outSz);
#endif /* HAVE_HKDF */
#ifdef HAVE_FIPS
/* fips wrapper calls, user can call direct */
CYASSL_API int HmacSetKey_fips(Hmac*, int type, const byte* key,
word32 keySz);
CYASSL_API int HmacUpdate_fips(Hmac*, const byte*, word32);
CYASSL_API int HmacFinal_fips(Hmac*, byte*);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define HmacSetKey HmacSetKey_fips
#define HmacUpdate HmacUpdate_fips
#define HmacFinal HmacFinal_fips
#endif /* FIPS_NO_WRAPPERS */
#endif /* HAVE_FIPS */
#ifdef __cplusplus
} /* extern "C" */
#endif
#include <wolfssl/wolfcrypt/hmac.h>
#endif /* CTAO_CRYPT_HMAC_H */

View File

@ -23,131 +23,7 @@
#ifndef CTAO_CRYPT_RANDOM_H
#define CTAO_CRYPT_RANDOM_H
#include <cyassl/ctaocrypt/types.h>
#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
#ifdef NO_SHA256
#error "Hash DRBG requires SHA-256."
#endif /* NO_SHA256 */
#include <cyassl/ctaocrypt/sha256.h>
#else /* HAVE_HASHDRBG || NO_RC4 */
#include <cyassl/ctaocrypt/arc4.h>
#endif /* HAVE_HASHDRBG || NO_RC4 */
#ifdef __cplusplus
extern "C" {
#endif
#if defined(USE_WINDOWS_API)
#if defined(_WIN64)
typedef unsigned __int64 ProviderHandle;
/* type HCRYPTPROV, avoid #include <windows.h> */
#else
typedef unsigned long ProviderHandle;
#endif
#endif
/* OS specific seeder */
typedef struct OS_Seed {
#if defined(USE_WINDOWS_API)
ProviderHandle handle;
#else
int fd;
#endif
} OS_Seed;
CYASSL_LOCAL
int GenerateSeed(OS_Seed* os, byte* seed, word32 sz);
#if defined(CYASSL_MDK_ARM)
#undef RNG
#define RNG CyaSSL_RNG /* for avoiding name conflict in "stm32f2xx.h" */
#endif
#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
#define DRBG_SEED_LEN (440/8)
struct DRBG; /* Private DRBG state */
/* Hash-based Deterministic Random Bit Generator */
typedef struct RNG {
OS_Seed seed;
struct DRBG* drbg;
byte status;
} RNG;
#else /* HAVE_HASHDRBG || NO_RC4 */
#define CYASSL_RNG_CAVIUM_MAGIC 0xBEEF0004
/* secure Random Number Generator */
typedef struct RNG {
OS_Seed seed;
Arc4 cipher;
#ifdef HAVE_CAVIUM
int devId; /* nitrox device id */
word32 magic; /* using cavium magic */
#endif
} RNG;
#ifdef HAVE_CAVIUM
CYASSL_API int InitRngCavium(RNG*, int);
#endif
#endif /* HAVE_HASH_DRBG || NO_RC4 */
CYASSL_API int InitRng(RNG*);
CYASSL_API int RNG_GenerateBlock(RNG*, byte*, word32 sz);
CYASSL_API int RNG_GenerateByte(RNG*, byte*);
#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
CYASSL_API int FreeRng(RNG*);
CYASSL_API int RNG_HealthTest(int reseed,
const byte* entropyA, word32 entropyASz,
const byte* entropyB, word32 entropyBSz,
byte* output, word32 outputSz);
#endif /* HAVE_HASHDRBG || NO_RC4 */
#ifdef HAVE_FIPS
/* fips wrapper calls, user can call direct */
CYASSL_API int InitRng_fips(RNG* rng);
CYASSL_API int FreeRng_fips(RNG* rng);
CYASSL_API int RNG_GenerateBlock_fips(RNG* rng, byte* buf, word32 bufSz);
CYASSL_API int RNG_HealthTest_fips(int reseed,
const byte* entropyA, word32 entropyASz,
const byte* entropyB, word32 entropyBSz,
byte* output, word32 outputSz);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define InitRng InitRng_fips
#define FreeRng FreeRng_fips
#define RNG_GenerateBlock RNG_GenerateBlock_fips
#define RNG_HealthTest RNG_HealthTest_fips
#endif /* FIPS_NO_WRAPPERS */
#endif /* HAVE_FIPS */
#ifdef __cplusplus
} /* extern "C" */
#endif
#include <wolfssl/wolfcrypt/random.h>
#endif /* CTAO_CRYPT_RANDOM_H */

View File

@ -24,122 +24,7 @@
#ifndef CTAO_CRYPT_RSA_H
#define CTAO_CRYPT_RSA_H
#include <cyassl/ctaocrypt/types.h>
#include <cyassl/ctaocrypt/integer.h>
#include <cyassl/ctaocrypt/random.h>
#ifdef __cplusplus
extern "C" {
#endif
#define CYASSL_RSA_CAVIUM_MAGIC 0xBEEF0006
enum {
RSA_PUBLIC = 0,
RSA_PRIVATE = 1
};
/* RSA */
typedef struct RsaKey {
mp_int n, e, d, p, q, dP, dQ, u;
int type; /* public or private */
void* heap; /* for user memory overrides */
#ifdef HAVE_CAVIUM
int devId; /* nitrox device id */
word32 magic; /* using cavium magic */
word64 contextHandle; /* nitrox context memory handle */
byte* c_n; /* cavium byte buffers for key parts */
byte* c_e;
byte* c_d;
byte* c_p;
byte* c_q;
byte* c_dP;
byte* c_dQ;
byte* c_u; /* sizes in bytes */
word16 c_nSz, c_eSz, c_dSz, c_pSz, c_qSz, c_dP_Sz, c_dQ_Sz, c_uSz;
#endif
} RsaKey;
CYASSL_API int InitRsaKey(RsaKey* key, void*);
CYASSL_API int FreeRsaKey(RsaKey* key);
CYASSL_API int RsaPublicEncrypt(const byte* in, word32 inLen, byte* out,
word32 outLen, RsaKey* key, RNG* rng);
CYASSL_API int RsaPrivateDecryptInline(byte* in, word32 inLen, byte** out,
RsaKey* key);
CYASSL_API int RsaPrivateDecrypt(const byte* in, word32 inLen, byte* out,
word32 outLen, RsaKey* key);
CYASSL_API int RsaSSL_Sign(const byte* in, word32 inLen, byte* out,
word32 outLen, RsaKey* key, RNG* rng);
CYASSL_API int RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out,
RsaKey* key);
CYASSL_API int RsaSSL_Verify(const byte* in, word32 inLen, byte* out,
word32 outLen, RsaKey* key);
CYASSL_API int RsaEncryptSize(RsaKey* key);
CYASSL_API int RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, RsaKey*,
word32);
CYASSL_API int RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey*,
word32);
CYASSL_API int RsaPublicKeyDecodeRaw(const byte* n, word32 nSz, const byte* e,
word32 eSz, RsaKey* key);
CYASSL_API int RsaFlattenPublicKey(RsaKey*, byte*, word32*, byte*, word32*);
#ifdef CYASSL_KEY_GEN
CYASSL_API int MakeRsaKey(RsaKey* key, int size, long e, RNG* rng);
CYASSL_API int RsaKeyToDer(RsaKey*, byte* output, word32 inLen);
#endif
#ifdef HAVE_CAVIUM
CYASSL_API int RsaInitCavium(RsaKey*, int);
CYASSL_API void RsaFreeCavium(RsaKey*);
#endif
#ifdef HAVE_FIPS
/* fips wrapper calls, user can call direct */
CYASSL_API int InitRsaKey_fips(RsaKey* key, void*);
CYASSL_API int FreeRsaKey_fips(RsaKey* key);
CYASSL_API int RsaPublicEncrypt_fips(const byte* in,word32 inLen,byte* out,
word32 outLen, RsaKey* key, RNG* rng);
CYASSL_API int RsaPrivateDecryptInline_fips(byte* in, word32 inLen,
byte** out, RsaKey* key);
CYASSL_API int RsaPrivateDecrypt_fips(const byte* in, word32 inLen,
byte* out,word32 outLen,RsaKey* key);
CYASSL_API int RsaSSL_Sign_fips(const byte* in, word32 inLen, byte* out,
word32 outLen, RsaKey* key, RNG* rng);
CYASSL_API int RsaSSL_VerifyInline_fips(byte* in, word32 inLen, byte** out,
RsaKey* key);
CYASSL_API int RsaSSL_Verify_fips(const byte* in, word32 inLen, byte* out,
word32 outLen, RsaKey* key);
CYASSL_API int RsaEncryptSize_fips(RsaKey* key);
CYASSL_API int RsaPrivateKeyDecode_fips(const byte* input, word32* inOutIdx,
RsaKey*, word32);
CYASSL_API int RsaPublicKeyDecode_fips(const byte* input, word32* inOutIdx,
RsaKey*, word32);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define InitRsaKey InitRsaKey_fips
#define FreeRsaKey FreeRsaKey_fips
#define RsaPublicEncrypt RsaPublicEncrypt_fips
#define RsaPrivateDecryptInline RsaPrivateDecryptInline_fips
#define RsaPrivateDecrypt RsaPrivateDecrypt_fips
#define RsaSSL_Sign RsaSSL_Sign_fips
#define RsaSSL_VerifyInline RsaSSL_VerifyInline_fips
#define RsaSSL_Verify RsaSSL_Verify_fips
#define RsaEncryptSize RsaEncryptSize_fips
/* no implicit KeyDecodes since in asn.c (not rsa.c) */
#endif /* FIPS_NO_WRAPPERS */
#endif /* HAVE_FIPS */
#ifdef __cplusplus
} /* extern "C" */
#endif
#include <wolfssl/wolfcrypt/rsa.h>
#endif /* CTAO_CRYPT_RSA_H */

View File

@ -25,67 +25,7 @@
#ifndef CTAO_CRYPT_SHA_H
#define CTAO_CRYPT_SHA_H
#include <cyassl/ctaocrypt/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/* in bytes */
enum {
#ifdef STM32F2_HASH
SHA_REG_SIZE = 4, /* STM32 register size, bytes */
#endif
SHA = 1, /* hash type unique */
SHA_BLOCK_SIZE = 64,
SHA_DIGEST_SIZE = 20,
SHA_PAD_SIZE = 56
};
#ifdef CYASSL_PIC32MZ_HASH
#include "port/pic32/pic32mz-crypt.h"
#endif
/* Sha digest */
typedef struct Sha {
word32 buffLen; /* in bytes */
word32 loLen; /* length in bytes */
word32 hiLen; /* length in bytes */
word32 buffer[SHA_BLOCK_SIZE / sizeof(word32)];
#ifndef CYASSL_PIC32MZ_HASH
word32 digest[SHA_DIGEST_SIZE / sizeof(word32)];
#else
word32 digest[PIC32_HASH_SIZE / sizeof(word32)];
pic32mz_desc desc; /* Crypt Engine descripter */
#endif
} Sha;
CYASSL_API int InitSha(Sha*);
CYASSL_API int ShaUpdate(Sha*, const byte*, word32);
CYASSL_API int ShaFinal(Sha*, byte*);
CYASSL_API int ShaHash(const byte*, word32, byte*);
#ifdef HAVE_FIPS
/* fips wrapper calls, user can call direct */
CYASSL_API int InitSha_fips(Sha*);
CYASSL_API int ShaUpdate_fips(Sha*, const byte*, word32);
CYASSL_API int ShaFinal_fips(Sha*, byte*);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define InitSha InitSha_fips
#define ShaUpdate ShaUpdate_fips
#define ShaFinal ShaFinal_fips
#endif /* FIPS_NO_WRAPPERS */
#endif /* HAVE_FIPS */
#ifdef __cplusplus
} /* extern "C" */
#endif
#include <wolfssl/wolfcrypt/sha.h>
#endif /* CTAO_CRYPT_SHA_H */
#endif /* NO_SHA */

View File

@ -28,63 +28,7 @@
#ifndef CTAO_CRYPT_SHA256_H
#define CTAO_CRYPT_SHA256_H
#include <cyassl/ctaocrypt/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef CYASSL_PIC32MZ_HASH
#include "port/pic32/pic32mz-crypt.h"
#endif
/* in bytes */
enum {
SHA256 = 2, /* hash type unique */
SHA256_BLOCK_SIZE = 64,
SHA256_DIGEST_SIZE = 32,
SHA256_PAD_SIZE = 56
};
/* Sha256 digest */
typedef struct Sha256 {
word32 buffLen; /* in bytes */
word32 loLen; /* length in bytes */
word32 hiLen; /* length in bytes */
word32 digest[SHA256_DIGEST_SIZE / sizeof(word32)];
word32 buffer[SHA256_BLOCK_SIZE / sizeof(word32)];
#ifdef CYASSL_PIC32MZ_HASH
pic32mz_desc desc ; /* Crypt Engine descripter */
#endif
} Sha256;
CYASSL_API int InitSha256(Sha256*);
CYASSL_API int Sha256Update(Sha256*, const byte*, word32);
CYASSL_API int Sha256Final(Sha256*, byte*);
CYASSL_API int Sha256Hash(const byte*, word32, byte*);
#ifdef HAVE_FIPS
/* fips wrapper calls, user can call direct */
CYASSL_API int InitSha256_fips(Sha256*);
CYASSL_API int Sha256Update_fips(Sha256*, const byte*, word32);
CYASSL_API int Sha256Final_fips(Sha256*, byte*);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define InitSha256 InitSha256_fips
#define Sha256Update Sha256Update_fips
#define Sha256Final Sha256Final_fips
#endif /* FIPS_NO_WRAPPERS */
#endif /* HAVE_FIPS */
#ifdef __cplusplus
} /* extern "C" */
#endif
#include <wolfssl/wolfcrypt/sha256.h>
#endif /* CTAO_CRYPT_SHA256_H */
#endif /* NO_SHA256 */

View File

@ -20,101 +20,10 @@
*/
#ifdef CYASSL_SHA512
#ifndef CTAO_CRYPT_SHA512_H
#define CTAO_CRYPT_SHA512_H
#include <cyassl/ctaocrypt/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/* in bytes */
enum {
SHA512 = 4, /* hash type unique */
SHA512_BLOCK_SIZE = 128,
SHA512_DIGEST_SIZE = 64,
SHA512_PAD_SIZE = 112
};
/* Sha512 digest */
typedef struct Sha512 {
word32 buffLen; /* in bytes */
word32 loLen; /* length in bytes */
word32 hiLen; /* length in bytes */
word64 digest[SHA512_DIGEST_SIZE / sizeof(word64)];
word64 buffer[SHA512_BLOCK_SIZE / sizeof(word64)];
} Sha512;
CYASSL_API int InitSha512(Sha512*);
CYASSL_API int Sha512Update(Sha512*, const byte*, word32);
CYASSL_API int Sha512Final(Sha512*, byte*);
CYASSL_API int Sha512Hash(const byte*, word32, byte*);
#if defined(CYASSL_SHA384) || defined(HAVE_AESGCM)
/* in bytes */
enum {
SHA384 = 5, /* hash type unique */
SHA384_BLOCK_SIZE = 128,
SHA384_DIGEST_SIZE = 48,
SHA384_PAD_SIZE = 112
};
/* Sha384 digest */
typedef struct Sha384 {
word32 buffLen; /* in bytes */
word32 loLen; /* length in bytes */
word32 hiLen; /* length in bytes */
word64 digest[SHA512_DIGEST_SIZE / sizeof(word64)]; /* for transform 512 */
word64 buffer[SHA384_BLOCK_SIZE / sizeof(word64)];
} Sha384;
CYASSL_API int InitSha384(Sha384*);
CYASSL_API int Sha384Update(Sha384*, const byte*, word32);
CYASSL_API int Sha384Final(Sha384*, byte*);
CYASSL_API int Sha384Hash(const byte*, word32, byte*);
#ifdef HAVE_FIPS
/* fips wrapper calls, user can call direct */
CYASSL_API int InitSha512_fips(Sha512*);
CYASSL_API int Sha512Update_fips(Sha512*, const byte*, word32);
CYASSL_API int Sha512Final_fips(Sha512*, byte*);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define InitSha512 InitSha512_fips
#define Sha512Update Sha512Update_fips
#define Sha512Final Sha512Final_fips
#endif /* FIPS_NO_WRAPPERS */
/* fips wrapper calls, user can call direct */
CYASSL_API int InitSha384_fips(Sha384*);
CYASSL_API int Sha384Update_fips(Sha384*, const byte*, word32);
CYASSL_API int Sha384Final_fips(Sha384*, byte*);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define InitSha384 InitSha384_fips
#define Sha384Update Sha384Update_fips
#define Sha384Final Sha384Final_fips
#endif /* FIPS_NO_WRAPPERS */
#endif /* HAVE_FIPS */
#endif /* CYASSL_SHA384 */
#ifdef __cplusplus
} /* extern "C" */
#endif
#include <wolfssl/wolfcrypt/sha512.h>
#endif /* CTAO_CRYPT_SHA512_H */
#endif /* CYASSL_SHA512 */

View File

@ -40,7 +40,6 @@
#endif
#ifndef HAVE_FIPS
#define CTAO_CRYPT_AES_H
#ifdef HAVE_CAVIUM
#include <wolfssl/ctaocrypt/logging.h>
#include "cavium_common.h"

View File

@ -38,7 +38,6 @@
#endif
#ifndef HAVE_FIPS
#define CTAO_CRYPT_DES3_H
#define WOLFSSL_3DES_CAVIUM_MAGIC 0xBEEF0003
enum {

View File

@ -62,7 +62,6 @@
extern "C" {
#endif
#ifndef HAVE_FIPS
#define CTAO_CRYPT_HMAC_H
#define WOLFSSL_HMAC_CAVIUM_MAGIC 0xBEEF0005
enum {

View File

@ -35,7 +35,6 @@
#endif
#ifndef HAVE_FIPS
#define CTAO_CRYPT_RANDOM_H
#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
#ifdef NO_SHA256
#error "Hash DRBG requires SHA-256."

View File

@ -42,7 +42,6 @@
#endif
#ifndef HAVE_FIPS
#define CTAO_CRYPT_RSA_H
#define WOLFSSL_RSA_CAVIUM_MAGIC 0xBEEF0006
enum {

View File

@ -37,7 +37,6 @@
extern "C" {
#endif
#ifndef HAVE_FIPS
#define CTAO_CRYPT_SHA_H
/* in bytes */
enum {

View File

@ -38,7 +38,6 @@
#endif
#ifndef HAVE_FIPS
#define CTAO_CRYPT_SHA256_H
#ifdef WOLFSSL_PIC32MZ_HASH
#include "port/pic32/pic32mz-crypt.h"
#endif

View File

@ -41,13 +41,13 @@
#endif
#ifndef HAVE_FIPS
#define CTAO_CRYPT_SHA512_H
/* in bytes */
enum {
SHA512 = 4, /* hash type unique */
SHA512_BLOCK_SIZE = 128,
SHA512_DIGEST_SIZE = 64,
SHA512_PAD_SIZE = 112
SHA512_PAD_SIZE = 112
};