Skip to content

Commit f332ef7

Browse files
cyliangtwccli8
authored andcommitted
Improve HW AES CFB mode performance for byte cnt non-word alignment
1 parent be9e74b commit f332ef7

File tree

1 file changed

+4
-2
lines changed
  • hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/aes

1 file changed

+4
-2
lines changed

hal/targets/hal/TARGET_NUVOTON/TARGET_NUC472/crypto/aes/aes_alt.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,12 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
409409
}
410410

411411
// For address or byte count non-word alignment, go through reserved DMA buffer.
412-
if( (((uint32_t)input) & 0x03) || (((uint32_t)output) & 0x03) || (length%4) )
412+
if( (((uint32_t)input) & 0x03) || (((uint32_t)output) & 0x03) ) // Must reserved DMA buffer for each block
413413
{
414414
blockChainLen = (( length > MAX_DMA_CHAIN_SIZE ) ? MAX_DMA_CHAIN_SIZE : length );
415-
} else {
415+
} else if(length%4) { // Need reserved DMA buffer once for last chain
416+
blockChainLen = (( length > MAX_DMA_CHAIN_SIZE ) ? (length - length%16) : length );
417+
} else { // Not need reserved DMA buffer
416418
blockChainLen = length;
417419
}
418420

0 commit comments

Comments
 (0)