|
|
@@ -773,9 +773,7 @@ TEST_CASE("mbedtls OFB, chained DMA descriptors", "[aes]")
|
|
|
|
|
|
|
|
|
|
|
|
-#ifdef CONFIG_SPIRAM_USE_MALLOC
|
|
|
-
|
|
|
-const uint8_t expected_cipher_psram_end[] = {
|
|
|
+const uint8_t expected_cipher_ctr_end[] = {
|
|
|
0x7e, 0xdf, 0x13, 0xf3, 0x56, 0xef, 0x67, 0x01,
|
|
|
0xfc, 0x08, 0x49, 0x62, 0xfa, 0xfe, 0x0c, 0x8b,
|
|
|
0x99, 0x39, 0x09, 0x51, 0x2c, 0x9a, 0xd5, 0x48,
|
|
|
@@ -783,7 +781,7 @@ const uint8_t expected_cipher_psram_end[] = {
|
|
|
};
|
|
|
|
|
|
|
|
|
-void aes_psram_ctr_test(uint32_t input_buf_caps, uint32_t output_buf_caps)
|
|
|
+void aes_ctr_alignment_test(uint32_t input_buf_caps, uint32_t output_buf_caps)
|
|
|
{
|
|
|
mbedtls_aes_context ctx;
|
|
|
uint8_t nonce[16];
|
|
|
@@ -815,7 +813,7 @@ void aes_psram_ctr_test(uint32_t input_buf_caps, uint32_t output_buf_caps)
|
|
|
offset = 0;
|
|
|
memset(nonce, 0x2F, 16);
|
|
|
mbedtls_aes_crypt_ctr(&ctx, SZ, &offset, nonce, stream_block, plaintext + i, chipertext + i);
|
|
|
- TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_psram_end, chipertext + i + SZ - 32, 32);
|
|
|
+ TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_ctr_end, chipertext + i + SZ - 32, 32);
|
|
|
|
|
|
// Decrypt
|
|
|
offset = 0;
|
|
|
@@ -833,6 +831,15 @@ void aes_psram_ctr_test(uint32_t input_buf_caps, uint32_t output_buf_caps)
|
|
|
free(decryptedtext);
|
|
|
}
|
|
|
|
|
|
+TEST_CASE("mbedtls AES internal mem alignment tests", "[aes]")
|
|
|
+{
|
|
|
+ uint32_t internal_dma_caps = MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL;
|
|
|
+ aes_ctr_alignment_test(internal_dma_caps, internal_dma_caps);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+#ifdef CONFIG_SPIRAM_USE_MALLOC
|
|
|
+
|
|
|
void aes_psram_one_buf_ctr_test(void)
|
|
|
{
|
|
|
mbedtls_aes_context ctx;
|
|
|
@@ -862,7 +869,7 @@ void aes_psram_one_buf_ctr_test(void)
|
|
|
memset(buf, 0x26, SZ + ALIGNMENT_SIZE_BYTES);
|
|
|
memset(nonce, 0x2F, 16);
|
|
|
mbedtls_aes_crypt_ctr(&ctx, SZ, &offset, nonce, stream_block, buf + i, buf + i);
|
|
|
- TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_psram_end, buf + i + SZ - 32, 32);
|
|
|
+ TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher_ctr_end, buf + i + SZ - 32, 32);
|
|
|
|
|
|
// Decrypt
|
|
|
offset = 0;
|
|
|
@@ -1444,9 +1451,9 @@ void aes_ext_flash_ctr_test(uint32_t output_buf_caps)
|
|
|
/* Tests how crypto DMA handles data in external memory */
|
|
|
TEST_CASE("mbedtls AES PSRAM tests", "[aes]")
|
|
|
{
|
|
|
- aes_psram_ctr_test(MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
|
|
|
- aes_psram_ctr_test(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
|
|
|
- aes_psram_ctr_test(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
|
|
|
+ aes_ctr_alignment_test(MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
|
|
|
+ aes_ctr_alignment_test(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM, MALLOC_CAP_DMA | MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
|
|
|
+ aes_ctr_alignment_test(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM, MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
|
|
|
aes_psram_one_buf_ctr_test();
|
|
|
}
|
|
|
|