Skip to content

Commit ac00024

Browse files
committed
[NUC472/M487] Refine AES/DES alter. DMA buffer requirement comment
1 parent aafbdc8 commit ac00024

File tree

4 files changed

+40
-16
lines changed

4 files changed

+40
-16
lines changed

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/aes/aes_alt.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ static void mbedtls_zeroize( void *v, size_t n )
4343
while( n-- ) *p++ = 0;
4444
}
4545

46-
/* DMA compatible backup buffer if user buffer doesn't meet requirements
46+
/* AES DMA compatible backup buffer if user buffer doesn't meet requirements
4747
*
48-
* MAX_DMA_CHAIN_SIZE must be a multiple of 16-byte block size.
49-
* Its value is estimated to trade memory footprint off against performance.
48+
* AES DMA buffer location requires to be:
49+
* (1) Word-aligned
50+
* (2) Located in 0x2xxxxxxx region. Check linker files to ensure global variables are placed in this region.
51+
*
52+
* AES DMA buffer size MAX_DMA_CHAIN_SIZE must be a multiple of 16-byte block size.
53+
* Its value is estimated to trade memory footprint off against performance.
54+
*
5055
*/
5156
#define MAX_DMA_CHAIN_SIZE (16*6)
5257
MBED_ALIGN(4) static uint8_t au8OutputData[MAX_DMA_CHAIN_SIZE];
@@ -133,7 +138,8 @@ static void __nvt_aes_crypt( mbedtls_aes_context *ctx,
133138
* 1) Word-aligned
134139
* 2) Located in 0x2xxxxxxx region
135140
*/
136-
if ((! crypto_dma_buff_compat(au8OutputData, MAX_DMA_CHAIN_SIZE)) || (! crypto_dma_buff_compat(au8InputData, MAX_DMA_CHAIN_SIZE))) {
141+
if ((! crypto_dma_buff_compat(au8OutputData, MAX_DMA_CHAIN_SIZE)) ||
142+
(! crypto_dma_buff_compat(au8InputData, MAX_DMA_CHAIN_SIZE))) {
137143
error("Buffer for AES alter. DMA requires to be word-aligned and located in 0x20000000-0x2FFFFFFF region.");
138144
}
139145

features/mbedtls/targets/TARGET_NUVOTON/TARGET_M480/des/des_alt.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@
2626
#include "mbed_toolchain.h"
2727
#include "mbed_error.h"
2828

29-
/* DMA buffer
29+
/* DES DMA compatible buffer requirements
3030
*
31-
* MAXSIZE_DMABUF must be a multiple of 64-bit block size.
32-
* Its value is estimated to trade memory footprint off against performance.
31+
* DES DMA buffer location requires to be:
32+
* (1) Word-aligned
33+
* (2) Located in 0x2xxxxxxx region. Check linker files to ensure global variables are placed in this region.
34+
*
35+
* DES DMA buffer size MAXSIZE_DMABUF must be a multiple of 64-bit block size.
36+
* Its value is estimated to trade memory footprint off against performance.
37+
*
3338
*/
3439
#define MAXSIZE_DMABUF (8 * 5)
3540
MBED_ALIGN(4) static uint8_t dmabuf_in[MAXSIZE_DMABUF];
@@ -314,7 +319,8 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
314319
* 1) Word-aligned
315320
* 2) Located in 0x2xxxxxxx region
316321
*/
317-
if ((! crypto_dma_buff_compat(dmabuf_in, MAXSIZE_DMABUF)) || (! crypto_dma_buff_compat(dmabuf_out, MAXSIZE_DMABUF))) {
322+
if ((! crypto_dma_buff_compat(dmabuf_in, MAXSIZE_DMABUF)) ||
323+
(! crypto_dma_buff_compat(dmabuf_out, MAXSIZE_DMABUF))) {
318324
error("Buffer for DES alter. DMA requires to be word-aligned and located in 0x20000000-0x2FFFFFFF region.");
319325
}
320326

features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/aes/aes_alt.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ static void mbedtls_zeroize( void *v, size_t n )
4343
while( n-- ) *p++ = 0;
4444
}
4545

46-
/* DMA compatible backup buffer if user buffer doesn't meet requirements
46+
/* AES DMA compatible backup buffer if user buffer doesn't meet requirements
4747
*
48-
* MAX_DMA_CHAIN_SIZE must be a multiple of 16-byte block size.
49-
* Its value is estimated to trade memory footprint off against performance.
48+
* AES DMA buffer location requires to be:
49+
* (1) Word-aligned
50+
* (2) Located in 0x2xxxxxxx region. Check linker files to ensure global variables are placed in this region.
51+
*
52+
* AES DMA buffer size MAX_DMA_CHAIN_SIZE must be a multiple of 16-byte block size.
53+
* Its value is estimated to trade memory footprint off against performance.
54+
*
5055
*/
5156
#define MAX_DMA_CHAIN_SIZE (16*6)
5257
MBED_ALIGN(4) static uint8_t au8OutputData[MAX_DMA_CHAIN_SIZE];
@@ -133,7 +138,8 @@ static void __nvt_aes_crypt( mbedtls_aes_context *ctx,
133138
* 1) Word-aligned
134139
* 2) Located in 0x2xxxxxxx region
135140
*/
136-
if ((! crypto_dma_buff_compat(au8OutputData, MAX_DMA_CHAIN_SIZE)) || (! crypto_dma_buff_compat(au8InputData, MAX_DMA_CHAIN_SIZE))) {
141+
if ((! crypto_dma_buff_compat(au8OutputData, MAX_DMA_CHAIN_SIZE)) ||
142+
(! crypto_dma_buff_compat(au8InputData, MAX_DMA_CHAIN_SIZE))) {
137143
error("Buffer for AES alter. DMA requires to be word-aligned and located in 0x20000000-0x2FFFFFFF region.");
138144
}
139145

features/mbedtls/targets/TARGET_NUVOTON/TARGET_NUC472/des/des_alt.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@
2626
#include "mbed_toolchain.h"
2727
#include "mbed_error.h"
2828

29-
/* DMA buffer
29+
/* DES DMA compatible buffer requirements
3030
*
31-
* MAXSIZE_DMABUF must be a multiple of 64-bit block size.
32-
* Its value is estimated to trade memory footprint off against performance.
31+
* DES DMA buffer location requires to be:
32+
* (1) Word-aligned
33+
* (2) Located in 0x2xxxxxxx region. Check linker files to ensure global variables are placed in this region.
34+
*
35+
* DES DMA buffer size MAXSIZE_DMABUF must be a multiple of 64-bit block size.
36+
* Its value is estimated to trade memory footprint off against performance.
37+
*
3338
*/
3439
#define MAXSIZE_DMABUF (8 * 5)
3540
MBED_ALIGN(4) static uint8_t dmabuf_in[MAXSIZE_DMABUF];
@@ -314,7 +319,8 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
314319
* 1) Word-aligned
315320
* 2) Located in 0x2xxxxxxx region
316321
*/
317-
if ((! crypto_dma_buff_compat(dmabuf_in, MAXSIZE_DMABUF)) || (! crypto_dma_buff_compat(dmabuf_out, MAXSIZE_DMABUF))) {
322+
if ((! crypto_dma_buff_compat(dmabuf_in, MAXSIZE_DMABUF)) ||
323+
(! crypto_dma_buff_compat(dmabuf_out, MAXSIZE_DMABUF))) {
318324
error("Buffer for DES alter. DMA requires to be word-aligned and located in 0x20000000-0x2FFFFFFF region.");
319325
}
320326

0 commit comments

Comments
 (0)