Merge branch 'master' into feature/esp32s2beta_update

This commit is contained in:
Angus Gratton
2019-08-08 14:00:45 +10:00
committed by Angus Gratton
657 changed files with 6814 additions and 7534 deletions

View File

@@ -28,6 +28,7 @@ target_sources(mbedtls PRIVATE "${COMPONENT_DIR}/port/esp_hardware.c"
"${COMPONENT_DIR}/port/esp_sha1.c"
"${COMPONENT_DIR}/port/esp_sha256.c"
"${COMPONENT_DIR}/port/esp_sha512.c"
"${COMPONENT_DIR}/port/esp_timing.c"
"${COMPONENT_DIR}/port/mbedtls_debug.c"
"${COMPONENT_DIR}/port/net_sockets.c"
"${COMPONENT_DIR}/port/${idf_target}/aes.c"

View File

@@ -73,7 +73,7 @@ static IRAM_ATTR void rsa_complete_isr(void *arg)
}
}
static void rsa_isr_initialise()
static void rsa_isr_initialise(void)
{
if (op_complete_sem == NULL) {
op_complete_sem = xSemaphoreCreateBinary();

View File

@@ -28,7 +28,6 @@
#include <string.h>
#include <stdio.h>
#include <sys/lock.h>
#include <byteswap.h>
#include <assert.h>
#include "esp32s2beta/sha.h"
@@ -82,7 +81,7 @@ static void memcpy_endianswap(void *to, const void *from, size_t num_bytes)
const uint32_t *from_words = (const uint32_t *)from;
assert(num_bytes % 4 == 0);
for (int i = 0; i < num_bytes / 4; i++) {
to_words[i] = __bswap_32(from_words[i]);
to_words[i] = __builtin_bswap32(from_words[i]);
}
asm volatile ("memw");
}

View File

@@ -0,0 +1,102 @@
/*
* Portable interface to the CPU cycle counter
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
/*
* mbedtls_timing_get_timer()m mbedtls_timing_set_delay() and
* mbedtls_timing_set_delay only abstracted from mbedtls/library/timing.c
* as that does not build on ESP-IDF but these 2 functions are needed for
* DTLS (in particular mbedtls_ssl_set_timer_cb() must be called for DTLS
* which requires these 2 delay functions).
*/
#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#if !defined(MBEDTLS_ESP_TIMING_C)
#include <sys/time.h>
#include "mbedtls/timing.h"
struct _hr_time
{
struct timeval start;
};
unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset )
{
struct _hr_time *t = (struct _hr_time *) val;
if( reset )
{
gettimeofday( &t->start, NULL );
return( 0 );
}
else
{
unsigned long delta;
struct timeval now;
gettimeofday( &now, NULL );
delta = ( now.tv_sec - t->start.tv_sec ) * 1000ul
+ ( now.tv_usec - t->start.tv_usec ) / 1000;
return( delta );
}
}
/*
* Set delays to watch
*/
void mbedtls_timing_set_delay( void *data, uint32_t int_ms, uint32_t fin_ms )
{
mbedtls_timing_delay_context *ctx = (mbedtls_timing_delay_context *) data;
ctx->int_ms = int_ms;
ctx->fin_ms = fin_ms;
if( fin_ms != 0 )
(void) mbedtls_timing_get_timer( &ctx->timer, 1 );
}
/*
* Get number of delays expired
*/
int mbedtls_timing_get_delay( void *data )
{
mbedtls_timing_delay_context *ctx = (mbedtls_timing_delay_context *) data;
unsigned long elapsed_ms;
if( ctx->fin_ms == 0 )
return( -1 );
elapsed_ms = mbedtls_timing_get_timer( &ctx->timer, 0 );
if( elapsed_ms >= ctx->fin_ms )
return( 2 );
if( elapsed_ms >= ctx->int_ms )
return( 1 );
return( 0 );
}
#endif /* MBEDTLS_ESP_TIMING_C */

View File

@@ -17,7 +17,7 @@ static void apb_access_loop_task(void *ignore);
static volatile bool apb_access_corrupt;
static TaskHandle_t apb_task_handle;
void start_apb_access_loop()
void start_apb_access_loop(void)
{
apb_access_corrupt = false;
xTaskCreatePinnedToCore(apb_access_loop_task, "accessAPB", 2048, NULL,
@@ -25,7 +25,7 @@ void start_apb_access_loop()
&apb_task_handle, !UNITY_FREERTOS_CPU);
}
void verify_apb_access_loop()
void verify_apb_access_loop(void)
{
vTaskDelete(apb_task_handle);
apb_task_handle = NULL;
@@ -45,11 +45,11 @@ static void apb_access_loop_task(void *ignore)
#else /*CONFIG_FREERTOS_UNICORE */
void start_apb_access_loop()
void start_apb_access_loop(void)
{
}
void verify_apb_access_loop()
void verify_apb_access_loop(void)
{
}

View File

@@ -10,9 +10,9 @@
Does nothing in unicore mode.
*/
void start_apb_access_loop();
void start_apb_access_loop(void);
/* verify_apb_access_loop() kills the task started by start_apb_access_loop()
and verifies that none of the APB reads were corrupted by unsafe DPORT reads.
*/
void verify_apb_access_loop();
void verify_apb_access_loop(void);