feat: remove support for aes and rsa peripherals in esp32c61

This commit is contained in:
nilesh.kale
2024-06-27 12:14:05 +05:30
parent bedfe0fe3b
commit e74dcb1fab
8 changed files with 22 additions and 68 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -16,7 +16,6 @@
#include "freertos/task.h"
#include "freertos/semphr.h"
static SemaphoreHandle_t done_sem;
static const unsigned char *one_hundred_bs = (unsigned char *)
@@ -77,11 +76,11 @@ static void tskRunAES256Test(void *pvParameters)
memcpy(nonce, iv, 16);
// allocate internal memory
uint8_t *chipertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
uint8_t *ciphertext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
uint8_t *plaintext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
uint8_t *decryptedtext = heap_caps_malloc(SZ, MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL);
TEST_ASSERT_NOT_NULL(chipertext);
TEST_ASSERT_NOT_NULL(ciphertext);
TEST_ASSERT_NOT_NULL(plaintext);
TEST_ASSERT_NOT_NULL(decryptedtext);
@@ -92,19 +91,19 @@ static void tskRunAES256Test(void *pvParameters)
memset(decryptedtext, 0x0, SZ);
// Encrypt
mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_ENCRYPT, SZ, nonce, plaintext, chipertext);
TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, chipertext + SZ - 32, 32);
mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_ENCRYPT, SZ, nonce, plaintext, ciphertext);
TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_end, ciphertext + SZ - 32, 32);
// Decrypt
memcpy(nonce, iv, 16);
mbedtls_aes_setkey_dec(&ctx, key_256, 256);
mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_DECRYPT, SZ, nonce, chipertext, decryptedtext);
mbedtls_aes_crypt_cbc(&ctx, MBEDTLS_AES_DECRYPT, SZ, nonce, ciphertext, decryptedtext);
TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ);
mbedtls_aes_free(&ctx);
free(plaintext);
free(chipertext);
free(ciphertext);
free(decryptedtext);
}
xSemaphoreGive(done_sem);

View File

@@ -1,6 +1,6 @@
/* mbedTLS bignum (MPI) self-tests as unit tests
*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -17,6 +17,12 @@
#include "sdkconfig.h"
#include "test_utils.h"
#ifdef SOC_MPI_SUPPORTED
#define RSA_MAX_BIT_LEN SOC_RSA_MAX_BIT_LEN
#else
#define RSA_MAX_BIT_LEN 3072
#endif
#define MBEDTLS_OK 0
/* Debugging function to print an MPI number to stdout. Happens to
@@ -54,7 +60,7 @@ static void test_bignum_mult_variant(const char *a_str, const char *b_str, const
TEST_ASSERT_FALSE(mbedtls_mpi_read_string(&A, 16, a_str));
TEST_ASSERT_FALSE(mbedtls_mpi_read_string(&B, 16, b_str));
/* calulate X = A * B variant */
/* calculate X = A * B variant */
TEST_ASSERT_FALSE(mbedtls_mpi_read_string(&E, 16, e_str));
if (res_operands_overlap == 0) {
TEST_ASSERT_FALSE(mbedtls_mpi_mul_mpi(&X, &A, &B));
@@ -72,7 +78,7 @@ static void test_bignum_mult_variant(const char *a_str, const char *b_str, const
#ifdef CONFIG_MBEDTLS_HARDWARE_MPI
mbedtls_mpi M;
/* if mod_bits arg is set, also do a esp_mpi_mul_mod() call */
if (mod_bits > 0 && mod_bits <= SOC_RSA_MAX_BIT_LEN) {
if (mod_bits > 0 && mod_bits <= RSA_MAX_BIT_LEN) {
mbedtls_mpi_init(&M);
for(int i = 0; i < mod_bits; i++) {
mbedtls_mpi_set_bit(&M, i, 1);
@@ -106,7 +112,7 @@ TEST_CASE("test MPI multiplication", "[bignum]")
/* Run some trivial numbers tests w/ various high modulo bit counts,
should make no difference to the result
*/
for(int i = 512; i <= SOC_RSA_MAX_BIT_LEN; i+= 512) {
for(int i = 512; i <= RSA_MAX_BIT_LEN; i+= 512) {
test_bignum_mult("10", "100", "1000",
i);
}

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -249,7 +249,7 @@ TEST_CASE("mbedtls SHA384 clone", "[mbedtls]")
TEST_ASSERT_EQUAL(0, mbedtls_sha512_update(&ctx, one_hundred_bs, 100));
TEST_ASSERT_EQUAL(0, mbedtls_sha512_update(&clone, one_hundred_bs, 100));
}
/* intended warning supression: is384 == true */
/* intended warning suppression: is384 == true */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
TEST_ASSERT_EQUAL(0, mbedtls_sha512_finish(&ctx, sha384));