From 97f08393e208f6564be807da53c36af47a9b0a2a Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 20 Mar 2020 14:40:17 -0700 Subject: [PATCH] Added wolfCrypt Xilinx SDK project. Fix for stsafe.h inclusion of ssl.h with `WOLFCRYPT_ONLY`. --- IDE/XilinxSDK/.cproject | 216 ++++++++++++++++++++ IDE/XilinxSDK/.project | 27 +++ IDE/XilinxSDK/README.md | 58 ++++++ IDE/XilinxSDK/include.am | 10 + IDE/XilinxSDK/lscript.ld | 309 +++++++++++++++++++++++++++++ IDE/XilinxSDK/user_settings.h | 117 +++++++++++ IDE/XilinxSDK/wolfssl_example.c | 119 +++++++++++ IDE/include.am | 1 + wolfssl/wolfcrypt/port/st/stsafe.h | 13 +- 9 files changed, 866 insertions(+), 4 deletions(-) create mode 100755 IDE/XilinxSDK/.cproject create mode 100755 IDE/XilinxSDK/.project create mode 100644 IDE/XilinxSDK/README.md create mode 100644 IDE/XilinxSDK/include.am create mode 100755 IDE/XilinxSDK/lscript.ld create mode 100755 IDE/XilinxSDK/user_settings.h create mode 100644 IDE/XilinxSDK/wolfssl_example.c diff --git a/IDE/XilinxSDK/.cproject b/IDE/XilinxSDK/.cproject new file mode 100755 index 000000000..32c36ab58 --- /dev/null +++ b/IDE/XilinxSDK/.cproject @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IDE/XilinxSDK/.project b/IDE/XilinxSDK/.project new file mode 100755 index 000000000..c705d984b --- /dev/null +++ b/IDE/XilinxSDK/.project @@ -0,0 +1,27 @@ + + + wolfcrypt + Created by SDK v2018.2. standalone_bsp_0 - psu_cortexa53_0 + + standalone_bsp_0 + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/IDE/XilinxSDK/README.md b/IDE/XilinxSDK/README.md new file mode 100644 index 000000000..7b131a070 --- /dev/null +++ b/IDE/XilinxSDK/README.md @@ -0,0 +1,58 @@ +# Xilinx SDK wolfCrypt Project + +To use this example project: +1. Start a new workspace +2. Create a new BSP called `standalone_bsp_0`. +3. Copy `.cproject` and `.project` into the wolfSSL root. +4. From the Xilinx SDK Import wolfBoot using "Import" -> "Existing Projects into Workspace". + +## Platform + +Tested on the Zynq UltraScale+ MPSoC (ZUC102). + +This is a bare-metal example for wolfCrypt only with algorithm support for: +* RNG +* RSA +* ECC +* AES-GCM +* ChaCha20 +* Poly1305 +* SHA2 +* SHA3 +* PBKDF2 + +## Benchmark Results + +``` +------------------------------------------------------------------------------ + wolfSSL version 4.3.0 +------------------------------------------------------------------------------ +wolfCrypt Benchmark (block bytes 1024, min sec each) +RNG 72 MB took 1.000 seconds, 72.388 MB/s +AES-128-GCM-enc 370 MB took 1.000 seconds, 370.312 MB/s +AES-128-GCM-dec 187 MB took 1.000 seconds, 187.451 MB/s +AES-192-GCM-enc 341 MB took 1.000 seconds, 341.382 MB/s +AES-192-GCM-dec 180 MB took 1.000 seconds, 179.663 MB/s +AES-256-GCM-enc 316 MB took 1.000 seconds, 316.382 MB/s +AES-256-GCM-dec 172 MB took 1.000 seconds, 172.485 MB/s +CHACHA 256 MB took 1.000 seconds, 255.859 MB/s +CHA-POLY 98 MB took 1.000 seconds, 97.559 MB/s +POLY1305 517 MB took 1.000 seconds, 516.895 MB/s +SHA-256 535 MB took 1.000 seconds, 534.595 MB/s +SHA-384 123 MB took 1.000 seconds, 123.291 MB/s +SHA-512 124 MB took 1.000 seconds, 123.657 MB/s +SHA3-224 70 MB took 1.000 seconds, 70.337 MB/s +SHA3-256 67 MB took 1.000 seconds, 66.528 MB/s +SHA3-384 53 MB took 1.000 seconds, 52.710 MB/s +SHA3-512 38 MB took 1.000 seconds, 37.598 MB/s +HMAC-SHA256 520 MB took 1.000 seconds, 520.093 MB/s +HMAC-SHA384 121 MB took 1.000 seconds, 121.265 MB/s +HMAC-SHA512 121 MB took 1.000 seconds, 121.289 MB/s +PBKDF2 28 KB took 1.000 seconds, 28.375 KB/s +ECC 256 key gen 8518 ops took 1.000 sec, avg 0.117 ms, 8518.000 ops/sec +ECDHE 256 agree 1818 ops took 1.000 sec, avg 0.550 ms, 1818.000 ops/sec +ECDSA 256 sign 4448 ops took 1.000 sec, avg 0.225 ms, 4448.000 ops/sec +ECDSA 256 verify 1430 ops took 1.000 sec, avg 0.699 ms, 1430.000 ops/sec +Benchmark complete +Benchmark Test: Return code 0 +``` diff --git a/IDE/XilinxSDK/include.am b/IDE/XilinxSDK/include.am new file mode 100644 index 000000000..26b136e86 --- /dev/null +++ b/IDE/XilinxSDK/include.am @@ -0,0 +1,10 @@ +# vim:ft=automake +# included from Top Level Makefile.am +# All paths should be given relative to the root + +EXTRA_DIST+= IDE/XilinxSDK/README.md +EXTRA_DIST+= IDE/XilinxSDK/user_settings.h +EXTRA_DIST+= IDE/XilinxSDK/wolfssl_example.c +EXTRA_DIST+= IDE/XilinxSDK/lscript.ld +EXTRA_DIST+= IDE/XilinxSDK/.cproject +EXTRA_DIST+= IDE/XilinxSDK/.project diff --git a/IDE/XilinxSDK/lscript.ld b/IDE/XilinxSDK/lscript.ld new file mode 100755 index 000000000..b881c337a --- /dev/null +++ b/IDE/XilinxSDK/lscript.ld @@ -0,0 +1,309 @@ + +/* Linker Script for Zynq MP */ + +/* Stack and Heap increased to 64KB */ +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x10000; +_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x10000; + +_EL0_STACK_SIZE = DEFINED(_EL0_STACK_SIZE) ? _EL0_STACK_SIZE : 1024; +_EL1_STACK_SIZE = DEFINED(_EL1_STACK_SIZE) ? _EL1_STACK_SIZE : 2048; +_EL2_STACK_SIZE = DEFINED(_EL2_STACK_SIZE) ? _EL2_STACK_SIZE : 1024; + +/* Define Memories in the system */ +MEMORY +{ + ddr4_ctrl_C0_DDR4_ADDRESS_BLOCK : ORIGIN = 0x500000000, LENGTH = 0x20000000 + psu_ddr_0_MEM_0 : ORIGIN = 0x0, LENGTH = 0x7FF00000 + psu_ddr_1_MEM_0 : ORIGIN = 0x800000000, LENGTH = 0x80000000 + psu_ocm_ram_0_MEM_0 : ORIGIN = 0xFFFC0000, LENGTH = 0x40000 + psu_qspi_linear_0_MEM_0 : ORIGIN = 0xC0000000, LENGTH = 0x20000000 +} + +/* Specify the default entry point to the program */ +ENTRY(_vector_table) + +/* Define the sections, and where they are mapped in memory */ +SECTIONS +{ +.text : { + KEEP (*(.vectors)) + *(.boot) + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + *(.plt) + *(.gnu_warning) + *(.gcc_execpt_table) + *(.glue_7) + *(.glue_7t) + *(.ARM.extab) + *(.gnu.linkonce.armextab.*) +} > psu_ddr_0_MEM_0 + +.init (ALIGN(64)) : { + KEEP (*(.init)) +} > psu_ddr_0_MEM_0 + +.fini (ALIGN(64)) : { + KEEP (*(.fini)) +} > psu_ddr_0_MEM_0 + +.interp : { + KEEP (*(.interp)) +} > psu_ddr_0_MEM_0 + +.note-ABI-tag : { + KEEP (*(.note-ABI-tag)) +} > psu_ddr_0_MEM_0 + +.rodata : { + . = ALIGN(64); + __rodata_start = .; + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + __rodata_end = .; +} > psu_ddr_0_MEM_0 + +.rodata1 : { + . = ALIGN(64); + __rodata1_start = .; + *(.rodata1) + *(.rodata1.*) + __rodata1_end = .; +} > psu_ddr_0_MEM_0 + +.sdata2 : { + . = ALIGN(64); + __sdata2_start = .; + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + __sdata2_end = .; +} > psu_ddr_0_MEM_0 + +.sbss2 : { + . = ALIGN(64); + __sbss2_start = .; + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + __sbss2_end = .; +} > psu_ddr_0_MEM_0 + +.data : { + . = ALIGN(64); + __data_start = .; + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + *(.jcr) + *(.got) + *(.got.plt) + __data_end = .; +} > psu_ddr_0_MEM_0 + +.data1 : { + . = ALIGN(64); + __data1_start = .; + *(.data1) + *(.data1.*) + __data1_end = .; +} > psu_ddr_0_MEM_0 + +.got : { + *(.got) +} > psu_ddr_0_MEM_0 + +.got1 : { + *(.got1) +} > psu_ddr_0_MEM_0 + +.got2 : { + *(.got2) +} > psu_ddr_0_MEM_0 + +.ctors : { + . = ALIGN(64); + __CTOR_LIST__ = .; + ___CTORS_LIST___ = .; + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __CTOR_END__ = .; + ___CTORS_END___ = .; +} > psu_ddr_0_MEM_0 + +.dtors : { + . = ALIGN(64); + __DTOR_LIST__ = .; + ___DTORS_LIST___ = .; + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __DTOR_END__ = .; + ___DTORS_END___ = .; +} > psu_ddr_0_MEM_0 + +.fixup : { + __fixup_start = .; + *(.fixup) + __fixup_end = .; +} > psu_ddr_0_MEM_0 + +.eh_frame : { + *(.eh_frame) +} > psu_ddr_0_MEM_0 + +.eh_framehdr : { + __eh_framehdr_start = .; + *(.eh_framehdr) + __eh_framehdr_end = .; +} > psu_ddr_0_MEM_0 + +.gcc_except_table : { + *(.gcc_except_table) +} > psu_ddr_0_MEM_0 + +.mmu_tbl0 (ALIGN(4096)) : { + __mmu_tbl0_start = .; + *(.mmu_tbl0) + __mmu_tbl0_end = .; +} > psu_ddr_0_MEM_0 + +.mmu_tbl1 (ALIGN(4096)) : { + __mmu_tbl1_start = .; + *(.mmu_tbl1) + __mmu_tbl1_end = .; +} > psu_ddr_0_MEM_0 + +.mmu_tbl2 (ALIGN(4096)) : { + __mmu_tbl2_start = .; + *(.mmu_tbl2) + __mmu_tbl2_end = .; +} > psu_ddr_0_MEM_0 + +.ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx*) + *(.gnu.linkonce.armexidix.*.*) + __exidx_end = .; +} > psu_ddr_0_MEM_0 + +.preinit_array : { + . = ALIGN(64); + __preinit_array_start = .; + KEEP (*(SORT(.preinit_array.*))) + KEEP (*(.preinit_array)) + __preinit_array_end = .; +} > psu_ddr_0_MEM_0 + +.init_array : { + . = ALIGN(64); + __init_array_start = .; + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + __init_array_end = .; +} > psu_ddr_0_MEM_0 + +.fini_array : { + . = ALIGN(64); + __fini_array_start = .; + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + __fini_array_end = .; +} > psu_ddr_0_MEM_0 + +.ARM.attributes : { + __ARM.attributes_start = .; + *(.ARM.attributes) + __ARM.attributes_end = .; +} > psu_ddr_0_MEM_0 + +.sdata : { + . = ALIGN(64); + __sdata_start = .; + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + __sdata_end = .; +} > psu_ddr_0_MEM_0 + +.sbss (NOLOAD) : { + . = ALIGN(64); + __sbss_start = .; + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + . = ALIGN(64); + __sbss_end = .; +} > psu_ddr_0_MEM_0 + +.tdata : { + . = ALIGN(64); + __tdata_start = .; + *(.tdata) + *(.tdata.*) + *(.gnu.linkonce.td.*) + __tdata_end = .; +} > psu_ddr_0_MEM_0 + +.tbss : { + . = ALIGN(64); + __tbss_start = .; + *(.tbss) + *(.tbss.*) + *(.gnu.linkonce.tb.*) + __tbss_end = .; +} > psu_ddr_0_MEM_0 + +.bss (NOLOAD) : { + . = ALIGN(64); + __bss_start__ = .; + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(64); + __bss_end__ = .; +} > psu_ddr_0_MEM_0 + +_SDA_BASE_ = __sdata_start + ((__sbss_end - __sdata_start) / 2 ); + +_SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 ); + +/* Generate Stack and Heap definitions */ + +.heap (NOLOAD) : { + . = ALIGN(64); + _heap = .; + HeapBase = .; + _heap_start = .; + . += _HEAP_SIZE; + _heap_end = .; + HeapLimit = .; +} > psu_ddr_0_MEM_0 + +.stack (NOLOAD) : { + . = ALIGN(64); + _el3_stack_end = .; + . += _STACK_SIZE; + __el3_stack = .; + _el2_stack_end = .; + . += _EL2_STACK_SIZE; + . = ALIGN(64); + __el2_stack = .; + _el1_stack_end = .; + . += _EL1_STACK_SIZE; + . = ALIGN(64); + __el1_stack = .; + _el0_stack_end = .; + . += _EL0_STACK_SIZE; + . = ALIGN(64); + __el0_stack = .; +} > psu_ddr_0_MEM_0 + +_end = .; +} diff --git a/IDE/XilinxSDK/user_settings.h b/IDE/XilinxSDK/user_settings.h new file mode 100755 index 000000000..f2604982d --- /dev/null +++ b/IDE/XilinxSDK/user_settings.h @@ -0,0 +1,117 @@ +/* user_settings.h + * + * Copyright (C) 2006-2020 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 + */ + +/* + * user_settings.h + * + * Created on: Mar 20, 2020 + * Generated using: + * ./configure --enable-cryptonly --enable-armasm --enable-ecc --enable-aesgcm --enable-pwdbased --enable-sp --enable-sp-asm \ + * --disable-dh --disable-sha --disable-md5 --disable-sha224 --disable-aescbc --disable-shake256 + * Result: wolfssl/options.h + */ + +#ifndef SRC_USER_SETTINGS_H_ +#define SRC_USER_SETTINGS_H_ + +/* Disable all TLS support, only wolfCrypt features */ +#define WOLFCRYPT_ONLY + +/* Xilinx SDK */ +#define WOLFSSL_XILINX +#define SINGLE_THREADED +#define NO_FILESYSTEM + +/* Platform - remap printf */ +#include "xil_printf.h" +#define XPRINTF xil_printf + +/* Enable ARMv8 (Aarch64) assembly speedups - SHA256 / AESGCM */ +/* Note: Requires CFLAGS="-mcpu=generic+crypto -mstrict-align" */ +#define WOLFSSL_ARMASM + +/* Math */ +#define USE_FAST_MATH +#define FP_MAX_BITS (4096 * 2) /* Max RSA 4096-bit */ + +/* Use Single Precision assembly math speedups for ECC */ +#define WOLFSSL_SP +#define WOLFSSL_SP_ASM +#define WOLFSSL_SP_ARM64_ASM +#define WOLFSSL_HAVE_SP_ECC +#define WOLFSSL_HAVE_SP_RSA + +/* Random: HashDRGB / P-RNG (SHA256) */ +#define HAVE_HASHDRBG +extern unsigned char my_rng_seed_gen(void); +#define CUSTOM_RAND_GENERATE my_rng_seed_gen + +/* Timing Resistance */ +#define TFM_TIMING_RESISTANT +#define ECC_TIMING_RESISTANT +#define WC_RSA_BLINDING + +/* ECC */ +#define HAVE_ECC +#define TFM_ECC256 +#define ECC_SHAMIR + +/* AES-GCM Only */ +#define NO_AES_CBC +#define HAVE_AESGCM + +/* Hashing */ +#define WOLFSSL_SHA512 +#define WOLFSSL_SHA384 +#define WOLFSSL_SHA3 +#define WOLFSSL_NO_HASH_RAW /* not supported with ARMASM */ + +/* ChaCha20 / Poly1305 */ +#define HAVE_CHACHA +#define HAVE_POLY1305 + +/* Disable Algorithms */ +#define NO_DH +#define NO_DSA +#define NO_RC4 +#define NO_MD4 +#define NO_MD5 +#define NO_SHA +#define NO_HC128 +#define NO_RABBIT +#define NO_PSK +#define NO_DES3 + +/* Other */ +#define WOLFSSL_IGNORE_FILE_WARN /* Ignore file include warnings */ +#define NO_MAIN_DRIVER /* User supplied "main" entry point */ +#define BENCH_EMBEDDED /* Use smaller buffers for benchmarking */ + +/* Test with "wolfssl/certs_test.h" buffers - no file system */ +#define USE_CERT_BUFFERS_256 +#define USE_CERT_BUFFERS_2048 + +/* Debugging */ +#if 0 + #define DEBUG_WOLFSSL +#endif + +#endif /* SRC_USER_SETTINGS_H_ */ diff --git a/IDE/XilinxSDK/wolfssl_example.c b/IDE/XilinxSDK/wolfssl_example.c new file mode 100644 index 000000000..c67a12f69 --- /dev/null +++ b/IDE/XilinxSDK/wolfssl_example.c @@ -0,0 +1,119 @@ +/* wolfssl_example.c + * + * Copyright (C) 2006-2020 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 + */ + +#include "xil_printf.h" +#include "xrtcpsu.h" + +#include "wolfssl/wolfcrypt/settings.h" +#include "wolfssl/wolfcrypt/wc_port.h" +#include "wolfssl/wolfcrypt/error-crypt.h" +#include "wolfssl/wolfcrypt/logging.h" +#include "wolfcrypt/test/test.h" +#include "wolfcrypt/benchmark/benchmark.h" + +/***************************************************************************** + * Configuration + ****************************************************************************/ + +/***************************************************************************** + * Private types/enumerations/variables + ****************************************************************************/ + +/***************************************************************************** + * Public types/enumerations/variables + ****************************************************************************/ +typedef struct func_args { + int argc; + char** argv; + int return_code; +} func_args; + +const char menu1[] = "\n" + "\tt. WolfCrypt Test\n" + "\tb. WolfCrypt Benchmark\n"; + +/***************************************************************************** + * Private functions + ****************************************************************************/ +/* Test RNG Seed Function */ +/* TODO: Must provide real seed to RNG */ +unsigned char my_rng_seed_gen(void) +{ + static unsigned int kTestSeed = 1; + return kTestSeed++; +} + +/***************************************************************************** + * Public functions + ****************************************************************************/ +int main() +{ + uint8_t cmd; + func_args args; + +#ifdef DEBUG_WOLFSSL + wolfSSL_Debugging_ON(); +#endif + + /* initialize wolfSSL */ + wolfCrypt_Init(); + + while (1) { + memset(&args, 0, sizeof(args)); + args.return_code = NOT_COMPILED_IN; /* default */ + + xil_printf("\n\t\t\t\tMENU\n"); + xil_printf(menu1); + xil_printf("Please select one of the above options:\n"); + + do { + cmd = inbyte(); + } while (cmd == '\n' || cmd == '\r'); + + switch (cmd) { + case 't': + xil_printf("Running wolfCrypt Tests...\n"); + #ifndef NO_CRYPT_TEST + args.return_code = 0; + wolfcrypt_test(&args); + #endif + xil_printf("Crypt Test: Return code %d\n", args.return_code); + break; + + case 'b': + xil_printf("Running wolfCrypt Benchmarks...\n"); + #ifndef NO_CRYPT_BENCHMARK + args.return_code = 0; + benchmark_test(&args); + #endif + xil_printf("Benchmark Test: Return code %d\n", args.return_code); + break; + + default: + xil_printf("\nSelection out of range\n"); + break; + } + } + + wolfCrypt_Cleanup(); + + return 0; +} diff --git a/IDE/include.am b/IDE/include.am index 3c94aed4d..828b173ad 100644 --- a/IDE/include.am +++ b/IDE/include.am @@ -30,5 +30,6 @@ include IDE/CRYPTOCELL/include.am include IDE/M68K/include.am include IDE/HEXAGON/include.am include IDE/RISCV/include.am +include IDE/XilinxSDK/include.am EXTRA_DIST+= IDE/IAR-EWARM IDE/MDK-ARM IDE/MDK5-ARM IDE/MYSQL IDE/LPCXPRESSO IDE/HEXIWEAR IDE/Espressif IDE/zephyr diff --git a/wolfssl/wolfcrypt/port/st/stsafe.h b/wolfssl/wolfcrypt/port/st/stsafe.h index ae7cde9ae..3cee4461d 100644 --- a/wolfssl/wolfcrypt/port/st/stsafe.h +++ b/wolfssl/wolfcrypt/port/st/stsafe.h @@ -23,10 +23,17 @@ #define _WOLFPORT_STSAFE_H_ #include -#include #include #include +#ifdef WOLF_CRYPTO_CB +#include +#endif + +#if !defined(WOLFCRYPT_ONLY) && defined(HAVE_PK_CALLBACKS) +#include +#endif + #ifdef WOLFSSL_STSAFEA100 /* The wolf STSAFE interface layer */ @@ -46,7 +53,7 @@ WOLFSSL_API int SSL_STSAFE_LoadDeviceCertificate(byte** pRawCertificate, word32* pRawCertificateLen); -#ifdef HAVE_PK_CALLBACKS +#if !defined(WOLFCRYPT_ONLY) && defined(HAVE_PK_CALLBACKS) WOLFSSL_API int SSL_STSAFE_CreateKeyCb(WOLFSSL* ssl, ecc_key* key, word32 keySz, int ecc_curve, void* ctx); WOLFSSL_API int SSL_STSAFE_VerifyPeerCertCb(WOLFSSL* ssl, @@ -72,8 +79,6 @@ WOLFSSL_API int SSL_STSAFE_SetupPkCallbackCtx(WOLFSSL* ssl, void* user_ctx); #ifdef WOLF_CRYPTO_CB -#include - /* Device ID that's unique and valid (not INVALID_DEVID -2) */ #define WOLF_STSAFE_DEVID 0x53545341; /* STSA */