forked from wolfSSL/wolfssl
Fixes for PIC32MZ:
* Adds crypto HW support for AES Direct and AES CCM. * Fixes to enable PIC32MZ hardware hashing where updates are cached via heap buffer and final performs single operations against hardware. * Fix for benchmark with 1024-bit certs passing in wrong size for `wc_RsaPrivateDecrypt` when using `USE_CERT_BUFFERS_1024`. * Fix to resolve missing `strncasecmp` for the Microchip XC32. Workaround to use case sensitive version instead. This error occurred when building with HAVE_ECC defined in Harmony with XC32. * Cleanup of the PIC32MZ crypto and hashing hardware code. Replace `pic32mz-hash.c` with `pic32mz-crypt.c` * Add user_settings.h for mplabx and mcapi examples. * Sync up with Harmony changes for MCAPI.
This commit is contained in:
@@ -1,28 +1,75 @@
|
||||
void _mon_putc(char c);
|
||||
|
||||
static void init_serial() {
|
||||
#ifdef MICROCHIP_PIC32
|
||||
#if defined (__32MZ2048ECH144__) || (__32MZ2048ECM144__)
|
||||
/* Set up PB2 divisor for UART2 */
|
||||
SYSKEY = 0x00000000;
|
||||
SYSKEY = 0xAA996655;
|
||||
SYSKEY = 0x556699AA;
|
||||
PB2DIV = 0x00008018;
|
||||
SYSKEY = 0x33333333;
|
||||
|
||||
/* UART2 Init */
|
||||
// U2BRG = 0x0C;
|
||||
U2BRG = 0x7;
|
||||
#define BAUD_GEN(sysclk, baud) ((sysclk / (16 * baud)) - 1)
|
||||
|
||||
#ifdef MICROCHIP_PIC32
|
||||
#if defined (__32MZ2048ECH144__) || defined(__32MZ2048ECM144__) || defined(__32MZ2048EFM144__)
|
||||
/* Code generated from Harmony example then exported using Window -> PIC32 Memory View -> Configuration Bits into system_config.h */
|
||||
#define SYS_CLK_FREQ 200000000ul
|
||||
#define SYS_CLK_BUS_PERIPHERAL_2 100000000ul
|
||||
|
||||
// DEVCFG3
|
||||
#pragma config FMIIEN = ON // Ethernet RMII/MII Enable (MII Enabled)
|
||||
#pragma config FETHIO = ON // Ethernet I/O Pin Select (Default Ethernet I/O)
|
||||
#pragma config PGL1WAY = ON // Permission Group Lock One Way Configuration (Allow only one reconfiguration)
|
||||
#pragma config PMDL1WAY = ON // Peripheral Module Disable Configuration (Allow only one reconfiguration)
|
||||
#pragma config IOL1WAY = ON // Peripheral Pin Select Configuration (Allow only one reconfiguration)
|
||||
#pragma config FUSBIDIO = ON // USB USBID Selection (Controlled by the USB Module)
|
||||
|
||||
// DEVCFG2
|
||||
#pragma config FPLLIDIV = DIV_1 // System PLL Input Divider (1x Divider)
|
||||
#pragma config FPLLRNG = RANGE_5_10_MHZ // System PLL Input Range (5-10 MHz Input)
|
||||
#pragma config FPLLICLK = PLL_FRC // System PLL Input Clock Selection (FRC is input to the System PLL)
|
||||
#pragma config FPLLMULT = MUL_50 // System PLL Multiplier (PLL Multiply by 50)
|
||||
#pragma config FPLLODIV = DIV_2 // System PLL Output Clock Divider (2x Divider)
|
||||
#pragma config UPLLFSEL = FREQ_24MHZ // USB PLL Input Frequency Selection (USB PLL input is 24 MHz)
|
||||
|
||||
// DEVCFG1
|
||||
#pragma config FNOSC = SPLL // Oscillator Selection Bits (System PLL)
|
||||
#pragma config DMTINTV = WIN_127_128 // DMT Count Window Interval (Window/Interval value is 127/128 counter value)
|
||||
#pragma config FSOSCEN = OFF // Secondary Oscillator Enable (Disable SOSC)
|
||||
#pragma config IESO = OFF // Internal/External Switch Over (Disabled)
|
||||
#pragma config POSCMOD = OFF // Primary Oscillator Configuration (Primary osc disabled)
|
||||
#pragma config OSCIOFNC = OFF // CLKO Output Signal Active on the OSCO Pin (Disabled)
|
||||
#pragma config FCKSM = CSECME // Clock Switching and Monitor Selection (Clock Switch Enabled, FSCM Enabled)
|
||||
#pragma config WDTPS = PS1048576 // Watchdog Timer Postscaler (1:1048576)
|
||||
#pragma config WDTSPGM = STOP // Watchdog Timer Stop During Flash Programming (WDT stops during Flash programming)
|
||||
#pragma config WINDIS = NORMAL // Watchdog Timer Window Mode (Watchdog Timer is in non-Window mode)
|
||||
#pragma config FWDTEN = OFF // Watchdog Timer Enable (WDT Disabled)
|
||||
#pragma config FWDTWINSZ = WINSZ_25 // Watchdog Timer Window Size (Window size is 25%)
|
||||
#pragma config DMTCNT = DMT31 // Deadman Timer Count Selection (2^31 (2147483648))
|
||||
#pragma config FDMTEN = OFF // Deadman Timer Enable (Deadman Timer is disabled)
|
||||
|
||||
// DEVCFG0
|
||||
#pragma config ICESEL = ICS_PGx2 // ICE/ICD Comm Channel Select (Communicate on PGEC2/PGED2)
|
||||
|
||||
// DEVCP0
|
||||
#pragma config CP = OFF // Code Protect (Protection Disabled)
|
||||
|
||||
#include <xc.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static void init_serial(unsigned int sysClk) {
|
||||
#ifdef MICROCHIP_PIC32
|
||||
#if defined (__32MZ2048ECH144__) || defined(__32MZ2048ECM144__) || defined(__32MZ2048EFM144__)
|
||||
/* This is for pin B14 which is connected to the USB to UART connector J11 located under Ethernet connector */
|
||||
|
||||
/* Setup UART2 */
|
||||
#ifdef SYS_CLK_BUS_PERIPHERAL_2
|
||||
U2BRG = BAUD_GEN(SYS_CLK_BUS_PERIPHERAL_2, 115200);
|
||||
#else
|
||||
if (sysClk > 100000000)
|
||||
sysClk /= 2;
|
||||
U2BRG = BAUD_GEN(sysClk, 115200);
|
||||
#endif
|
||||
ANSELBCLR = 0x4000;
|
||||
ANSELGCLR = 0x0040;
|
||||
RPB14R = 0x02;
|
||||
U2RXR = 0x01;
|
||||
U2MODE = 0x8000;
|
||||
U2STA = 0x400;
|
||||
#elif defined __PIC32MX__
|
||||
SYSTEMConfigPerformance(80000000);
|
||||
DBINIT();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
(void)sysClk;
|
||||
}
|
||||
|
102
mcapi/crypto.c
102
mcapi/crypto.c
@@ -20,29 +20,32 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Implements Microchip CRYPTO API layer */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#ifdef MICROCHIP_MPLAB_HARMONY
|
||||
#include "system_config.h"
|
||||
#endif
|
||||
|
||||
#include "crypto.h"
|
||||
|
||||
#include <cyassl/ctaocrypt/settings.h>
|
||||
|
||||
#include <cyassl/ctaocrypt/md5.h>
|
||||
#include <cyassl/ctaocrypt/sha.h>
|
||||
#include <cyassl/ctaocrypt/sha256.h>
|
||||
#include <cyassl/ctaocrypt/sha512.h>
|
||||
#include <cyassl/ctaocrypt/hmac.h>
|
||||
#include <cyassl/ctaocrypt/compress.h>
|
||||
#include <cyassl/ctaocrypt/random.h>
|
||||
#include <cyassl/ctaocrypt/des3.h>
|
||||
#include <cyassl/ctaocrypt/aes.h>
|
||||
#include <cyassl/ctaocrypt/rsa.h>
|
||||
#include <cyassl/ctaocrypt/ecc.h>
|
||||
#include <cyassl/ctaocrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#include <wolfssl/wolfcrypt/md5.h>
|
||||
#include <wolfssl/wolfcrypt/sha.h>
|
||||
#include <wolfssl/wolfcrypt/sha256.h>
|
||||
#include <wolfssl/wolfcrypt/sha512.h>
|
||||
#include <wolfssl/wolfcrypt/hmac.h>
|
||||
#include <wolfssl/wolfcrypt/compress.h>
|
||||
#include <wolfssl/wolfcrypt/random.h>
|
||||
#include <wolfssl/wolfcrypt/des3.h>
|
||||
#include <wolfssl/wolfcrypt/aes.h>
|
||||
#include <wolfssl/wolfcrypt/rsa.h>
|
||||
#include <wolfssl/wolfcrypt/ecc.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
|
||||
#ifndef NO_MD5
|
||||
/* Initialize MD5 */
|
||||
int CRYPT_MD5_Initialize(CRYPT_MD5_CTX* md5)
|
||||
{
|
||||
@@ -75,7 +78,9 @@ int CRYPT_MD5_Finalize(CRYPT_MD5_CTX* md5, unsigned char* digest)
|
||||
|
||||
return wc_Md5Final((Md5*)md5, digest);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NO_SHA
|
||||
|
||||
/* Initialize SHA */
|
||||
int CRYPT_SHA_Initialize(CRYPT_SHA_CTX* sha)
|
||||
@@ -109,7 +114,9 @@ int CRYPT_SHA_Finalize(CRYPT_SHA_CTX* sha, unsigned char* digest)
|
||||
|
||||
return wc_ShaFinal((Sha*)sha, digest);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NO_SHA256
|
||||
|
||||
/* Initialize SHA-256 */
|
||||
int CRYPT_SHA256_Initialize(CRYPT_SHA256_CTX* sha256)
|
||||
@@ -143,8 +150,10 @@ int CRYPT_SHA256_Finalize(CRYPT_SHA256_CTX* sha256, unsigned char* digest)
|
||||
|
||||
return wc_Sha256Final((Sha256*)sha256, digest);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WOLFSSL_SHA512
|
||||
#ifdef WOLFSSL_SHA384
|
||||
/* Initialize SHA-384 */
|
||||
int CRYPT_SHA384_Initialize(CRYPT_SHA384_CTX* sha384)
|
||||
{
|
||||
@@ -177,6 +186,7 @@ int CRYPT_SHA384_Finalize(CRYPT_SHA384_CTX* sha384, unsigned char* digest)
|
||||
|
||||
return wc_Sha384Final((Sha384*)sha384, digest);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Initialize SHA-512 */
|
||||
@@ -211,8 +221,9 @@ int CRYPT_SHA512_Finalize(CRYPT_SHA512_CTX* sha512, unsigned char* digest)
|
||||
|
||||
return wc_Sha512Final((Sha512*)sha512, digest);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NO_HMAC
|
||||
/* Set HMAC key with type */
|
||||
int CRYPT_HMAC_SetKey(CRYPT_HMAC_CTX* hmac, int type, const unsigned char* key,
|
||||
unsigned int sz)
|
||||
@@ -252,6 +263,9 @@ int CRYPT_HMAC_Finalize(CRYPT_HMAC_CTX* hmac, unsigned char* digest)
|
||||
return wc_HmacFinal((Hmac*)hmac, digest);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
|
||||
/* Huffman Compression, set flag to do static, otherwise dynamic */
|
||||
/* return compressed size, otherwise < 0 for error */
|
||||
@@ -262,7 +276,7 @@ int CRYPT_HUFFMAN_Compress(unsigned char* out, unsigned int outSz,
|
||||
if (out == NULL || in == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return Compress(out, outSz, in, inSz, flags);
|
||||
return wc_Compress(out, outSz, in, inSz, flags);
|
||||
}
|
||||
|
||||
|
||||
@@ -274,9 +288,12 @@ int CRYPT_HUFFMAN_DeCompress(unsigned char* out, unsigned int outSz,
|
||||
if (out == NULL || in == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return DeCompress(out, outSz, in, inSz);
|
||||
return wc_DeCompress(out, outSz, in, inSz);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NO_RNG
|
||||
|
||||
/* RNG Initialize, < 0 on error */
|
||||
int CRYPT_RNG_Initialize(CRYPT_RNG_CTX* rng)
|
||||
@@ -287,7 +304,7 @@ int CRYPT_RNG_Initialize(CRYPT_RNG_CTX* rng)
|
||||
if (rng == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return InitRng((WC_RNG*)rng);
|
||||
return wc_InitRng((WC_RNG*)rng);
|
||||
}
|
||||
|
||||
|
||||
@@ -297,7 +314,7 @@ int CRYPT_RNG_Get(CRYPT_RNG_CTX* rng, unsigned char* b)
|
||||
if (rng == NULL || b == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return RNG_GenerateByte((WC_RNG*)rng, (byte*)b);
|
||||
return wc_RNG_GenerateByte((WC_RNG*)rng, (byte*)b);
|
||||
}
|
||||
|
||||
|
||||
@@ -308,10 +325,12 @@ int CRYPT_RNG_BlockGenerate(CRYPT_RNG_CTX* rng, unsigned char* b,
|
||||
if (rng == NULL || b == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return RNG_GenerateBlock((WC_RNG*)rng, b, sz);
|
||||
return wc_RNG_GenerateBlock((WC_RNG*)rng, b, sz);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NO_DES3
|
||||
/* Triple DES Key Set, may have iv, will have direction */
|
||||
int CRYPT_TDES_KeySet(CRYPT_TDES_CTX* tdes, const unsigned char* key,
|
||||
const unsigned char* iv, int dir)
|
||||
@@ -322,7 +341,7 @@ int CRYPT_TDES_KeySet(CRYPT_TDES_CTX* tdes, const unsigned char* key,
|
||||
if (tdes == NULL || key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return Des3_SetKey((Des3*)tdes, key, iv, dir);
|
||||
return wc_Des3_SetKey((Des3*)tdes, key, iv, dir);
|
||||
}
|
||||
|
||||
|
||||
@@ -354,9 +373,12 @@ int CRYPT_TDES_CBC_Decrypt(CRYPT_TDES_CTX* tdes, unsigned char* out,
|
||||
if (tdes == NULL || out == NULL || in == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return Des3_CbcDecrypt((Des3*)tdes, out, in, inSz);
|
||||
return wc_Des3_CbcDecrypt((Des3*)tdes, out, in, inSz);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NO_AES
|
||||
|
||||
/* AES Key Set, may have iv, will have direction */
|
||||
int CRYPT_AES_KeySet(CRYPT_AES_CTX* aes, const unsigned char* key,
|
||||
@@ -400,10 +422,11 @@ int CRYPT_AES_CBC_Decrypt(CRYPT_AES_CTX* aes, unsigned char* out,
|
||||
if (aes == NULL || out == NULL || in == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return AesCbcDecrypt((Aes*)aes, out, in, inSz);
|
||||
return wc_AesCbcDecrypt((Aes*)aes, out, in, inSz);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WOLFSSL_AES_COUNTER
|
||||
/* AES CTR Encrypt (used for decrypt too, with ENCRYPT key setup) */
|
||||
int CRYPT_AES_CTR_Encrypt(CRYPT_AES_CTX* aes, unsigned char* out,
|
||||
const unsigned char* in, unsigned int inSz)
|
||||
@@ -413,7 +436,9 @@ int CRYPT_AES_CTR_Encrypt(CRYPT_AES_CTX* aes, unsigned char* out,
|
||||
|
||||
return wc_AesCtrEncrypt((Aes*)aes, out, in, inSz);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_AES_DIRECT
|
||||
|
||||
/* AES Direct mode encrypt, one block at a time */
|
||||
int CRYPT_AES_DIRECT_Encrypt(CRYPT_AES_CTX* aes, unsigned char* out,
|
||||
@@ -439,7 +464,9 @@ int CRYPT_AES_DIRECT_Decrypt(CRYPT_AES_CTX* aes, unsigned char* out,
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NO_RSA
|
||||
|
||||
/* RSA Initialize */
|
||||
int CRYPT_RSA_Initialize(CRYPT_RSA_CTX* rsa)
|
||||
@@ -451,7 +478,7 @@ int CRYPT_RSA_Initialize(CRYPT_RSA_CTX* rsa)
|
||||
if (rsa->holder == NULL)
|
||||
return -1;
|
||||
|
||||
return InitRsaKey((RsaKey*)rsa->holder, NULL);
|
||||
return wc_InitRsaKey((RsaKey*)rsa->holder, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -461,7 +488,7 @@ int CRYPT_RSA_Free(CRYPT_RSA_CTX* rsa)
|
||||
if (rsa == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
FreeRsaKey((RsaKey*)rsa->holder);
|
||||
wc_FreeRsaKey((RsaKey*)rsa->holder);
|
||||
XFREE(rsa->holder, NULL, DYNAMIC_TYPE_RSA);
|
||||
rsa->holder = NULL;
|
||||
|
||||
@@ -479,7 +506,7 @@ int CRYPT_RSA_PublicKeyDecode(CRYPT_RSA_CTX* rsa, const unsigned char* in,
|
||||
if (rsa == NULL || in == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return RsaPublicKeyDecode(in, &idx, (RsaKey*)rsa->holder, inSz);
|
||||
return wc_RsaPublicKeyDecode(in, &idx, (RsaKey*)rsa->holder, inSz);
|
||||
}
|
||||
|
||||
|
||||
@@ -493,7 +520,7 @@ int CRYPT_RSA_PrivateKeyDecode(CRYPT_RSA_CTX* rsa, const unsigned char* in,
|
||||
if (rsa == NULL || in == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return RsaPrivateKeyDecode(in, &idx, (RsaKey*)rsa->holder, inSz);
|
||||
return wc_RsaPrivateKeyDecode(in, &idx, (RsaKey*)rsa->holder, inSz);
|
||||
}
|
||||
|
||||
|
||||
@@ -505,7 +532,7 @@ int CRYPT_RSA_PublicEncrypt(CRYPT_RSA_CTX* rsa, unsigned char* out,
|
||||
if (rsa == NULL || in == NULL || out == NULL || rng == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return RsaPublicEncrypt(in, inSz, out, outSz, (RsaKey*)rsa->holder,
|
||||
return wc_RsaPublicEncrypt(in, inSz, out, outSz, (RsaKey*)rsa->holder,
|
||||
(WC_RNG*)rng);
|
||||
}
|
||||
|
||||
@@ -518,7 +545,7 @@ int CRYPT_RSA_PrivateDecrypt(CRYPT_RSA_CTX* rsa, unsigned char* out,
|
||||
if (rsa == NULL || in == NULL || out == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return RsaPrivateDecrypt(in, inSz, out, outSz, (RsaKey*)rsa->holder);
|
||||
return wc_RsaPrivateDecrypt(in, inSz, out, outSz, (RsaKey*)rsa->holder);
|
||||
}
|
||||
|
||||
|
||||
@@ -528,7 +555,7 @@ int CRYPT_RSA_EncryptSizeGet(CRYPT_RSA_CTX* rsa)
|
||||
if (rsa == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return RsaEncryptSize((RsaKey*)rsa->holder);
|
||||
return wc_RsaEncryptSize((RsaKey*)rsa->holder);
|
||||
}
|
||||
|
||||
|
||||
@@ -545,7 +572,9 @@ int CRYPT_RSA_SetRng(CRYPT_RSA_CTX* rsa, CRYPT_RNG_CTX* rng)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
|
||||
/* ECC init */
|
||||
int CRYPT_ECC_Initialize(CRYPT_ECC_CTX* ecc)
|
||||
@@ -698,6 +727,7 @@ int CRYPT_ECC_SignatureSizeGet(CRYPT_ECC_CTX* ecc)
|
||||
return wc_ecc_sig_size((ecc_key*)ecc->holder);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Save error string from err to str which needs to be >= 80 chars */
|
||||
int CRYPT_ERROR_StringGet(int err, char* str)
|
||||
@@ -705,7 +735,7 @@ int CRYPT_ERROR_StringGet(int err, char* str)
|
||||
if (str == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
CTaoCryptErrorString(err, str);
|
||||
wc_ErrorString(err, str);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -164,7 +164,7 @@ enum {
|
||||
|
||||
/* AES */
|
||||
typedef struct CRYPT_AES_CTX {
|
||||
int holder[78]; /* big enough to hold internal, but check on init */
|
||||
int holder[90]; /* big enough to hold internal, but check on init */
|
||||
} CRYPT_AES_CTX;
|
||||
|
||||
/* key */
|
||||
|
@@ -15,5 +15,5 @@ noinst_HEADERS += mcapi/crypto.h
|
||||
|
||||
EXTRA_DIST += \
|
||||
mcapi/README \
|
||||
mcapi/PIC32MZ-serial.h
|
||||
|
||||
mcapi/PIC32MZ-serial.h \
|
||||
mcapi/user_settings.h
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* test.c
|
||||
/* mcapi_test.c
|
||||
*
|
||||
* Copyright (C) 2006-2016 wolfSSL Inc.
|
||||
*
|
||||
@@ -59,6 +59,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <p32xxxx.h>
|
||||
#define _SUPPRESS_PLIB_WARNING
|
||||
#define _DISABLE_OPENADC10_CONFIGPORT_WARNING
|
||||
#include <plib.h>
|
||||
#include <sys/appio.h>
|
||||
#define init_serial() /* void out init_serial() */
|
||||
|
386
mcapi/user_settings.h
Normal file
386
mcapi/user_settings.h
Normal file
@@ -0,0 +1,386 @@
|
||||
/* Example custom user settings for wolfSSL */
|
||||
|
||||
#ifndef WOLFSSL_USER_SETTINGS_H
|
||||
#define WOLFSSL_USER_SETTINGS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h> /* for size_t */
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Platform */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
#undef WOLFSSL_GENERAL_ALIGNMENT
|
||||
#define WOLFSSL_GENERAL_ALIGNMENT 4
|
||||
|
||||
#undef SINGLE_THREADED
|
||||
#define SINGLE_THREADED
|
||||
|
||||
#undef WOLFSSL_SMALL_STACK
|
||||
#define WOLFSSL_SMALL_STACK
|
||||
|
||||
#undef MICROCHIP_PIC32
|
||||
#define MICROCHIP_PIC32
|
||||
|
||||
#undef WOLFSSL_MICROCHIP_PIC32MZ
|
||||
#define WOLFSSL_MICROCHIP_PIC32MZ
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Math Configuration */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
#undef USE_FAST_MATH
|
||||
#define USE_FAST_MATH
|
||||
|
||||
#ifdef USE_FAST_MATH
|
||||
#undef TFM_TIMING_RESISTANT
|
||||
#define TFM_TIMING_RESISTANT
|
||||
|
||||
/* Optimizations */
|
||||
//#define TFM_MIPS
|
||||
#endif
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Crypto */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ECC */
|
||||
#if 1
|
||||
#undef HAVE_ECC
|
||||
#define HAVE_ECC
|
||||
|
||||
/* Manually define enabled curves */
|
||||
#undef ECC_USER_CURVES
|
||||
#define ECC_USER_CURVES
|
||||
|
||||
//#define HAVE_ECC192
|
||||
//#define HAVE_ECC224
|
||||
#undef NO_ECC256
|
||||
//#define HAVE_ECC384
|
||||
//#define HAVE_ECC521
|
||||
|
||||
/* Fixed point cache (speeds repeated operations against same private key) */
|
||||
#undef FP_ECC
|
||||
//#define FP_ECC
|
||||
#ifdef FP_ECC
|
||||
/* Bits / Entries */
|
||||
#undef FP_ENTRIES
|
||||
#define FP_ENTRIES 2
|
||||
#undef FP_LUT
|
||||
#define FP_LUT 4
|
||||
#endif
|
||||
|
||||
/* Optional ECC calculation method */
|
||||
/* Note: doubles heap usage, but slightly faster */
|
||||
#undef ECC_SHAMIR
|
||||
#define ECC_SHAMIR
|
||||
|
||||
/* Reduces heap usage, but slower */
|
||||
#undef ECC_TIMING_RESISTANT
|
||||
#define ECC_TIMING_RESISTANT
|
||||
|
||||
#ifdef USE_FAST_MATH
|
||||
/* use reduced size math buffers for ecc points */
|
||||
#undef ALT_ECC_SIZE
|
||||
#define ALT_ECC_SIZE
|
||||
|
||||
/* Enable TFM optimizations for ECC */
|
||||
#if defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)
|
||||
#define TFM_ECC192
|
||||
#endif
|
||||
#if defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES)
|
||||
#define TFM_ECC224
|
||||
#endif
|
||||
#if !defined(NO_ECC256) || defined(HAVE_ALL_CURVES)
|
||||
#define TFM_ECC256
|
||||
#endif
|
||||
#if defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES)
|
||||
#define TFM_ECC384
|
||||
#endif
|
||||
#if defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES)
|
||||
#define TFM_ECC521
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* RSA */
|
||||
#undef NO_RSA
|
||||
#if 1
|
||||
#ifdef USE_FAST_MATH
|
||||
/* Maximum math bits (Max RSA key bits * 2) */
|
||||
#undef FP_MAX_BITS
|
||||
#define FP_MAX_BITS 2048
|
||||
#endif
|
||||
|
||||
/* half as much memory but twice as slow */
|
||||
#undef RSA_LOW_MEM
|
||||
//#define RSA_LOW_MEM
|
||||
|
||||
/* timing resistance */
|
||||
#undef WC_RSA_BLINDING
|
||||
#define WC_RSA_BLINDING
|
||||
#else
|
||||
#define NO_RSA
|
||||
#endif
|
||||
|
||||
/* AES */
|
||||
#undef NO_AES
|
||||
#if 1
|
||||
#undef HAVE_AES_DECRYPT
|
||||
#define HAVE_AES_DECRYPT
|
||||
|
||||
#undef HAVE_AESGCM
|
||||
#define HAVE_AESGCM
|
||||
|
||||
/* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */
|
||||
#undef GCM_SMALL
|
||||
#define GCM_SMALL
|
||||
|
||||
#undef HAVE_AESCCM
|
||||
#define HAVE_AESCCM
|
||||
|
||||
#undef WOLFSSL_AES_COUNTER
|
||||
#define WOLFSSL_AES_COUNTER
|
||||
|
||||
#undef WOLFSSL_AES_DIRECT
|
||||
#define WOLFSSL_AES_DIRECT
|
||||
#else
|
||||
#define NO_AES
|
||||
#endif
|
||||
|
||||
/* DES3 */
|
||||
#undef NO_DES3
|
||||
#if 1
|
||||
#undef WOLFSSL_DES_ECB
|
||||
#define WOLFSSL_DES_ECB
|
||||
#else
|
||||
#define NO_DES3
|
||||
#endif
|
||||
|
||||
|
||||
/* ChaCha20 / Poly1305 */
|
||||
#undef HAVE_CHACHA
|
||||
#undef HAVE_POLY1305
|
||||
#if 0
|
||||
#define HAVE_CHACHA
|
||||
#define HAVE_POLY1305
|
||||
|
||||
/* Needed for Poly1305 */
|
||||
#undef HAVE_ONE_TIME_AUTH
|
||||
#define HAVE_ONE_TIME_AUTH
|
||||
#endif
|
||||
|
||||
/* Ed25519 / Curve25519 */
|
||||
#undef HAVE_CURVE25519
|
||||
#undef HAVE_ED25519
|
||||
#if 0
|
||||
#define HAVE_CURVE25519
|
||||
#define HAVE_ED25519
|
||||
|
||||
/* Optionally use small math (less flash usage, but much slower) */
|
||||
#if 0
|
||||
#define CURVED25519_SMALL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Hashing */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Sha */
|
||||
#undef NO_SHA
|
||||
#if 1
|
||||
/* 1k smaller, but 25% slower */
|
||||
//#define USE_SLOW_SHA
|
||||
#else
|
||||
#define NO_SHA
|
||||
#endif
|
||||
|
||||
/* Sha256 */
|
||||
#undef NO_SHA256
|
||||
#if 1
|
||||
#else
|
||||
#define NO_SHA256
|
||||
#endif
|
||||
|
||||
/* Sha512 */
|
||||
#undef WOLFSSL_SHA512
|
||||
#if 1
|
||||
#define WOLFSSL_SHA512
|
||||
|
||||
/* Sha384 */
|
||||
#undef WOLFSSL_SHA384
|
||||
#if 1
|
||||
#define WOLFSSL_SHA384
|
||||
#endif
|
||||
|
||||
/* over twice as small, but 50% slower */
|
||||
//#define USE_SLOW_SHA2
|
||||
#endif
|
||||
|
||||
/* MD5 */
|
||||
#undef NO_MD5
|
||||
#if 1
|
||||
#else
|
||||
#define NO_MD5
|
||||
#endif
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Benchmark / Test */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Use reduced benchmark / test sizes */
|
||||
#undef BENCH_EMBEDDED
|
||||
#define BENCH_EMBEDDED
|
||||
|
||||
#undef USE_CERT_BUFFERS_2048
|
||||
//#define USE_CERT_BUFFERS_2048
|
||||
|
||||
#undef USE_CERT_BUFFERS_1024
|
||||
#define USE_CERT_BUFFERS_1024
|
||||
|
||||
#undef USE_CERT_BUFFERS_256
|
||||
#define USE_CERT_BUFFERS_256
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Time */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
#if 0
|
||||
/* Override Current Time */
|
||||
/* Allows custom "custom_time()" function to be used for benchmark */
|
||||
#define WOLFSSL_USER_CURRTIME
|
||||
#define USER_TICKS
|
||||
extern unsigned long custom_time(unsigned long* timer);
|
||||
#define XTIME custom_time
|
||||
#else
|
||||
#warning Time/RTC disabled
|
||||
#undef NO_ASN_TIME
|
||||
#define NO_ASN_TIME
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Debugging */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
#undef DEBUG_WOLFSSL
|
||||
#define DEBUG_WOLFSSL
|
||||
|
||||
#ifdef DEBUG_WOLFSSL
|
||||
/* Use this to measure / print heap usage */
|
||||
#if 0
|
||||
#undef USE_WOLFSSL_MEMORY
|
||||
#define USE_WOLFSSL_MEMORY
|
||||
#undef WOLFSSL_TRACK_MEMORY
|
||||
#define WOLFSSL_TRACK_MEMORY
|
||||
#endif
|
||||
#else
|
||||
#undef NO_WOLFSSL_MEMORY
|
||||
#define NO_WOLFSSL_MEMORY
|
||||
|
||||
#undef NO_ERROR_STRINGS
|
||||
//#define NO_ERROR_STRINGS
|
||||
#endif
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Enable Features */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
#undef KEEP_PEER_CERT
|
||||
//#define KEEP_PEER_CERT
|
||||
|
||||
#undef HAVE_COMP_KEY
|
||||
//#define HAVE_COMP_KEY
|
||||
|
||||
#undef HAVE_TLS_EXTENSIONS
|
||||
//#define HAVE_TLS_EXTENSIONS
|
||||
|
||||
#undef HAVE_SUPPORTED_CURVES
|
||||
//#define HAVE_SUPPORTED_CURVES
|
||||
|
||||
#undef WOLFSSL_BASE64_ENCODE
|
||||
//#define WOLFSSL_BASE64_ENCODE
|
||||
|
||||
/* TLS Session Cache */
|
||||
#if 0
|
||||
#define SMALL_SESSION_CACHE
|
||||
#else
|
||||
#define NO_SESSION_CACHE
|
||||
#endif
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Disable Features */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
#undef NO_WOLFSSL_SERVER
|
||||
//#define NO_WOLFSSL_SERVER
|
||||
|
||||
#undef NO_WOLFSSL_CLIENT
|
||||
//#define NO_WOLFSSL_CLIENT
|
||||
|
||||
#undef NO_CRYPT_TEST
|
||||
//#define NO_CRYPT_TEST
|
||||
|
||||
#undef NO_CRYPT_BENCHMARK
|
||||
//#define NO_CRYPT_BENCHMARK
|
||||
|
||||
/* In-lining of misc.c functions */
|
||||
/* If defined, must include wolfcrypt/src/misc.c in build */
|
||||
/* Slower, but about 1k smaller */
|
||||
#undef NO_INLINE
|
||||
//#define NO_INLINE
|
||||
|
||||
#undef NO_FILESYSTEM
|
||||
#define NO_FILESYSTEM
|
||||
|
||||
#undef NO_WRITEV
|
||||
#define NO_WRITEV
|
||||
|
||||
#undef NO_MAIN_DRIVER
|
||||
#define NO_MAIN_DRIVER
|
||||
|
||||
#undef NO_DEV_RANDOM
|
||||
#define NO_DEV_RANDOM
|
||||
|
||||
#undef NO_DSA
|
||||
#define NO_DSA
|
||||
|
||||
#undef NO_DH
|
||||
#define NO_DH
|
||||
|
||||
#undef NO_RC4
|
||||
#define NO_RC4
|
||||
|
||||
#undef NO_OLD_TLS
|
||||
#define NO_OLD_TLS
|
||||
|
||||
#undef NO_HC128
|
||||
#define NO_HC128
|
||||
|
||||
#undef NO_RABBIT
|
||||
#define NO_RABBIT
|
||||
|
||||
#undef NO_PSK
|
||||
#define NO_PSK
|
||||
|
||||
#undef NO_MD4
|
||||
#define NO_MD4
|
||||
|
||||
#undef NO_PWDBASED
|
||||
#define NO_PWDBASED
|
||||
|
||||
#undef NO_CODING
|
||||
//#define NO_CODING
|
||||
|
||||
|
||||
/* Suppress array-bounds */
|
||||
#pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WOLFSSL_USER_SETTINGS_H */
|
@@ -4,6 +4,7 @@
|
||||
<logicalFolder name="HeaderFiles"
|
||||
displayName="Header Files"
|
||||
projectFiles="true">
|
||||
<itemPath>../user_settings.h</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="LinkerScript"
|
||||
displayName="Linker Files"
|
||||
@@ -110,8 +111,7 @@
|
||||
<property key="place-data-into-section" value="false"/>
|
||||
<property key="post-instruction-scheduling" value="default"/>
|
||||
<property key="pre-instruction-scheduling" value="default"/>
|
||||
<property key="preprocessor-macros"
|
||||
value="WOLFSSL_SHA384;WOLFSSL_SHA512;HAVE_ECC;HAVE_LIBZ;HAVE_MCAPI"/>
|
||||
<property key="preprocessor-macros" value="WOLFSSL_USER_SETTINGS;HAVE_LIBZ;HAVE_MCAPI"/>
|
||||
<property key="strict-ansi" value="false"/>
|
||||
<property key="support-ansi" value="false"/>
|
||||
<property key="use-cci" value="false"/>
|
||||
@@ -149,7 +149,7 @@
|
||||
<property key="preprocessor-macros" value=""/>
|
||||
<property key="remove-unused-sections" value="false"/>
|
||||
<property key="report-memory-usage" value="false"/>
|
||||
<property key="stack-size" value="2048"/>
|
||||
<property key="stack-size" value="20480"/>
|
||||
<property key="symbol-stripping" value=""/>
|
||||
<property key="trace-symbols" value=""/>
|
||||
<property key="warn-section-align" value="false"/>
|
||||
|
@@ -4,6 +4,7 @@
|
||||
<logicalFolder name="HeaderFiles"
|
||||
displayName="Header Files"
|
||||
projectFiles="true">
|
||||
<itemPath>../user_settings.h</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="LinkerScript"
|
||||
displayName="Linker Files"
|
||||
@@ -110,8 +111,7 @@
|
||||
<property key="place-data-into-section" value="false"/>
|
||||
<property key="post-instruction-scheduling" value="default"/>
|
||||
<property key="pre-instruction-scheduling" value="default"/>
|
||||
<property key="preprocessor-macros"
|
||||
value="NO_MAIN_DRIVER;USE_CERT_BUFFERS_1024;WOLFSSL_SHA384;WOLFSSL_SHA512;HAVE_ECC;HAVE_LIBZ;HAVE_MCAPI"/>
|
||||
<property key="preprocessor-macros" value="WOLFSSL_USER_SETTINGS;HAVE_LIBZ;HAVE_MCAPI"/>
|
||||
<property key="strict-ansi" value="false"/>
|
||||
<property key="support-ansi" value="false"/>
|
||||
<property key="use-cci" value="false"/>
|
||||
|
@@ -4,6 +4,7 @@
|
||||
<logicalFolder name="HeaderFiles"
|
||||
displayName="Header Files"
|
||||
projectFiles="true">
|
||||
<itemPath>../user_settings.h</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="LinkerScript"
|
||||
displayName="Linker Files"
|
||||
@@ -37,10 +38,8 @@
|
||||
<itemPath>../../wolfcrypt/src/md5.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/memory.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/misc.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/pic32mz-hash.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/pkcs7.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/poly1305.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/pw.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/pwdbased.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/rabbit.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/random.c</itemPath>
|
||||
@@ -51,6 +50,21 @@
|
||||
<itemPath>../../wolfcrypt/src/sha512.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/tfm.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/wc_port.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/port/pic32/pic32mz-hash.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/port/pic32/pic32mz-crypt.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/hash.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/chacha20_poly1305.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/curve25519.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/ed25519.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/fe_low_mem.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/fe_operations.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/ge_low_mem.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/ge_operations.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/wc_encrypt.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/pkcs12.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/signature.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/wolfevent.c</itemPath>
|
||||
<itemPath>../../wolfcrypt/src/wolfmath.c</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="src" displayName="wolfssl" projectFiles="true">
|
||||
<itemPath>../../src/crl.c</itemPath>
|
||||
@@ -61,6 +75,7 @@
|
||||
<itemPath>../../src/sniffer.c</itemPath>
|
||||
<itemPath>../../src/ssl.c</itemPath>
|
||||
<itemPath>../../src/tls.c</itemPath>
|
||||
<itemPath>../../src/tls13.c</itemPath>
|
||||
</logicalFolder>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="ExternalFiles"
|
||||
@@ -118,7 +133,7 @@
|
||||
<property key="enable-unroll-loops" value="false"/>
|
||||
<property key="exclude-floating-point" value="false"/>
|
||||
<property key="extra-include-directories"
|
||||
value="../../;../../mcapi;../../zlib-1.2.8;/Users/chrisc/yaSSL/products/cyassl/git/cyassl57/zlib-1.2.7"/>
|
||||
value="../../;../../mcapi;../../mplabx;../../zlib-1.2.8"/>
|
||||
<property key="generate-16-bit-code" value="false"/>
|
||||
<property key="generate-micro-compressed-code" value="false"/>
|
||||
<property key="isolate-each-function" value="false"/>
|
||||
@@ -127,8 +142,7 @@
|
||||
<property key="place-data-into-section" value="false"/>
|
||||
<property key="post-instruction-scheduling" value="default"/>
|
||||
<property key="pre-instruction-scheduling" value="default"/>
|
||||
<property key="preprocessor-macros"
|
||||
value="WOLFSSL_SHA512;WOLFSSL_SHA384;WOLFSSL_AES_COUNTER;WOLFSSL_AES_DIRECT;HAVE_ECC;HAVE_LIBZ;HAVE_MCAPI"/>
|
||||
<property key="preprocessor-macros" value="WOLFSSL_USER_SETTINGS;HAVE_LIBZ;HAVE_MCAPI"/>
|
||||
<property key="strict-ansi" value="false"/>
|
||||
<property key="support-ansi" value="false"/>
|
||||
<property key="use-cci" value="false"/>
|
||||
|
Reference in New Issue
Block a user