[修改] 增加freeRTOS
1. 版本FreeRTOSv202212.01,命名为kernel;
This commit is contained in:
210
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/GCC-ARM/Source/armtarget.c
vendored
Normal file
210
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/GCC-ARM/Source/armtarget.c
vendored
Normal file
@ -0,0 +1,210 @@
|
||||
/* armtarget.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 <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/ssl.h>
|
||||
#include <wolfssl/wolfcrypt/random.h> /* for CUSTOM_RAND_TYPE */
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#ifdef USE_WOLF_ARM_STARTUP
|
||||
|
||||
/* Memory initialization */
|
||||
extern uint32_t __data_load_start__[];
|
||||
extern uint32_t __data_start__[];
|
||||
extern uint32_t __data_end__[];
|
||||
|
||||
extern uint32_t __bss_start__[];
|
||||
extern uint32_t __bss_end__[];
|
||||
|
||||
extern uint32_t __stack_process_end__[];
|
||||
|
||||
extern uint32_t __heap_start__[];
|
||||
extern uint32_t __heap_end__[];
|
||||
|
||||
/* Copy memory: src=Source, dst_beg=Destination Begin, dst_end=Destination End */
|
||||
void memcpy32(uint32_t* src, uint32_t* dst_beg, uint32_t* dst_end)
|
||||
{
|
||||
while (dst_beg < dst_end) {
|
||||
*dst_beg++ = *src++;
|
||||
}
|
||||
}
|
||||
/* Zero address in range */
|
||||
void meminit32(uint32_t* start, uint32_t* end)
|
||||
{
|
||||
while (start < end) {
|
||||
*start++ = 0;
|
||||
}
|
||||
}
|
||||
#endif /* USE_WOLF_ARM_STARTUP */
|
||||
|
||||
/* Entry Point */
|
||||
void reset_handler(void)
|
||||
{
|
||||
#ifdef USE_WOLF_ARM_STARTUP
|
||||
/* Init sections */
|
||||
memcpy32(__data_load_start__, __data_start__, __data_end__);
|
||||
meminit32(__bss_start__, __bss_end__);
|
||||
|
||||
/* Init heap */
|
||||
__heap_start__[0] = 0;
|
||||
__heap_start__[1] = ((uint32_t)__heap_end__ - (uint32_t)__heap_start__);
|
||||
#endif /* USE_WOLF_ARM_STARTUP */
|
||||
|
||||
/* Start main */
|
||||
extern int main(void);
|
||||
main();
|
||||
|
||||
/* Application has ended, so busy wait */
|
||||
while(1);
|
||||
}
|
||||
|
||||
#ifdef USE_WOLF_ARM_STARTUP
|
||||
// Vector Exception/Interrupt Handlers
|
||||
static void Default_Handler(void)
|
||||
{
|
||||
/* If we get here then need to implement real IRQ handler */
|
||||
while(1);
|
||||
}
|
||||
|
||||
__attribute__((section(".sys"))) __attribute__ ((used))
|
||||
void HardFault_HandlerC( uint32_t *hardfault_args )
|
||||
{
|
||||
/* These are volatile to try and prevent the compiler/linker optimizing them
|
||||
away as the variables never actually get used. If the debugger won't show the
|
||||
values of the variables, make them global my moving their declaration outside
|
||||
of this function. */
|
||||
volatile uint32_t stacked_r0;
|
||||
volatile uint32_t stacked_r1;
|
||||
volatile uint32_t stacked_r2;
|
||||
volatile uint32_t stacked_r3;
|
||||
volatile uint32_t stacked_r12;
|
||||
volatile uint32_t stacked_lr;
|
||||
volatile uint32_t stacked_pc;
|
||||
volatile uint32_t stacked_psr;
|
||||
volatile uint32_t _CFSR;
|
||||
volatile uint32_t _HFSR;
|
||||
volatile uint32_t _DFSR;
|
||||
volatile uint32_t _AFSR;
|
||||
volatile uint32_t _BFAR;
|
||||
volatile uint32_t _MMAR;
|
||||
|
||||
stacked_r0 = ((uint32_t)hardfault_args[0]);
|
||||
stacked_r1 = ((uint32_t)hardfault_args[1]);
|
||||
stacked_r2 = ((uint32_t)hardfault_args[2]);
|
||||
stacked_r3 = ((uint32_t)hardfault_args[3]);
|
||||
stacked_r12 = ((uint32_t)hardfault_args[4]);
|
||||
stacked_lr = ((uint32_t)hardfault_args[5]);
|
||||
stacked_pc = ((uint32_t)hardfault_args[6]);
|
||||
stacked_psr = ((uint32_t)hardfault_args[7]);
|
||||
|
||||
// Configurable Fault Status Register
|
||||
// Consists of MMSR, BFSR and UFSR
|
||||
_CFSR = (*((volatile uint32_t *)(0xE000ED28)));
|
||||
|
||||
// Hard Fault Status Register
|
||||
_HFSR = (*((volatile uint32_t *)(0xE000ED2C)));
|
||||
|
||||
// Debug Fault Status Register
|
||||
_DFSR = (*((volatile uint32_t *)(0xE000ED30)));
|
||||
|
||||
// Auxiliary Fault Status Register
|
||||
_AFSR = (*((volatile uint32_t *)(0xE000ED3C)));
|
||||
|
||||
// Read the Fault Address Registers. These may not contain valid values.
|
||||
// Check BFARVALID/MMARVALID to see if they are valid values
|
||||
// MemManage Fault Address Register
|
||||
_MMAR = (*((volatile uint32_t *)(0xE000ED34)));
|
||||
// Bus Fault Address Register
|
||||
_BFAR = (*((volatile uint32_t *)(0xE000ED38)));
|
||||
|
||||
printf ("\n\nHard fault handler (all numbers in hex):\n");
|
||||
printf ("R0 = %ux\n", stacked_r0);
|
||||
printf ("R1 = %ux\n", stacked_r1);
|
||||
printf ("R2 = %ux\n", stacked_r2);
|
||||
printf ("R3 = %ux\n", stacked_r3);
|
||||
printf ("R12 = %ux\n", stacked_r12);
|
||||
printf ("LR [R14] = %ux subroutine call return address\n", stacked_lr);
|
||||
printf ("PC [R15] = %ux program counter\n", stacked_pc);
|
||||
printf ("PSR = %ux\n", stacked_psr);
|
||||
printf ("CFSR = %ux\n", _CFSR);
|
||||
printf ("HFSR = %ux\n", _HFSR);
|
||||
printf ("DFSR = %ux\n", _DFSR);
|
||||
printf ("AFSR = %ux\n", _AFSR);
|
||||
printf ("MMAR = %ux\n", _MMAR);
|
||||
printf ("BFAR = %ux\n", _BFAR);
|
||||
|
||||
// Break into the debugger
|
||||
__asm("BKPT #0\n");
|
||||
}
|
||||
|
||||
__attribute__((section(".sys"))) __attribute__( ( naked ) )
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
__asm volatile
|
||||
(
|
||||
" movs r0,#4 \n" /* load bit mask into R0 */
|
||||
" mov r1, lr \n" /* load link register into R1 */
|
||||
" tst r0, r1 \n" /* compare with bitmask */
|
||||
" beq _MSP \n" /* if bitmask is set: stack pointer is in PSP. Otherwise in MSP */
|
||||
" mrs r0, psp \n" /* otherwise: stack pointer is in PSP */
|
||||
" b _GetPC \n" /* go to part which loads the PC */
|
||||
"_MSP: \n" /* stack pointer is in MSP register */
|
||||
" mrs r0, msp \n" /* load stack pointer into R0 */
|
||||
"_GetPC: \n" /* find out where the hard fault happened */
|
||||
" ldr r1,[r0,#20] \n" /* load program counter into R1. R1 contains address of the next instruction where the hard fault happened */
|
||||
" ldr r2, =HardFault_HandlerC \n"
|
||||
" bx r2 \n"
|
||||
" bx lr \n" /* decode more information. R0 contains pointer to stack frame */
|
||||
);
|
||||
}
|
||||
|
||||
/* Vectors Table */
|
||||
typedef void (*vector_entry)(void);
|
||||
const vector_entry vectors[] __attribute__ ((section(".vectors"),used)) =
|
||||
{
|
||||
/* Interrupt Vector Table Function Pointers */
|
||||
// Address Vector IRQ Source module Source description
|
||||
(vector_entry)__stack_process_end__, // ARM core Initial Supervisor SP
|
||||
reset_handler, // 0x0000_0004 1 - ARM core Initial Program Counter
|
||||
Default_Handler, // 0x0000_0008 2 - ARM core Non-maskable Interrupt (NMI)
|
||||
HardFault_Handler, // 0x0000_000C 3 - ARM core Hard Fault
|
||||
Default_Handler, // 0x0000_0010 4 -
|
||||
HardFault_Handler, // 0x0000_0014 5 - ARM core Bus Fault
|
||||
HardFault_Handler, // 0x0000_0018 6 - ARM core Usage Fault
|
||||
Default_Handler, // 0x0000_001C 7 -
|
||||
Default_Handler, // 0x0000_0020 8 -
|
||||
Default_Handler, // 0x0000_0024 9 -
|
||||
Default_Handler, // 0x0000_0028 10 -
|
||||
Default_Handler, // 0x0000_002C 11 - ARM core Supervisor call (SVCall)
|
||||
Default_Handler, // 0x0000_0030 12 - ARM core Debug Monitor
|
||||
Default_Handler, // 0x0000_0034 13 -
|
||||
Default_Handler, // 0x0000_0038 14 - ARM core Pendable request for system service (PendableSrvReq)
|
||||
Default_Handler, // 0x0000_003C 15 - ARM core System tick timer (SysTick)
|
||||
|
||||
/* remainder go below */
|
||||
};
|
||||
#endif /* USE_WOLF_ARM_STARTUP */
|
||||
54
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/GCC-ARM/Source/benchmark_main.c
vendored
Normal file
54
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/GCC-ARM/Source/benchmark_main.c
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
/* benchmark_main.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 <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
#include <wolfcrypt/benchmark/benchmark.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef NO_CRYPT_BENCHMARK
|
||||
typedef struct func_args {
|
||||
int argc;
|
||||
char** argv;
|
||||
int return_code;
|
||||
} func_args;
|
||||
|
||||
static func_args args = { 0 } ;
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int ret;
|
||||
#ifndef NO_CRYPT_BENCHMARK
|
||||
wolfCrypt_Init();
|
||||
|
||||
printf("\nBenchmark Test\n");
|
||||
benchmark_test(&args);
|
||||
ret = args.return_code;
|
||||
printf("Benchmark Test: Return code %d\n", ret);
|
||||
|
||||
wolfCrypt_Cleanup();
|
||||
#else
|
||||
ret = NOT_COMPILED_IN;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
55
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/GCC-ARM/Source/test_main.c
vendored
Normal file
55
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/GCC-ARM/Source/test_main.c
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/* test_main.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 <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfcrypt/test/test.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef NO_CRYPT_TEST
|
||||
typedef struct func_args {
|
||||
int argc;
|
||||
char** argv;
|
||||
int return_code;
|
||||
} func_args;
|
||||
|
||||
static func_args args = { 0 } ;
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int ret;
|
||||
#ifndef NO_CRYPT_TEST
|
||||
wolfCrypt_Init();
|
||||
|
||||
printf("\nCrypt Test\n");
|
||||
wolfcrypt_test(&args);
|
||||
ret = args.return_code;
|
||||
printf("Crypt Test: Return code %d\n", ret);
|
||||
|
||||
wolfCrypt_Cleanup();
|
||||
#else
|
||||
ret = NOT_COMPILED_IN;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
207
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/GCC-ARM/Source/tls_client.c
vendored
Normal file
207
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/GCC-ARM/Source/tls_client.c
vendored
Normal file
@ -0,0 +1,207 @@
|
||||
/* tls_client.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 <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
|
||||
#ifndef WOLFCRYPT_ONLY
|
||||
|
||||
#include <wolfssl/ssl.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAXSZ 1024
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* TLS CLIENT */
|
||||
/*------------------------------------------------------------------------*/
|
||||
static int CbIORecv(WOLFSSL *ssl, char *buf, int sz, void *ctx)
|
||||
{
|
||||
int ret = WOLFSSL_CBIO_ERR_GENERAL;
|
||||
|
||||
(void)ssl;
|
||||
(void)ctx;
|
||||
|
||||
/* TODO: Exchange data over your own transport */
|
||||
#warning TODO: Implement your own recv data transport
|
||||
#if 0
|
||||
ret = usart_read_buffer_wait(&cdc_uart_module, buf, sz);
|
||||
if (ret == STATUS_ERR_TIMEOUT)
|
||||
return WOLFSSL_CBIO_ERR_WANT_READ;
|
||||
|
||||
return (ret == STATUS_OK) ? sz : WOLFSSL_CBIO_ERR_GENERAL;
|
||||
#else
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int CbIOSend(WOLFSSL *ssl, char *buf, int sz, void *ctx)
|
||||
{
|
||||
int ret = WOLFSSL_CBIO_ERR_GENERAL;
|
||||
|
||||
(void)ssl;
|
||||
(void)ctx;
|
||||
|
||||
/* TODO: Exchange data over your own transport */
|
||||
#warning TODO: Implement your own send data transport
|
||||
#if 0
|
||||
ret = usart_write_buffer_wait(&cdc_uart_module, buf, sz);
|
||||
if (ret == STATUS_ERR_TIMEOUT)
|
||||
return WOLFSSL_CBIO_ERR_WANT_WRITE;
|
||||
|
||||
return (ret == STATUS_OK) ? sz : WOLFSSL_CBIO_ERR_GENERAL;
|
||||
#else
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int tls_client(void)
|
||||
{
|
||||
char msg[] = "Hello WolfSSL!\r\n";
|
||||
char reply[MAXSZ];
|
||||
int ret, msgSz, error;
|
||||
WOLFSSL* ssl = NULL;
|
||||
WOLFSSL_CTX* ctx = NULL;
|
||||
|
||||
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {
|
||||
printf("CTXnew failed.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* ECDHE-ECDSA */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/*--------------------*/
|
||||
/* for peer auth use: */
|
||||
/*--------------------*/
|
||||
// wolfSSL_CTX_load_verify_buffer(ctx, rsa_key_der_1024,
|
||||
// sizeof_rsa_key_der_1024, SSL_FILETYPE_ASN1);
|
||||
// wolfSSL_CTX_load_verify_buffer(ctx, server_cert_der_1024,
|
||||
// sizeof_server_cert_der_1024, SSL_FILETYPE_ASN1);
|
||||
/*---------------------*/
|
||||
/* for no peer auth: */
|
||||
/*---------------------*/
|
||||
wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
|
||||
/*---------------------*/
|
||||
/* end peer auth option*/
|
||||
/*---------------------*/
|
||||
if ((ret = wolfSSL_CTX_set_cipher_list(ctx, "ECDHE-ECDSA-AES128-SHA256")) != SSL_SUCCESS) {
|
||||
wolfSSL_CTX_free(ctx);
|
||||
printf("CTXset_cipher_list failed, error: %d\n", ret);
|
||||
goto fail;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* END CIPHER SUITE OPTIONS */
|
||||
/*------------------------------------------------------------------------*/
|
||||
wolfSSL_CTX_SetIORecv(ctx, CbIORecv);
|
||||
wolfSSL_CTX_SetIOSend(ctx, CbIOSend);
|
||||
|
||||
if ((ssl = wolfSSL_new(ctx)) == NULL) {
|
||||
error = wolfSSL_get_error(ssl, 0);
|
||||
printf("wolfSSL_new failed %d\n", error);
|
||||
wolfSSL_CTX_free(ctx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* non blocking accept and connect */
|
||||
ret = SSL_FAILURE;
|
||||
|
||||
while (ret != SSL_SUCCESS) {
|
||||
/* client connect */
|
||||
ret = wolfSSL_connect(ssl);
|
||||
error = wolfSSL_get_error(ssl, 0);
|
||||
if (ret != SSL_SUCCESS) {
|
||||
if (error != SSL_ERROR_WANT_READ && error != SSL_ERROR_WANT_WRITE) {
|
||||
/* Fail */
|
||||
printf("wolfSSL connect failed with return code %d\n", error);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
/* Success */
|
||||
}
|
||||
|
||||
/* read and write */
|
||||
while (1) {
|
||||
/* client send/read */
|
||||
msgSz = sizeof(msg);
|
||||
ret = wolfSSL_write(ssl, msg, msgSz);
|
||||
error = wolfSSL_get_error(ssl, 0);
|
||||
if (ret != msgSz) {
|
||||
if (error != SSL_ERROR_WANT_READ && error != SSL_ERROR_WANT_WRITE) {
|
||||
/* Write failed */
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
/* Write succeeded */
|
||||
break;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
ret = wolfSSL_read(ssl, reply, sizeof(reply) - 1);
|
||||
error = wolfSSL_get_error(ssl, 0);
|
||||
if (ret < 0) {
|
||||
if (error != SSL_ERROR_WANT_READ && error != SSL_ERROR_WANT_WRITE) {
|
||||
/* Can put print here, the server enters a loop waiting to read
|
||||
* a confirmation message at this point */
|
||||
// printf("client read failed\n");
|
||||
goto fail;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
/* Can put print here, the server enters a loop waiting to read
|
||||
* a confirmation message at this point */
|
||||
reply[ret] = '\0';
|
||||
// printf("Client Received Reply: %s\n", reply);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
wolfSSL_shutdown(ssl);
|
||||
wolfSSL_free(ssl);
|
||||
wolfSSL_CTX_free(ctx);
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifndef WOLFCRYPT_ONLY
|
||||
wolfSSL_Init();
|
||||
|
||||
ret = tls_client();
|
||||
|
||||
wolfSSL_Cleanup();
|
||||
#else
|
||||
ret = NOT_COMPILED_IN;
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
142
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/GCC-ARM/Source/wolf_main.c
vendored
Normal file
142
kernel/FreeRTOS-Plus/ThirdParty/wolfSSL/IDE/GCC-ARM/Source/wolf_main.c
vendored
Normal file
@ -0,0 +1,142 @@
|
||||
/* wolf_main.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 <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/random.h> /* for CUSTOM_RAND_TYPE */
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* TIME CODE */
|
||||
/* TODO: Implement real RTC */
|
||||
/* Optionally you can define NO_ASN_TIME to disable all cert time checks */
|
||||
static int gTimeMs;
|
||||
static int hw_get_time_sec(void)
|
||||
{
|
||||
#warning Must implement your own time source if validating certificates
|
||||
|
||||
return ++gTimeMs;
|
||||
}
|
||||
|
||||
/* 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 time;
|
||||
int timeMs = gTimeMs;
|
||||
(void)reset;
|
||||
time = (timeMs / 1000); // sec
|
||||
time += (double)(timeMs % 1000) / 1000; // ms
|
||||
return time;
|
||||
}
|
||||
#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();
|
||||
}
|
||||
|
||||
int my_rng_gen_block(unsigned char* output, unsigned int sz)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
|
||||
while (i < sz)
|
||||
{
|
||||
/* If not aligned or there is odd/remainder */
|
||||
if( (i + sizeof(CUSTOM_RAND_TYPE)) > sz ||
|
||||
((uint32_t)&output[i] % sizeof(CUSTOM_RAND_TYPE)) != 0
|
||||
) {
|
||||
/* Single byte at a time */
|
||||
output[i++] = (unsigned char)my_rng_seed_gen();
|
||||
}
|
||||
else {
|
||||
/* Use native 8, 16, 32 or 64 copy instruction */
|
||||
*((CUSTOM_RAND_TYPE*)&output[i]) = my_rng_seed_gen();
|
||||
i += sizeof(CUSTOM_RAND_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef XMALLOC_OVERRIDE
|
||||
void *myMalloc(size_t n, void* heap, int type)
|
||||
{
|
||||
(void)n;
|
||||
(void)heap;
|
||||
(void)type;
|
||||
|
||||
#warning Must implement your own malloc
|
||||
|
||||
return NULL;
|
||||
}
|
||||
void myFree(void *p, void* heap, int type)
|
||||
{
|
||||
(void)p;
|
||||
(void)heap;
|
||||
(void)type;
|
||||
|
||||
#warning Must implement your own free
|
||||
}
|
||||
|
||||
/* Required for normal math (!USE_FAST_MATH) */
|
||||
void *myRealloc(void *p, size_t n, void* heap, int type)
|
||||
{
|
||||
(void)p;
|
||||
(void)n;
|
||||
(void)heap;
|
||||
(void)type;
|
||||
|
||||
#warning Must implement your own realloc
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif /* XMALLOC_OVERRIDE */
|
||||
Reference in New Issue
Block a user