@@ -332,7 +332,9 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
332
332
/* Init crypto module */
333
333
crypto_init ();
334
334
335
- // NOTE: Don't call driver function TDES_Open in BSP because it doesn't support TDES_CTL[3KEYS] setting.
335
+ /* NOTE: Don't call driver function TDES_Open in BSP because we don't want its internal multiple context (channel) support.
336
+ * Multiple context (channel) support has done in the upper layer.
337
+ */
336
338
CRPT -> TDES_CTL = (0 << CRPT_TDES_CTL_CHANNEL_Pos ) | (enc << CRPT_TDES_CTL_ENCRPT_Pos ) |
337
339
tdes_opmode | (TDES_IN_OUT_WHL_SWAP << CRPT_TDES_CTL_BLKSWAP_Pos );
338
340
@@ -345,8 +347,10 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
345
347
CRPT -> TDES_CTL &= ~CRPT_TDES_CTL_3KEYS_Msk ;
346
348
}
347
349
348
- // Set DES/TDES keys
349
- // NOTE: Don't call driver function TDES_SetKey in BSP because it doesn't support endian swap.
350
+ /* Set DES/TDES keys
351
+ *
352
+ * NOTE: TDES_SetKey in BSP is not used because we need to make up an extra 2-dimension array to pass keys.
353
+ */
350
354
uint32_t val ;
351
355
volatile uint32_t * tdes_key = (uint32_t * ) ((uint32_t ) & CRPT -> TDES0_KEY1H + (0x40 * 0 ));
352
356
val = nu_get32_be (key [0 ] + 0 );
@@ -378,8 +382,10 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
378
382
379
383
TDES_SetDMATransfer (0 , (uint32_t ) dmabuf_in , (uint32_t ) dmabuf_out , data_len );
380
384
381
- // Start enc/dec.
382
- // NOTE: Don't call driver function TDES_Start in BSP because it will override TDES_CTL[3KEYS] setting.
385
+ /* Start enc/dec.
386
+ *
387
+ * NOTE: Don't call driver function TDES_Start in BSP because of the multiple context (channel) reason as above.
388
+ */
383
389
CRPT -> TDES_CTL |= CRPT_TDES_CTL_START_Msk | (CRYPTO_DMA_ONE_SHOT << CRPT_TDES_CTL_DMALAST_Pos );
384
390
while (CRPT -> TDES_STS & CRPT_TDES_STS_BUSY_Msk );
385
391
0 commit comments