add MPLAB X projects, PIC32 GenerateSeed()

This commit is contained in:
Chris Conlon
2013-01-30 18:02:18 -07:00
parent b3ffcbd5b4
commit 5d29bf1e49
12 changed files with 327 additions and 2 deletions

View File

@@ -55,6 +55,9 @@ include testsuite/include.am
include tests/include.am
include sslSniffer/sslSnifferTest/include.am
include rpm/include.am
include mplabx/ctaocrypt_benchmark.X/nbproject/include.am
include mplabx/ctaocrypt_test.X/nbproject/include.am
include mplabx/cyassl.X/nbproject/include.am
if USE_VALGRIND
TESTS_ENVIRONMENT=./valgrind-error.sh

View File

@@ -455,6 +455,25 @@ int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
return 0;
}
#elif defined(MICROCHIP_PIC32)
#include <peripheral/timer.h>
/* uses the core timer, in nanoseconds to seed srand */
int GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
int i;
srand(ReadCoreTimer() * 25);
for (i = 0; i < sz; i++ ) {
output[i] = rand() % 256;
if ( (i % 8) == 7)
srand(ReadCoreTimer() * 25);
}
return 0;
}
#elif defined(CYASSL_SAFERTOS) || defined(CYASSL_LEANPSK)
#warning "write a real random seed!!!!, just for testing now"

View File

@@ -88,9 +88,14 @@
#endif
#ifdef MICROCHIP_PIC32
/* use MBED plus no filesystem */
#define MBED
#define SIZEOF_LONG_LONG 8
#define SINGLE_THREADED
#define CYASSL_USER_IO
#define NO_WRITEV
#define NO_DEV_RANDOM
#define NO_FILESYSTEM
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#endif
#ifdef MBED

37
mplabx/README Normal file
View File

@@ -0,0 +1,37 @@
CyaSSL MPLAB X Project Files
This directory contains project files for the Microchip MPLAB X IDE. These
projects have been set up to use the Microchip PIC32 Ethernet Starter Kit
and the Microchip XC32 compiler.
In order to generate the necessary auto-generated MPLAB X files, make sure
to import the cyassl.X project into your MPLAB X workspace before trying to
build either the CTaoCrypt test or benchmark applications.
Included Project Files
-----------------------
1. CyaSSL library (cyassl.X)
This project build a static CyaSSL library. Prior to building this
project, uncomment the MICROCHIP_PIC32 define located in:
<cyassl_root>/cyassl/ctaocrypt/settings.h
After this project has been built, the compiled library will be located
at:
<cyassl_root>/mplabx/cyassl.X/dist/default/production/cyassl.X.a
2. CTaoCrypt Test App (ctaocrypt_test.X)
3. CTaoCrypt Benchmark App (ctaocrypt_benchmark.X)
MIPS16 and MIPS32 Support
-------------------------
These projects support both MIPS16 and MIPS32 instruction sets. Switching
between these two instruction sets can be done in each project's properties
settings by checking the "Generate 16-bit code" checkbox.

View File

@@ -0,0 +1,116 @@
/* main.c
*
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
*
* This file is part of CyaSSL.
*
* CyaSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* CyaSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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 <p32xxxx.h>
#include <plib.h>
#include <sys/appio.h>
void bench_des(void);
void bench_arc4(void);
void bench_hc128(void);
void bench_rabbit(void);
void bench_aes(int);
void bench_aesgcm(void);
void bench_md5(void);
void bench_sha(void);
void bench_sha256(void);
void bench_sha512(void);
void bench_ripemd(void);
void bench_rsa(void);
void bench_rsaKeyGen(void);
void bench_dh(void);
#ifdef HAVE_ECC
void bench_eccKeyGen(void);
void bench_eccKeyAgree(void);
#endif
/*
* Main driver for CTaoCrypt benchmarks.
*/
int main(int argc, char** argv) {
SYSTEMConfigPerformance(80000000);
DBINIT();
printf("CTaoCrypt Benchmark:\n");
#ifndef NO_AES
bench_aes(0);
bench_aes(1);
#endif
#ifdef HAVE_AESGCM
bench_aesgcm();
#endif
#ifndef NO_RC4
bench_arc4();
#endif
#ifdef HAVE_HC128
bench_hc128();
#endif
#ifndef NO_RABBIT
bench_rabbit();
#endif
#ifndef NO_DES3
bench_des();
#endif
printf("\n");
#ifndef NO_MD5
bench_md5();
#endif
bench_sha();
#ifndef NO_SHA256
bench_sha256();
#endif
#ifdef CYASSL_SHA512
bench_sha512();
#endif
#ifdef CYASSL_RIPEMD
bench_ripemd();
#endif
printf("\n");
#ifndef NO_RSA
bench_rsa();
#endif
#ifndef NO_DH
bench_dh();
#endif
#if defined(CYASSL_KEY_GEN) && !defined(NO_RSA)
bench_rsaKeyGen();
#endif
#ifdef HAVE_ECC
bench_eccKeyGen();
bench_eccKeyAgree();
#endif
return 0;
}

View File

@@ -0,0 +1,12 @@
# vim:ft=automake
# All paths should be given relative to the root
#
EXTRA_DIST += \
mplabx/ctaocrypt_benchmark.X/Makefile \
mplabx/ctaocrypt_benchmark.X/main.c
EXTRA_DIST += \
mplabx/ctaocrypt_benchmark.X/nbproject/configurations.xml \
mplabx/ctaocrypt_benchmark.X/nbproject/project.xml

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>com.microchip.mplab.nbide.embedded.makeproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1">
<name>ctaocrypt_benchmark</name>
<creation-uuid>22e4138b-5f20-4957-ac0a-c181b94d3342</creation-uuid>
<make-project-type>0</make-project-type>
<c-extensions>c</c-extensions>
<cpp-extensions/>
<header-extensions/>
<sourceEncoding>ISO-8859-1</sourceEncoding>
<make-dep-projects>
<make-dep-project>../cyassl.X</make-dep-project>
</make-dep-projects>
</data>
</configuration>
</project>

View File

@@ -0,0 +1,57 @@
/* main.c
*
* Copyright (C) 2006-2012 Sawtooth Consulting Ltd.
*
* This file is part of CyaSSL.
*
* CyaSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* CyaSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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 <stdio.h>
#include <stdlib.h>
#include <p32xxxx.h>
#include <sys/appio.h>
/* func_args from test.h, so don't have to pull in other junk */
typedef struct func_args {
int argc;
char** argv;
int return_code;
} func_args;
/*
* Main driver for CTaoCrypt tests.
*/
int main(int argc, char** argv) {
DBINIT();
printf("CTaoCrypt Test:\n");
func_args args;
args.argc = argc;
args.argv = argv;
ctaocrypt_test(&args);
if (args.return_code == 0) {
printf("All tests passed!\n");
}
return 0;
}

View File

@@ -0,0 +1,12 @@
# vim:ft=automake
# All paths should be given relative to the root
#
EXTRA_DIST += \
mplabx/ctaocrypt_test.X/Makefile \
mplabx/ctaocrypt_test.X/main.c
EXTRA_DIST += \
mplabx/ctaocrypt_test.X/nbproject/configurations.xml \
mplabx/ctaocrypt_test.X/nbproject/project.xml

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>com.microchip.mplab.nbide.embedded.makeproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1">
<name>ctaocrypt_test</name>
<creation-uuid>b34c4937-7042-4352-88b1-7717bcdf8aeb</creation-uuid>
<make-project-type>0</make-project-type>
<c-extensions>c</c-extensions>
<cpp-extensions/>
<header-extensions>h</header-extensions>
<sourceEncoding>ISO-8859-1</sourceEncoding>
<make-dep-projects>
<make-dep-project>../cyassl.X</make-dep-project>
</make-dep-projects>
</data>
</configuration>
</project>

View File

@@ -0,0 +1,12 @@
# vim:ft=automake
# All paths should be given relative to the root
#
EXTRA_DIST += \
mplabx/README \
mplabx/cyassl.X/Makefile
EXTRA_DIST += \
mplabx/cyassl.X/nbproject/configurations.xml \
mplabx/cyassl.X/nbproject/project.xml

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>com.microchip.mplab.nbide.embedded.makeproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1">
<name>cyassl</name>
<creation-uuid>93bbfc3a-a0fa-4d48-bbc8-6cd47a2bd05b</creation-uuid>
<make-project-type>0</make-project-type>
<c-extensions>c</c-extensions>
<cpp-extensions/>
<header-extensions/>
<sourceEncoding>ISO-8859-1</sourceEncoding>
<make-dep-projects/>
</data>
</configuration>
</project>