mirror of
https://github.com/Cateners/tiny_computer.git
synced 2026-05-20 16:35:47 +08:00
Update code to v1.0.14 (10)
This commit is contained in:
153
android/extern/wolfssl/IDE/AURIX/Cpu0_Main.c
vendored
Normal file
153
android/extern/wolfssl/IDE/AURIX/Cpu0_Main.c
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
/* Cpu0_Main.c
|
||||
*
|
||||
* Copyright (C) 2006-2022 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL 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.
|
||||
*
|
||||
* wolfSSL 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/* Infineon includes */
|
||||
#include "Ifx_Types.h"
|
||||
#include "IfxCpu.h"
|
||||
#include "IfxScuWdt.h"
|
||||
#include "IfxAsclin_Asc.h"
|
||||
#include "IfxCpu_Irq.h"
|
||||
#include "IfxPort.h"
|
||||
#include "SysSe/Bsp/Bsp.h"
|
||||
|
||||
/* For mapping stdio printf */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* used to wait for CPU sync event */
|
||||
IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;
|
||||
|
||||
#define SERIAL_BAUDRATE 115200 /* Baud rate in bit/s */
|
||||
#define SERIAL_PIN_RX IfxAsclin0_RXA_P14_1_IN /* RX pin of the board */
|
||||
#define SERIAL_PIN_TX IfxAsclin0_TX_P14_0_OUT /* TX pin of the board */
|
||||
#define INTPRIO_ASCLIN0_TX 19 /* Priority of the ISR */
|
||||
#define ASC_TX_BUFFER_SIZE 128 /* Definition of the buffer size */
|
||||
|
||||
/* Declaration of the ASC handle */
|
||||
static IfxAsclin_Asc g_asc;
|
||||
|
||||
/* Declaration of the FIFOs parameters:
|
||||
* The transfer buffers allocate memory for the data itself and for FIFO runtime
|
||||
* variables. 8 more bytes have to be added to ensure a proper circular buffer
|
||||
* handling independent from the address to which the buffers have been located.
|
||||
*/
|
||||
static uint8 g_ascTxBuffer[ASC_TX_BUFFER_SIZE + sizeof(Ifx_Fifo) + 8];
|
||||
|
||||
/******************************************************************************/
|
||||
/*----Function Implementations------------------------------------------------*/
|
||||
/******************************************************************************/
|
||||
|
||||
/* Re-target the C library printf function to the asc lin. */
|
||||
int fputc(int ch, FILE *f)
|
||||
{
|
||||
Ifx_SizeT count;
|
||||
/* convert to CRLF */
|
||||
if (ch == (int)'\n') {
|
||||
int chcr = (int)'\r';
|
||||
count = 1;
|
||||
IfxAsclin_Asc_write(&g_asc, &chcr, &count, TIME_INFINITE);
|
||||
}
|
||||
count = 1;
|
||||
IfxAsclin_Asc_write(&g_asc, &ch, &count, TIME_INFINITE);
|
||||
return ch;
|
||||
}
|
||||
|
||||
/* Add the Interrupt Service Routine */
|
||||
IFX_INTERRUPT(asclin0_Tx_ISR, 0, INTPRIO_ASCLIN0_TX);
|
||||
void asclin0_Tx_ISR(void)
|
||||
{
|
||||
IfxAsclin_Asc_isrTransmit(&g_asc);
|
||||
}
|
||||
|
||||
static void init_UART(void)
|
||||
{
|
||||
IfxAsclin_Asc_Config ascConfig;
|
||||
|
||||
IfxCpu_Irq_installInterruptHandler(asclin0_Tx_ISR, INTPRIO_ASCLIN0_TX);
|
||||
|
||||
/* Port pins configuration */
|
||||
const IfxAsclin_Asc_Pins pins = {
|
||||
NULL_PTR, IfxPort_InputMode_pullUp, /* CTS pin not used */
|
||||
&SERIAL_PIN_RX, IfxPort_InputMode_pullUp, /* RX pin */
|
||||
NULL_PTR, IfxPort_OutputMode_pushPull, /* RTS pin not used */
|
||||
&SERIAL_PIN_TX, IfxPort_OutputMode_pushPull, /* TX pin */
|
||||
IfxPort_PadDriver_cmosAutomotiveSpeed1
|
||||
};
|
||||
|
||||
/* Initialize an instance of IfxAsclin_Asc_Config with default values */
|
||||
IfxAsclin_Asc_initModuleConfig(&ascConfig, SERIAL_PIN_TX.module);
|
||||
|
||||
/* Set the desired baud rate */
|
||||
ascConfig.baudrate.baudrate = SERIAL_BAUDRATE;
|
||||
|
||||
/* ISR priorities and interrupt target */
|
||||
ascConfig.interrupt.txPriority = INTPRIO_ASCLIN0_TX;
|
||||
ascConfig.interrupt.typeOfService = IfxCpu_Irq_getTos(IfxCpu_getCoreIndex());
|
||||
|
||||
/* FIFO configuration */
|
||||
ascConfig.txBuffer = &g_ascTxBuffer;
|
||||
ascConfig.txBufferSize = ASC_TX_BUFFER_SIZE;
|
||||
|
||||
ascConfig.pins = &pins;
|
||||
|
||||
/* Initialize module with above parameters */
|
||||
IfxAsclin_Asc_initModule(&g_asc, &ascConfig);
|
||||
|
||||
/* Turn off buffers, so I/O occurs immediately */
|
||||
setvbuf(stdin, NULL, _IONBF, 0);
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
setvbuf(stderr, NULL, _IONBF, 0);
|
||||
}
|
||||
|
||||
int send_UART(const char* str)
|
||||
{
|
||||
Ifx_SizeT count = (Ifx_SizeT)strlen(str);
|
||||
IfxAsclin_Asc_write(&g_asc, str, &count, TIME_INFINITE);
|
||||
return (int)count;
|
||||
}
|
||||
|
||||
void core0_main(void)
|
||||
{
|
||||
IfxCpu_enableInterrupts();
|
||||
|
||||
/* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!
|
||||
* Enable the watchdogs and service them periodically if it is required
|
||||
*/
|
||||
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
|
||||
IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());
|
||||
|
||||
/* Wait for CPU sync event */
|
||||
IfxCpu_emitEvent(&g_cpuSyncEvent);
|
||||
IfxCpu_waitEvent(&g_cpuSyncEvent, 1);
|
||||
|
||||
/* Initialize the UART to board VCOM */
|
||||
init_UART();
|
||||
|
||||
/* bare metal loop */
|
||||
while(1)
|
||||
{
|
||||
extern void run_wolf_tests(void);
|
||||
run_wolf_tests();
|
||||
|
||||
/* wait 5 seconds */
|
||||
waitTime(IfxStm_getTicksFromMilliseconds(BSP_DEFAULT_TIMER, 5 * 1000));
|
||||
} /* while */
|
||||
}
|
||||
114
android/extern/wolfssl/IDE/AURIX/README.md
vendored
Normal file
114
android/extern/wolfssl/IDE/AURIX/README.md
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
# Infineon AURIX Development Studio
|
||||
|
||||
An Eclipse based IDE for developing software for the Infineon TriCore AURIX TX3XX.
|
||||
|
||||
Tested Platform:
|
||||
* Infineon AURIX™ Development Studio 1.7.2 (Build 20220617-0730)
|
||||
* Infineon TriBoard TC399 v2.0
|
||||
* wolfSSL v5.4.0 (with PR 5419)
|
||||
|
||||
## Running wolfCrypt on TriCore
|
||||
|
||||
1) Add the wolfSSL source and headers to `Libraries/wolfssl`.
|
||||
- Only the following folders are required: `src`, `wolfcrypt` and `wolfssl`.
|
||||
- See script to help with producing bundle here: https://github.com/wolfSSL/wolfssl/blob/master/scripts/makedistsmall.sh
|
||||
2) Add `WOLFSSL_USER_SETTINGS` to the Preprocessing symbols list. C/C++ Build -> Settings -> TASKING C/C++ Compiler -> Preprocessing.
|
||||
3) Add `Libraries/wolfssl` to the include path. C/C++ General -> Paths and Symbols -> Includes -> GNU C
|
||||
4) Add ignores for the following warnings. Unused static function (553) and switch missing break (536). C/C++ Build -> Settings -> TASKING C/C++ Compiler -> Diagnostics
|
||||
5) Copy `Cpu0_Main.c`, `user_settings.h` and `wolf_main.c` into the project folder.
|
||||
6) Increase the stack by modifying `Lcf_Tasking_Tricore_Tc.lsl` to adjusting the USTACK0-4 (`LCF_USTACK#_SIZE`) from 2k to 12k.
|
||||
6) Build and run/debug.
|
||||
|
||||
### Example output from wolfCrypt test and benchmark
|
||||
|
||||
Benchmark Configuration:
|
||||
* TriCore (TC1.6.2P) 32-bit super-scalar running at 300MHz:
|
||||
* Release build: `-O2`
|
||||
* SP Math SMALL: sp_c32.c for RSA/ECC/DH
|
||||
* AES GCM SMALL
|
||||
|
||||
```
|
||||
Running wolfCrypt Tests...
|
||||
------------------------------------------------------------------------------
|
||||
wolfSSL version 5.4.0
|
||||
------------------------------------------------------------------------------
|
||||
error test passed!
|
||||
MEMORY test passed!
|
||||
base64 test passed!
|
||||
asn test passed!
|
||||
RANDOM test passed!
|
||||
SHA test passed!
|
||||
SHA-256 test passed!
|
||||
Hash test passed!
|
||||
HMAC-SHA test passed!
|
||||
HMAC-SHA256 test passed!
|
||||
HMAC-KDF test passed!
|
||||
TLSv1.3 KDF test passed!
|
||||
GMAC test passed!
|
||||
Chacha test passed!
|
||||
POLY1305 test passed!
|
||||
ChaCha20-Poly1305 AEAD test passed!
|
||||
AES test passed!
|
||||
AES192 test passed!
|
||||
AES256 test passed!
|
||||
AES-GCM test passed!
|
||||
RSA test passed!
|
||||
ECC test passed!
|
||||
ECC buffer test passed!
|
||||
CMAC test passed!
|
||||
logging test passed!
|
||||
time test passed!
|
||||
mutex test passed!
|
||||
memcb test passed!
|
||||
Test complete
|
||||
Crypt Test: Return code 0
|
||||
Running wolfCrypt Benchmarks...
|
||||
wolfCrypt Benchmark (block bytes 1024, min 1.0 sec each)
|
||||
RNG 725 KB took 1.023 seconds, 708.703 KB/s
|
||||
AES-128-CBC-enc 2 MB took 1.002 seconds, 2.071 MB/s
|
||||
AES-128-CBC-dec 2 MB took 1.005 seconds, 2.065 MB/s
|
||||
AES-192-CBC-enc 2 MB took 1.002 seconds, 1.779 MB/s
|
||||
AES-192-CBC-dec 2 MB took 1.013 seconds, 1.783 MB/s
|
||||
AES-256-CBC-enc 2 MB took 1.003 seconds, 1.558 MB/s
|
||||
AES-256-CBC-dec 2 MB took 1.009 seconds, 1.573 MB/s
|
||||
AES-128-GCM-enc 225 KB took 1.013 seconds, 222.112 KB/s
|
||||
AES-128-GCM-dec 225 KB took 1.014 seconds, 221.892 KB/s
|
||||
AES-192-GCM-enc 225 KB took 1.046 seconds, 215.107 KB/s
|
||||
AES-192-GCM-dec 225 KB took 1.046 seconds, 215.104 KB/s
|
||||
AES-256-GCM-enc 225 KB took 1.070 seconds, 210.279 KB/s
|
||||
AES-256-GCM-dec 225 KB took 1.069 seconds, 210.477 KB/s
|
||||
GMAC Small 251 KB took 1.000 seconds, 251.000 KB/s
|
||||
AES-128-ECB-enc 2 MB took 1.000 seconds, 2.000 MB/s
|
||||
AES-128-ECB-dec 2 MB took 1.000 seconds, 2.049 MB/s
|
||||
AES-192-ECB-enc 2 MB took 1.000 seconds, 1.727 MB/s
|
||||
AES-192-ECB-dec 2 MB took 1.000 seconds, 1.772 MB/s
|
||||
AES-256-ECB-enc 2 MB took 1.000 seconds, 1.518 MB/s
|
||||
AES-256-ECB-dec 2 MB took 1.000 seconds, 1.563 MB/s
|
||||
CHACHA 3 MB took 1.007 seconds, 3.322 MB/s
|
||||
CHA-POLY 2 MB took 1.011 seconds, 2.028 MB/s
|
||||
POLY1305 6 MB took 1.003 seconds, 6.012 MB/s
|
||||
SHA 3 MB took 1.004 seconds, 3.380 MB/s
|
||||
SHA-256 2 MB took 1.003 seconds, 1.558 MB/s
|
||||
AES-128-CMAC 2 MB took 1.010 seconds, 2.055 MB/s
|
||||
AES-256-CMAC 2 MB took 1.010 seconds, 1.547 MB/s
|
||||
HMAC-SHA 3 MB took 1.004 seconds, 3.356 MB/s
|
||||
HMAC-SHA256 2 MB took 1.010 seconds, 1.547 MB/s
|
||||
RSA 2048 public 50 ops took 1.020 sec, avg 20.400 ms, 49.019 ops/sec
|
||||
RSA 2048 private 2 ops took 2.377 sec, avg 1188.492 ms, 0.841 ops/sec
|
||||
ECC [ SECP256R1] 256 key gen 16 ops took 1.061 sec, avg 66.313 ms, 15.080 ops/sec
|
||||
ECDHE [ SECP256R1] 256 agree 16 ops took 1.059 sec, avg 66.187 ms, 15.109 ops/sec
|
||||
ECDSA [ SECP256R1] 256 sign 14 ops took 1.058 sec, avg 75.570 ms, 13.233 ops/sec
|
||||
ECDSA [ SECP256R1] 256 verify 8 ops took 1.080 sec, avg 135.002 ms, 7.407 ops/sec
|
||||
Benchmark complete
|
||||
Benchmark Test: Return code 0
|
||||
```
|
||||
|
||||
|
||||
## Running wolfCrypt on the HSM (Cortex M3)
|
||||
|
||||
Coming soon
|
||||
|
||||
|
||||
## Support
|
||||
|
||||
For questions please email facts@wolfssl.com
|
||||
8
android/extern/wolfssl/IDE/AURIX/include.am
vendored
Normal file
8
android/extern/wolfssl/IDE/AURIX/include.am
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# vim:ft=automake
|
||||
# included from Top Level Makefile.am
|
||||
# All paths should be given relative to the root
|
||||
|
||||
EXTRA_DIST+= IDE/AURIX/Cpu0_Main.c
|
||||
EXTRA_DIST+= IDE/AURIX/README.md
|
||||
EXTRA_DIST+= IDE/AURIX/user_settings.h
|
||||
EXTRA_DIST+= IDE/AURIX/wolf_main.c
|
||||
461
android/extern/wolfssl/IDE/AURIX/user_settings.h
vendored
Normal file
461
android/extern/wolfssl/IDE/AURIX/user_settings.h
vendored
Normal file
@@ -0,0 +1,461 @@
|
||||
/* user_settings.h
|
||||
*
|
||||
* Copyright (C) 2006-2022 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL 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.
|
||||
*
|
||||
* wolfSSL 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/* Template for the Infineon AURIX Development Studio and TC3XX
|
||||
* Example wolfSSL user settings with #if 0/1 gates to enable/disable algorithms and features.
|
||||
* This file is included with wolfssl/wolfcrypt/settings.h when WOLFSSL_USER_SETTINGS is defined.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef WOLFSSL_USER_SETTINGS_H
|
||||
#define WOLFSSL_USER_SETTINGS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Platform */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Alignment and sizeof 64-bit */
|
||||
#define WOLFSSL_GENERAL_ALIGNMENT 4
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
|
||||
/* disable threading - mutex locking */
|
||||
#define SINGLE_THREADED
|
||||
|
||||
/* ignore file include warnings */
|
||||
#define WOLFSSL_IGNORE_FILE_WARN
|
||||
|
||||
/* disable the built-in socket support and use the IO callbacks.
|
||||
* Set with wolfSSL_CTX_SetIORecv/wolfSSL_CTX_SetIOSend
|
||||
*/
|
||||
#define WOLFSSL_USER_IO
|
||||
|
||||
/* Disable file system */
|
||||
#define NO_FILESYSTEM
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Port */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Override Current Time */
|
||||
/* Allows custom "custom_time()" function to be used for benchmark */
|
||||
#define WOLFSSL_USER_CURRTIME
|
||||
#define WOLFSSL_GMTIME
|
||||
#define USER_TICKS
|
||||
extern unsigned long my_time(unsigned long* timer);
|
||||
#define XTIME my_time
|
||||
|
||||
/* Use built-in P-RNG (SHA256 based) with HW RNG */
|
||||
#undef HAVE_HASHDRBG
|
||||
#define HAVE_HASHDRBG
|
||||
|
||||
/* Custom Seed Source */
|
||||
#define CUSTOM_RAND_TYPE unsigned int
|
||||
extern unsigned int my_rng_seed_gen(void);
|
||||
#undef CUSTOM_RAND_GENERATE
|
||||
#define CUSTOM_RAND_GENERATE my_rng_seed_gen
|
||||
|
||||
/* Standard Lib - C89 */
|
||||
#define XSTRCASECMP(s1,s2) strcmp((s1),(s2))
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Math Configuration */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
#undef USE_FAST_MATH
|
||||
#undef WOLFSSL_SP
|
||||
#if 1
|
||||
/* Wolf Single Precision Math */
|
||||
#define WOLFSSL_HAVE_SP_RSA
|
||||
//#define WOLFSSL_HAVE_SP_DH
|
||||
#define WOLFSSL_HAVE_SP_ECC
|
||||
#define WOLFSSL_SP_4096 /* Enable RSA/RH 4096-bit support */
|
||||
#define WOLFSSL_SP_384 /* Enable ECC 384-bit SECP384R1 support */
|
||||
|
||||
#define WOLFSSL_SP_MATH /* only SP math - disables integer.c/tfm.c */
|
||||
//#define WOLFSSL_SP_MATH_ALL /* use SP math for all key sizes and curves */
|
||||
|
||||
#define WOLFSSL_SP_NO_MALLOC
|
||||
//#define WOLFSSL_SP_DIV_32 /* do not use 64-bit divides */
|
||||
//#define WOLFSSL_SP_CACHE_RESISTANT
|
||||
|
||||
/* use smaller version of code */
|
||||
#define WOLFSSL_SP_SMALL
|
||||
|
||||
/* SP Assembly Speedups - specific to chip type */
|
||||
//#define WOLFSSL_SP_ASM
|
||||
//#define WOLFSSL_SP_ARM32_ASM
|
||||
//#define WOLFSSL_SP_ARM64_ASM
|
||||
//#define WOLFSSL_SP_ARM_THUMB_ASM
|
||||
//#define WOLFSSL_SP_ARM_CORTEX_M_ASM
|
||||
#endif
|
||||
|
||||
#ifndef WOLFSSL_SP_MATH
|
||||
#if 0
|
||||
/* fast math (tfmc.) (stack based and timing resistant) */
|
||||
#define USE_FAST_MATH
|
||||
#define TFM_TIMING_RESISTANT
|
||||
#else
|
||||
/* normal heap based integer.c (not timing resistant) */
|
||||
#define USE_INTEGER_HEAP_MATH
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Crypto */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* RSA */
|
||||
#undef NO_RSA
|
||||
#if 1
|
||||
#ifdef USE_FAST_MATH
|
||||
/* Maximum math bits (Max RSA key bits * 2) */
|
||||
#define FP_MAX_BITS 4096
|
||||
#endif
|
||||
|
||||
/* half as much memory but twice as slow */
|
||||
//#define RSA_LOW_MEM
|
||||
|
||||
/* Enables blinding mode, to prevent timing attacks */
|
||||
#define WC_RSA_BLINDING
|
||||
|
||||
/* RSA PSS Support */
|
||||
#define WC_RSA_PSS
|
||||
#else
|
||||
#define NO_RSA
|
||||
#endif
|
||||
|
||||
/* DH */
|
||||
#undef NO_DH
|
||||
#if 0
|
||||
/* Use table for DH instead of -lm (math) lib dependency */
|
||||
#if 1
|
||||
#define WOLFSSL_DH_CONST
|
||||
#define HAVE_FFDHE_2048
|
||||
//#define HAVE_FFDHE_4096
|
||||
//#define HAVE_FFDHE_6144
|
||||
//#define HAVE_FFDHE_8192
|
||||
#endif
|
||||
#else
|
||||
#define NO_DH
|
||||
#endif
|
||||
|
||||
/* ECC */
|
||||
#undef HAVE_ECC
|
||||
#if 1
|
||||
#define HAVE_ECC
|
||||
|
||||
/* Manually define enabled curves */
|
||||
#define ECC_USER_CURVES
|
||||
|
||||
#ifdef ECC_USER_CURVES
|
||||
/* Manual Curve Selection */
|
||||
//#define HAVE_ECC192
|
||||
//#define HAVE_ECC224
|
||||
#undef NO_ECC256
|
||||
#define HAVE_ECC384
|
||||
//#define HAVE_ECC521
|
||||
#endif
|
||||
|
||||
/* Fixed point cache (speeds repeated operations against same private key) */
|
||||
//#define FP_ECC
|
||||
#ifdef FP_ECC
|
||||
/* Bits / Entries */
|
||||
#define FP_ENTRIES 2
|
||||
#define FP_LUT 4
|
||||
#endif
|
||||
|
||||
/* Optional ECC calculation method */
|
||||
/* Note: doubles heap usage, but slightly faster */
|
||||
#define ECC_SHAMIR
|
||||
|
||||
/* Reduces heap usage, but slower */
|
||||
#define ECC_TIMING_RESISTANT
|
||||
|
||||
/* Compressed ECC Key Support */
|
||||
//#define HAVE_COMP_KEY
|
||||
|
||||
/* Use alternate ECC size for ECC math */
|
||||
#ifdef USE_FAST_MATH
|
||||
/* MAX ECC BITS = ROUND8(MAX ECC) * 2 */
|
||||
#if defined(NO_RSA) && defined(NO_DH)
|
||||
/* Custom fastmath size if not using RSA/DH */
|
||||
#define FP_MAX_BITS (256 * 2)
|
||||
#else
|
||||
/* use heap allocation for ECC points */
|
||||
#define ALT_ECC_SIZE
|
||||
|
||||
/* wolfSSL will compute the FP_MAX_BITS_ECC, but it can be overriden */
|
||||
//#define FP_MAX_BITS_ECC (256 * 2)
|
||||
#endif
|
||||
|
||||
/* Speedups specific to curve */
|
||||
#ifndef NO_ECC256
|
||||
#define TFM_ECC256
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* AES */
|
||||
#undef NO_AES
|
||||
#if 1
|
||||
#define HAVE_AES_CBC
|
||||
|
||||
/* GCM Method: GCM_TABLE_4BIT, GCM_SMALL, GCM_WORD32 or GCM_TABLE */
|
||||
#define HAVE_AESGCM
|
||||
#define GCM_SMALL
|
||||
|
||||
#define WOLFSSL_AES_DIRECT
|
||||
#define HAVE_AES_ECB
|
||||
#else
|
||||
#define NO_AES
|
||||
#endif
|
||||
|
||||
|
||||
/* DES3 */
|
||||
#undef NO_DES3
|
||||
#if 0
|
||||
#else
|
||||
#define NO_DES3
|
||||
#endif
|
||||
|
||||
/* ChaCha20 / Poly1305 */
|
||||
#undef HAVE_CHACHA
|
||||
#undef HAVE_POLY1305
|
||||
#if 1
|
||||
#define HAVE_CHACHA
|
||||
#define HAVE_POLY1305
|
||||
|
||||
/* Needed for Poly1305 */
|
||||
#define HAVE_ONE_TIME_AUTH
|
||||
#endif
|
||||
|
||||
/* Ed25519 / Curve25519 */
|
||||
#undef HAVE_CURVE25519
|
||||
#undef HAVE_ED25519
|
||||
#if 0
|
||||
#define HAVE_CURVE25519
|
||||
#define HAVE_ED25519 /* ED25519 Requires SHA512 */
|
||||
|
||||
/* Optionally use small math (less flash usage, but much slower) */
|
||||
#if 1
|
||||
#define CURVED25519_SMALL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Hashing */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Sha */
|
||||
#undef NO_SHA
|
||||
#if 1
|
||||
/* on by default */
|
||||
/* 1k smaller, but 25% slower */
|
||||
//#define USE_SLOW_SHA
|
||||
#else
|
||||
#define NO_SHA
|
||||
#endif
|
||||
|
||||
/* Sha256 */
|
||||
#undef NO_SHA256
|
||||
#if 1
|
||||
/* not unrolled - ~2k smaller and ~25% slower */
|
||||
//#define USE_SLOW_SHA256
|
||||
|
||||
/* Sha224 */
|
||||
#if 0
|
||||
#define WOLFSSL_SHA224
|
||||
#endif
|
||||
#else
|
||||
#define NO_SHA256
|
||||
#endif
|
||||
|
||||
/* Sha512 */
|
||||
#undef WOLFSSL_SHA512
|
||||
#if 0
|
||||
#define WOLFSSL_SHA512
|
||||
|
||||
/* Sha384 */
|
||||
#undef WOLFSSL_SHA384
|
||||
#if 0
|
||||
#define WOLFSSL_SHA384
|
||||
#endif
|
||||
|
||||
/* over twice as small, but 50% slower */
|
||||
//#define USE_SLOW_SHA512
|
||||
#endif
|
||||
|
||||
/* Sha3 */
|
||||
#undef WOLFSSL_SHA3
|
||||
#if 0
|
||||
#define WOLFSSL_SHA3
|
||||
#endif
|
||||
|
||||
/* MD5 */
|
||||
#undef NO_MD5
|
||||
#if 0
|
||||
/* on by default */
|
||||
#else
|
||||
#define NO_MD5
|
||||
#endif
|
||||
|
||||
/* HKDF */
|
||||
#undef HAVE_HKDF
|
||||
#if 1
|
||||
#define HAVE_HKDF
|
||||
#endif
|
||||
|
||||
/* CMAC */
|
||||
#undef WOLFSSL_CMAC
|
||||
#if 1
|
||||
#define WOLFSSL_CMAC
|
||||
/* Note: requires WOLFSSL_AES_DIRECT */
|
||||
#endif
|
||||
|
||||
/* HMAC - on by default */
|
||||
#undef NO_HMAC
|
||||
#if 1
|
||||
/* on by default */
|
||||
#else
|
||||
#define NO_HMAC
|
||||
#endif
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ASN */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
#if 0
|
||||
/* Use the newer ASN template code */
|
||||
#define WOLFSSL_ASN_TEMPLATE
|
||||
//#define WOLFSSL_CUSTOM_OID
|
||||
//#define HAVE_OID_ENCODING
|
||||
//#define HAVE_OID_DECODING
|
||||
#else
|
||||
/* Use the original custom ASN code */
|
||||
#endif
|
||||
/* Optionally disable time checking for ASN */
|
||||
//#define NO_ASN_TIME
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Benchmark / Test */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Use reduced benchmark / test sizes */
|
||||
#define BENCH_EMBEDDED
|
||||
|
||||
/* Use test buffers from array (not filesystem) */
|
||||
#ifndef NO_FILESYSTEM
|
||||
#define USE_CERT_BUFFERS_256
|
||||
#define USE_CERT_BUFFERS_2048
|
||||
#endif
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Debugging */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#undef DEBUG_WOLFSSL
|
||||
#undef NO_ERROR_STRINGS
|
||||
#if 0
|
||||
#define DEBUG_WOLFSSL
|
||||
#define WOLFSSL_LOG_PRINTF
|
||||
#else
|
||||
#if 0
|
||||
#define NO_ERROR_STRINGS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Memory */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
#if 0
|
||||
/* Static memory requires fast math or SP math with no malloc */
|
||||
#define WOLFSSL_STATIC_MEMORY
|
||||
|
||||
/* Disable fallback malloc/free */
|
||||
#define WOLFSSL_NO_MALLOC
|
||||
#if 1
|
||||
#define WOLFSSL_MALLOC_CHECK /* trap malloc failure */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Enable Features */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define WOLFSSL_TLS13
|
||||
#define WOLFSSL_OLD_PRIME_CHECK /* Use faster DH prime checking */
|
||||
#define HAVE_TLS_EXTENSIONS
|
||||
#define HAVE_SUPPORTED_CURVES
|
||||
#define WOLFSSL_BASE64_ENCODE
|
||||
|
||||
//#define WOLFSSL_KEY_GEN /* For RSA Key gen only */
|
||||
//#define KEEP_PEER_CERT
|
||||
//#define HAVE_COMP_KEY
|
||||
|
||||
/* TLS Session Cache */
|
||||
#if 0
|
||||
#define SMALL_SESSION_CACHE
|
||||
#else
|
||||
#define NO_SESSION_CACHE
|
||||
#endif
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Disable Features */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
//#define NO_WOLFSSL_SERVER
|
||||
//#define NO_WOLFSSL_CLIENT
|
||||
//#define NO_CRYPT_TEST
|
||||
//#define NO_CRYPT_BENCHMARK
|
||||
//#define WOLFCRYPT_ONLY
|
||||
|
||||
/* In-lining of misc.c functions */
|
||||
/* If defined, must include wolfcrypt/src/misc.c in build */
|
||||
/* Slower, but about 1k smaller */
|
||||
//#define NO_INLINE
|
||||
|
||||
#define NO_WRITEV
|
||||
#define NO_MAIN_DRIVER
|
||||
//#define NO_DEV_RANDOM
|
||||
|
||||
#define NO_OLD_TLS
|
||||
#define NO_PSK
|
||||
|
||||
#define NO_DSA
|
||||
#define NO_RC4
|
||||
#define NO_MD4
|
||||
#define NO_PWDBASED
|
||||
//#define NO_CODING
|
||||
//#define NO_CERTS
|
||||
//#define NO_SIG_WRAPPER
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WOLFSSL_USER_SETTINGS_H */
|
||||
150
android/extern/wolfssl/IDE/AURIX/wolf_main.c
vendored
Normal file
150
android/extern/wolfssl/IDE/AURIX/wolf_main.c
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
/* wolf_main.c
|
||||
*
|
||||
* Copyright (C) 2006-2022 wolfSSL Inc.
|
||||
*
|
||||
* This file is part of wolfSSL.
|
||||
*
|
||||
* wolfSSL 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.
|
||||
*
|
||||
* wolfSSL 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
/* wolfSSL includes */
|
||||
#ifndef WOLFSSL_USER_SETTINGS
|
||||
#include <wolfssl/options.h>
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/random.h> /* for CUSTOM_RAND_TYPE */
|
||||
#include <wolfcrypt/test/test.h>
|
||||
#include <wolfcrypt/benchmark/benchmark.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Infineon Includes */
|
||||
#include "Ifx_Types.h"
|
||||
#include "IfxStm.h"
|
||||
|
||||
extern int send_UART(const char* str);
|
||||
static void my_logging_cb(const int logLevel, const char *const logMessage)
|
||||
{
|
||||
send_UART(logMessage);
|
||||
send_UART("\r\n");
|
||||
(void)logLevel; /* not used */
|
||||
}
|
||||
|
||||
/* TIME CODE */
|
||||
/* Optionally you can define NO_ASN_TIME to disable all cert time checks */
|
||||
static int hw_get_time_sec(void)
|
||||
{
|
||||
/* get time in seconds */
|
||||
return IfxStm_get(&MODULE_STM0) / IfxStm_getFrequency(&MODULE_STM0);
|
||||
}
|
||||
|
||||
/* This is used by wolfCrypt asn.c for cert time checking */
|
||||
unsigned long my_time(unsigned long* timer)
|
||||
{
|
||||
(void)timer;
|
||||
return hw_get_time_sec();
|
||||
}
|
||||
|
||||
#ifndef WOLFCRYPT_ONLY
|
||||
/* This is used by TLS only */
|
||||
unsigned int LowResTimer(void)
|
||||
{
|
||||
return hw_get_time_sec();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NO_CRYPT_BENCHMARK
|
||||
/* This is used by wolfCrypt benchmark tool only */
|
||||
double current_time(int reset)
|
||||
{
|
||||
double timeNow;
|
||||
uint64_t timeMs, ticks = IfxStm_get(&MODULE_STM0);
|
||||
(void)reset;
|
||||
timeMs = ticks / (IfxStm_getFrequency(&MODULE_STM0) / 1000);
|
||||
timeNow = (timeMs / 1000); // sec
|
||||
timeNow += (double)(timeMs % 1000) / 1000; // ms
|
||||
return timeNow;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* RNG CODE */
|
||||
/* TODO: Implement real RNG */
|
||||
static unsigned int gCounter;
|
||||
unsigned int hw_rand(void)
|
||||
{
|
||||
//#warning Must implement your own random source
|
||||
|
||||
return ++gCounter;
|
||||
}
|
||||
|
||||
unsigned int my_rng_seed_gen(void)
|
||||
{
|
||||
return hw_rand();
|
||||
}
|
||||
|
||||
typedef struct func_args {
|
||||
int argc;
|
||||
char** argv;
|
||||
int return_code;
|
||||
} func_args;
|
||||
|
||||
void run_wolf_tests(void)
|
||||
{
|
||||
func_args args;
|
||||
|
||||
#ifdef DEBUG_WOLFSSL
|
||||
wolfSSL_Debugging_ON();
|
||||
#endif
|
||||
wolfSSL_SetLoggingCb(my_logging_cb);
|
||||
|
||||
/* initialize wolfSSL */
|
||||
#ifdef WOLFCRYPT_ONLY
|
||||
wolfCrypt_Init();
|
||||
#else
|
||||
wolfSSL_Init();
|
||||
#endif
|
||||
|
||||
memset(&args, 0, sizeof(args));
|
||||
args.return_code = NOT_COMPILED_IN; /* default */
|
||||
|
||||
printf("Running wolfCrypt Tests...\n");
|
||||
#ifndef NO_CRYPT_TEST
|
||||
args.return_code = 0;
|
||||
wolfcrypt_test(&args);
|
||||
printf("Crypt Test: Return code %d\n", args.return_code);
|
||||
#else
|
||||
args.return_code = NOT_COMPILED_IN;
|
||||
#endif
|
||||
|
||||
printf("Running wolfCrypt Benchmarks...\n");
|
||||
#ifndef NO_CRYPT_BENCHMARK
|
||||
args.return_code = 0;
|
||||
benchmark_test(&args);
|
||||
#else
|
||||
args.return_code = NOT_COMPILED_IN;
|
||||
#endif
|
||||
printf("Benchmark Test: Return code %d\n", args.return_code);
|
||||
|
||||
#ifdef WOLFCRYPT_ONLY
|
||||
wolfCrypt_Cleanup();
|
||||
#else
|
||||
wolfSSL_Cleanup();
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user