diff --git a/ctaocrypt/benchmark/benchmark.c b/ctaocrypt/benchmark/benchmark.c index d0f9fbd38..4ad39833e 100644 --- a/ctaocrypt/benchmark/benchmark.c +++ b/ctaocrypt/benchmark/benchmark.c @@ -1063,29 +1063,28 @@ void bench_eccKeyAgree(void) } #elif defined MICROCHIP_PIC32 - - #include + #if defined(CYASSL_MICROCHIP_PIC32MZ) + #define CLOCK 8000000.0 + #else + #include + #define CLOCK 4000000.0 + #endif double current_time(int reset) { - /* NOTE: core timer tick rate = 40 Mhz, 1 tick = 25 ns */ - unsigned int ns; - /* should we reset our timer back to zero? Helps prevent timer - rollover */ - if (reset) { WriteCoreTimer(0); } /* get timer in ns */ - ns = ReadCoreTimer() * 25; + ns = ReadCoreTimer(); /* return seconds as a double */ - return ( ns / 1000000000.0 ); + return ( ns / CLOCK * 2.0); } - + #elif defined CYASSL_MDK_ARM extern double current_time(int reset) ; #else diff --git a/ctaocrypt/src/random.c b/ctaocrypt/src/random.c index 0cb566404..c81380d18 100644 --- a/ctaocrypt/src/random.c +++ b/ctaocrypt/src/random.c @@ -23,6 +23,8 @@ #include #endif +#include + /* on HPUX 11 you may need to install /dev/random see http://h20293.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=KRNG11I @@ -460,8 +462,10 @@ int GenerateSeed(OS_Seed* os, byte* output, word32 sz) #ifdef MICROCHIP_MPLAB_HARMONY #define PIC32_SEED_COUNT _CP0_GET_COUNT -#else - #include +#else + #if !defined(CYASSL_MICROCHIP_PIC32MZ) + #include + #endif #define PIC32_SEED_COUNT ReadCoreTimer #endif diff --git a/cyassl/ssl.h b/cyassl/ssl.h index 245cdebf4..1fd697712 100644 --- a/cyassl/ssl.h +++ b/cyassl/ssl.h @@ -805,8 +805,10 @@ CYASSL_API char* CyaSSL_X509_get_next_altname(CYASSL_X509*); CYASSL_API CYASSL_X509* CyaSSL_X509_d2i(CYASSL_X509** x509, const unsigned char* in, int len); +#ifndef NO_FILESYSTEM CYASSL_API CYASSL_X509* CyaSSL_X509_d2i_fp(CYASSL_X509** x509, FILE* file); +#endif CYASSL_API CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format); diff --git a/mcapi/PIC32MZ-serial.h b/mcapi/PIC32MZ-serial.h new file mode 100644 index 000000000..323de525b --- /dev/null +++ b/mcapi/PIC32MZ-serial.h @@ -0,0 +1,28 @@ +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; + ANSELBCLR = 0x4000; + ANSELGCLR = 0x0040; + RPB14R = 0x02; + U2RXR = 0x01; + U2MODE = 0x8000; + U2STA = 0x400; +#elif defined __PIC32MX__ + SYSTEMConfigPerformance(80000000); + DBINIT(); +#endif + +#endif +} diff --git a/mcapi/ctaocrypt_mcapi.X/nbproject/configurations.xml b/mcapi/ctaocrypt_mcapi.X/nbproject/configurations.xml index 0c1e4c6cf..54eef5bf8 100644 --- a/mcapi/ctaocrypt_mcapi.X/nbproject/configurations.xml +++ b/mcapi/ctaocrypt_mcapi.X/nbproject/configurations.xml @@ -12,7 +12,7 @@ - ../../mcapi/test.c + ../mcapi_test.c Makefile + + .. + Makefile @@ -30,8 +33,8 @@ SKDEPIC32PlatformTool XC32 - 1.10 - 4 + 1.30 + 3 @@ -106,6 +109,7 @@ + @@ -123,6 +127,7 @@ + @@ -133,10 +138,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mcapi/ctaocrypt_mcapi.X/nbproject/project.xml b/mcapi/ctaocrypt_mcapi.X/nbproject/project.xml index ba9477e80..ee5e120b0 100644 --- a/mcapi/ctaocrypt_mcapi.X/nbproject/project.xml +++ b/mcapi/ctaocrypt_mcapi.X/nbproject/project.xml @@ -1,5 +1,4 @@ - - + com.microchip.mplab.nbide.embedded.makeproject diff --git a/mcapi/ctaocrypt_test.X/nbproject/configurations.xml b/mcapi/ctaocrypt_test.X/nbproject/configurations.xml index 83cc5d002..e0ee5463e 100644 --- a/mcapi/ctaocrypt_test.X/nbproject/configurations.xml +++ b/mcapi/ctaocrypt_test.X/nbproject/configurations.xml @@ -13,8 +13,8 @@ - main.c ../../ctaocrypt/test/test.c + ../../mplabx/test_main.c Makefile + + ../../mplabx + Makefile @@ -32,8 +35,8 @@ SKDEPIC32PlatformTool XC32 - 1.10 - 4 + 1.30 + 3 @@ -108,6 +111,7 @@ + @@ -141,6 +145,7 @@ + @@ -176,7 +181,31 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mcapi/ctaocrypt_test.X/nbproject/project.xml b/mcapi/ctaocrypt_test.X/nbproject/project.xml index 0edce97de..d60fdcdb0 100644 --- a/mcapi/ctaocrypt_test.X/nbproject/project.xml +++ b/mcapi/ctaocrypt_test.X/nbproject/project.xml @@ -1,5 +1,4 @@ - - + com.microchip.mplab.nbide.embedded.makeproject diff --git a/mcapi/cyassl.X/nbproject/configurations.xml b/mcapi/cyassl.X/nbproject/configurations.xml index f98818350..7837eed08 100644 --- a/mcapi/cyassl.X/nbproject/configurations.xml +++ b/mcapi/cyassl.X/nbproject/configurations.xml @@ -52,6 +52,7 @@ ../../mcapi/crypto.c ../../ctaocrypt/src/compress.c ../../ctaocrypt/src/camellia.c + ../../ctaocrypt/src/port.c .. + ../../ctaocrypt/src Makefile @@ -72,8 +74,8 @@ SKDEPIC32PlatformTool XC32 - 1.10 - 4 + 1.30 + 3 @@ -109,6 +111,7 @@ + @@ -142,6 +145,7 @@ + @@ -177,6 +181,8 @@ + + diff --git a/mcapi/cyassl.X/nbproject/project.xml b/mcapi/cyassl.X/nbproject/project.xml index 831eae925..c7604d711 100644 --- a/mcapi/cyassl.X/nbproject/project.xml +++ b/mcapi/cyassl.X/nbproject/project.xml @@ -1,5 +1,4 @@ - - + com.microchip.mplab.nbide.embedded.makeproject diff --git a/mcapi/test.c b/mcapi/mcapi_test.c similarity index 98% rename from mcapi/test.c rename to mcapi/mcapi_test.c index 40de58bc0..c22618772 100644 --- a/mcapi/test.c +++ b/mcapi/mcapi_test.c @@ -44,16 +44,24 @@ #define USE_CERT_BUFFERS_1024 #include -/* c stdlib headers */ -#include - -/* pic32 specific */ -#ifdef MICROCHIP_PIC32 +#if defined(CYASSL_MICROCHIP_PIC32MZ) + #define MICROCHIP_PIC32 + #include + #pragma config ICESEL = ICS_PGx2 + /* ICE/ICD Comm Channel Select (Communicate on PGEC2/PGED2) */ + #include + #include + #include "PIC32MZ-serial.h" + #define SYSTEMConfigPerformance /* void out SYSTEMConfigPerformance(); */ +#else #define PIC32_STARTER_KIT + #include + #include #include #include + #include + #define init_serial() /* void out init_serial() */ #endif - #define OUR_DATA_SIZE 1024 static byte ourData[OUR_DATA_SIZE]; static byte* key = NULL; @@ -85,10 +93,9 @@ int main(int argc, char** argv) (void)argc; (void)argv; -#ifdef MICROCHIP_PIC32 + init_serial() ; /* initialize PIC32MZ serial I/O */ SYSTEMConfigPerformance(80000000); DBINIT(); -#endif /* align key, iv pointers */ key = (byte*)XMALLOC(32, NULL, DYNAMIC_TYPE_KEY); diff --git a/mcapi/zlib.X/nbproject/configurations.xml b/mcapi/zlib.X/nbproject/configurations.xml index bdf84a38d..cea50b3f1 100644 --- a/mcapi/zlib.X/nbproject/configurations.xml +++ b/mcapi/zlib.X/nbproject/configurations.xml @@ -44,8 +44,8 @@ SKDEPIC32PlatformTool XC32 - 1.10 - 4 + 1.30 + 3 @@ -80,6 +80,7 @@ + @@ -113,6 +114,7 @@ + @@ -148,6 +150,8 @@ + + diff --git a/mcapi/zlib.X/nbproject/project.xml b/mcapi/zlib.X/nbproject/project.xml index 060627700..b0da527da 100644 --- a/mcapi/zlib.X/nbproject/project.xml +++ b/mcapi/zlib.X/nbproject/project.xml @@ -1,5 +1,4 @@ - - + com.microchip.mplab.nbide.embedded.makeproject diff --git a/mplabx/PIC32MZ-Putc.c b/mplabx/PIC32MZ-Putc.c new file mode 100644 index 000000000..d77c4794d --- /dev/null +++ b/mplabx/PIC32MZ-Putc.c @@ -0,0 +1,10 @@ + +#ifdef MICROCHIP_PIC32 +#if defined (__32MZ2048ECH144__) || defined (__32MZ2048ECM144__) +void _mon_putc (char c) +{ + while (U2STAbits.UTXBF); + U2TXREG = c; +} +#endif +#endif \ No newline at end of file diff --git a/mplabx/PIC32MZ-serial.h b/mplabx/PIC32MZ-serial.h new file mode 100644 index 000000000..323de525b --- /dev/null +++ b/mplabx/PIC32MZ-serial.h @@ -0,0 +1,28 @@ +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; + ANSELBCLR = 0x4000; + ANSELGCLR = 0x0040; + RPB14R = 0x02; + U2RXR = 0x01; + U2MODE = 0x8000; + U2STA = 0x400; +#elif defined __PIC32MX__ + SYSTEMConfigPerformance(80000000); + DBINIT(); +#endif + +#endif +} diff --git a/mplabx/ctaocrypt_benchmark.X/main.c b/mplabx/benchmark_main.c similarity index 74% rename from mplabx/ctaocrypt_benchmark.X/main.c rename to mplabx/benchmark_main.c index 587eae1e2..f9c0bdaef 100644 --- a/mplabx/ctaocrypt_benchmark.X/main.c +++ b/mplabx/benchmark_main.c @@ -1,4 +1,4 @@ -/* main.c +/* benchmark_main.c * * Copyright (C) 2006-2013 wolfSSL Inc. * @@ -18,12 +18,20 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ - -#define PIC32_STARTER_KIT - -#include -#include -#include +#if defined(CYASSL_MICROCHIP_PIC32MZ) + #define MICROCHIP_PIC32 + #include + #pragma config ICESEL = ICS_PGx2 + /* ICE/ICD Comm Channel Select (Communicate on PGEC2/PGED2) */ + #include "PIC32MZ-serial.h" + #define SYSTEMConfigPerformance /* void out SYSTEMConfigPerformance(); */ +#else + #define PIC32_STARTER_KIT + #include + #include + #include + #define init_serial() /* void out init_serial() ; */ +#endif void bench_des(void); void bench_arc4(void); @@ -50,11 +58,14 @@ void bench_eccKeyAgree(void); * Main driver for CTaoCrypt benchmarks. */ int main(int argc, char** argv) { - - SYSTEMConfigPerformance(80000000); - + volatile int i ; + int j ; + + init_serial() ; /* initialize PIC32MZ serial I/O */ + SYSTEMConfigPerformance(80000000); DBINIT(); - printf("CTaoCrypt Benchmark:\n"); + + printf("wolfCrypt Benchmark:\n"); #ifndef NO_AES bench_aes(0); @@ -110,7 +121,7 @@ int main(int argc, char** argv) { bench_eccKeyGen(); bench_eccKeyAgree(); #endif - + printf("End of wolfCrypt Benchmark:\n"); return 0; } diff --git a/mplabx/ctaocrypt_benchmark.X/nbproject/configurations.xml b/mplabx/ctaocrypt_benchmark.X/nbproject/configurations.xml index 8617c2123..1b9409815 100644 --- a/mplabx/ctaocrypt_benchmark.X/nbproject/configurations.xml +++ b/mplabx/ctaocrypt_benchmark.X/nbproject/configurations.xml @@ -12,8 +12,8 @@ - main.c ../../ctaocrypt/benchmark/benchmark.c + ../benchmark_main.c Makefile + + .. + Makefile @@ -31,8 +34,8 @@ SKDEPIC32PlatformTool XC32 - 1.10 - 4 + 1.30 + 3 @@ -44,8 +47,8 @@ AC="true" BL="true" WD="../cyassl.X" - BC="${MAKE} -f Makefile CONF=default" - DBC="${MAKE} -f Makefile CONF=default TYPE_IMAGE=DEBUG_RUN" + BC="${MAKE} MAKE_OPTIONS="" -f Makefile CONF=default" + DBC="${MAKE} MAKE_OPTIONS="" -f Makefile CONF=default TYPE_IMAGE=DEBUG_RUN" CC="rm -rf "build/default" "dist/default"" OP="dist/default/production/cyassl.X.a" DOP="dist/default/debug/cyassl.X.a" @@ -81,7 +84,7 @@ - + @@ -90,6 +93,7 @@ + @@ -123,6 +127,7 @@ + @@ -158,9 +163,10 @@ + + - diff --git a/mplabx/ctaocrypt_benchmark.X/nbproject/project.xml b/mplabx/ctaocrypt_benchmark.X/nbproject/project.xml index 9ec9516cc..e87963a96 100644 --- a/mplabx/ctaocrypt_benchmark.X/nbproject/project.xml +++ b/mplabx/ctaocrypt_benchmark.X/nbproject/project.xml @@ -1,5 +1,4 @@ - - + com.microchip.mplab.nbide.embedded.makeproject diff --git a/mplabx/ctaocrypt_test.X/nbproject/configurations.xml b/mplabx/ctaocrypt_test.X/nbproject/configurations.xml index bd3e33e66..de0a4cde1 100644 --- a/mplabx/ctaocrypt_test.X/nbproject/configurations.xml +++ b/mplabx/ctaocrypt_test.X/nbproject/configurations.xml @@ -13,8 +13,8 @@ - main.c ../../ctaocrypt/test/test.c + ../test_main.c Makefile + + .. + Makefile @@ -32,8 +35,8 @@ SKDEPIC32PlatformTool XC32 - 1.10 - 4 + 1.30 + 3 @@ -45,8 +48,8 @@ AC="true" BL="true" WD="../cyassl.X" - BC="${MAKE} -f Makefile CONF=default" - DBC="${MAKE} -f Makefile CONF=default TYPE_IMAGE=DEBUG_RUN" + BC="${MAKE} MAKE_OPTIONS="" -f Makefile CONF=default" + DBC="${MAKE} MAKE_OPTIONS="" -f Makefile CONF=default TYPE_IMAGE=DEBUG_RUN" CC="rm -rf "build/default" "dist/default"" OP="dist/default/production/cyassl.X.a" DOP="dist/default/debug/cyassl.X.a" @@ -82,7 +85,7 @@ - + @@ -91,6 +94,7 @@ + @@ -124,6 +128,7 @@ + @@ -159,9 +164,10 @@ + + - diff --git a/mplabx/ctaocrypt_test.X/nbproject/project.xml b/mplabx/ctaocrypt_test.X/nbproject/project.xml index 3567a51b8..82180e826 100644 --- a/mplabx/ctaocrypt_test.X/nbproject/project.xml +++ b/mplabx/ctaocrypt_test.X/nbproject/project.xml @@ -1,5 +1,4 @@ - - + com.microchip.mplab.nbide.embedded.makeproject diff --git a/mplabx/cyassl.X/nbproject/configurations.xml b/mplabx/cyassl.X/nbproject/configurations.xml index cf2aebe06..e12a2e988 100644 --- a/mplabx/cyassl.X/nbproject/configurations.xml +++ b/mplabx/cyassl.X/nbproject/configurations.xml @@ -49,6 +49,7 @@ ../../ctaocrypt/src/sha256.c ../../ctaocrypt/src/sha512.c ../../ctaocrypt/src/tfm.c + ../../ctaocrypt/src/port.c .. + ../../cyassl/ctaocrypt + ../../ctaocrypt/src Makefile @@ -69,8 +72,8 @@ SKDEPIC32PlatformTool XC32 - 1.10 - 4 + 1.30 + 3 @@ -92,11 +95,11 @@ - + - + @@ -105,6 +108,7 @@ + @@ -138,6 +142,7 @@ + @@ -173,6 +178,8 @@ + + diff --git a/mplabx/cyassl.X/nbproject/project.xml b/mplabx/cyassl.X/nbproject/project.xml index 831eae925..c7604d711 100644 --- a/mplabx/cyassl.X/nbproject/project.xml +++ b/mplabx/cyassl.X/nbproject/project.xml @@ -1,5 +1,4 @@ - - + com.microchip.mplab.nbide.embedded.makeproject diff --git a/mplabx/ctaocrypt_test.X/main.c b/mplabx/test_main.c similarity index 66% rename from mplabx/ctaocrypt_test.X/main.c rename to mplabx/test_main.c index 5edccecad..cc9992da3 100644 --- a/mplabx/ctaocrypt_test.X/main.c +++ b/mplabx/test_main.c @@ -19,13 +19,24 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#define PIC32_STARTER_KIT - -#include -#include -#include -#include -#include +#if defined(CYASSL_MICROCHIP_PIC32MZ) + #define MICROCHIP_PIC32 + #include + #pragma config ICESEL = ICS_PGx2 + /* ICE/ICD Comm Channel Select (Communicate on PGEC2/PGED2) */ + #include + #include + #include "PIC32MZ-serial.h" + #define SYSTEMConfigPerformance /* void out SYSTEMConfigPerformance(); */ +#else + #define PIC32_STARTER_KIT + #include + #include + #include + #include + #include + #define init_serial() /* void out init_serial() */ +#endif /* func_args from test.h, so don't have to pull in other junk */ typedef struct func_args { @@ -38,12 +49,12 @@ typedef struct func_args { * Main driver for CTaoCrypt tests. */ int main(int argc, char** argv) { + int i ; + init_serial() ; /* initialize PIC32MZ serial I/O */ SYSTEMConfigPerformance(80000000); - DBINIT(); printf("CTaoCrypt Test:\n"); - func_args args; args.argc = argc;