1
- /* mbed Microcontroller Library
2
- * Copyright (c) 2015-2016 Nuvoton
1
+ /*
2
+ * Copyright (c) 2015-2016, Nuvoton Technology Corporation
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
3
5
*
4
6
* Licensed under the Apache License, Version 2.0 (the "License");
5
7
* you may not use this file except in compliance with the License.
@@ -355,7 +357,7 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
355
357
/* Init crypto module */
356
358
crypto_init ();
357
359
/* Enable DES interrupt */
358
- TDES_ENABLE_INT ();
360
+ TDES_ENABLE_INT (CRPT );
359
361
360
362
/* Configure TDES_CTL register
361
363
*
@@ -373,7 +375,8 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
373
375
* 1. BE for byte sequence in word
374
376
* 2. BE for word sequence in double-word
375
377
*/
376
- TDES_Open (0 , // Channel number (0~4)
378
+ TDES_Open (CRPT
379
+ 0 , // Channel number (0~4)
377
380
enc , // 0: decode, 1: encode
378
381
(tdes_opmode & CRPT_TDES_CTL_TMODE_Msk ) ? 1 : 0 , // 0: DES, 1: TDES
379
382
(keyopt == 1 ) ? 1 : 0 , // 0: TDES 2-key mode, 1: TDES 3-key mode
@@ -390,7 +393,7 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
390
393
keys3x2 [i ][0 ] = nu_get32_be (key [i ] + 0 );
391
394
keys3x2 [i ][1 ] = nu_get32_be (key [i ] + 4 );
392
395
}
393
- TDES_SetKey (0 , keys3x2 );
396
+ TDES_SetKey (CRPT , 0 , keys3x2 );
394
397
395
398
uint32_t rmn = length ;
396
399
const unsigned char * in_pos = input ;
@@ -402,15 +405,15 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
402
405
uint32_t ivh , ivl ;
403
406
ivh = nu_get32_be (iv );
404
407
ivl = nu_get32_be (iv + 4 );
405
- TDES_SetInitVect (0 , ivh , ivl );
408
+ TDES_SetInitVect (CRPT , 0 , ivh , ivl );
406
409
407
410
memcpy (dmabuf_in , in_pos , data_len );
408
411
409
412
/* We always use DMA backup buffers, which are guaranteed to be non-overlapped. */
410
- TDES_SetDMATransfer (0 , (uint32_t ) dmabuf_in , (uint32_t ) dmabuf_out , data_len );
413
+ TDES_SetDMATransfer (CRPT , 0 , (uint32_t ) dmabuf_in , (uint32_t ) dmabuf_out , data_len );
411
414
412
415
crypto_des_prestart ();
413
- TDES_Start (0 , CRYPTO_DMA_ONE_SHOT );
416
+ TDES_Start (CRPT , 0 , CRYPTO_DMA_ONE_SHOT );
414
417
crypto_des_wait ();
415
418
416
419
memcpy (out_pos , dmabuf_out , data_len );
@@ -452,7 +455,7 @@ static int mbedtls_des_docrypt(uint16_t keyopt, uint8_t key[3][MBEDTLS_DES_KEY_S
452
455
}
453
456
454
457
/* Disable DES interrupt */
455
- TDES_DISABLE_INT ();
458
+ TDES_DISABLE_INT (CRPT );
456
459
/* Uninit crypto module */
457
460
crypto_uninit ();
458
461
0 commit comments