1 /*
2 * Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 /////////////////////////////////////////////////////////////////////////
8 // <SC32#4 AES-128 Encryption with ECB Mode> //
9 // Procedure number: 04 //
10 // File name : SC324_p04.prc //
11 // State Diagram : main(FSM1) //
12 // Start State : main03 //
13 // End State : main03 //
14 // Input Data : InData_Key[4] //
15 // : InData_Text[MAX_CNT] //
16 // Output Data : OutData_Text[MAX_CNT] //
17 // : (MAX_CNT is Multiples of four.) //
18 // Return Value : Pass, Fail or Resource_Conflict //
19 // ---------------------------------------------------------------------//
20 // total cycle : polling + write access + read access //
21 // polling : 259 + (MAX_CNT/4-1)*44 cycle //
22 // polling access : 11 + (MAX_CNT/4-1)*2 times //
23 // write access : 44 + (MAX_CNT-4) times //
24 // read access : 4 + (MAX_CNT-4) times //
25 /////////////////////////////////////////////////////////////////////////
26
27 #include "sc324_aes_private.h"
28 #include "hw_sce_aes_private.h"
29
30 /*******************************************************************************************************************//**
31 * AES-128 Encryption with ECB Mode.
32 *
33 * @param[in] InData_Key In data key
34 * @param[in] num_words The number words
35 * @param[in] InData_Text In data text
36 * @param OutData_Text The out data text
37 *
38 * @retval FSP_SUCCESS The operation completed successfully.
39 * @retval FSP_ERR_CRYPTO_INVALID_SIZE The size of the data must be multiples of 4 WORDS / 16 bytes.
40 **********************************************************************************************************************/
HW_SCE_AES_128EcbEncrypt(const uint32_t * InData_Key,const uint32_t num_words,const uint32_t * InData_Text,uint32_t * OutData_Text)41 fsp_err_t HW_SCE_AES_128EcbEncrypt (const uint32_t * InData_Key,
42 const uint32_t num_words,
43 const uint32_t * InData_Text,
44 uint32_t * OutData_Text)
45 {
46 hw_sc324_aes_ctrl_t aesCtrl;
47
48 aesCtrl.encrypt_flag = SC324_AES_ENCRYPT;
49 aesCtrl.keysize = SC324_AES_KEYSIZE_128;
50 aesCtrl.mode = SC324_AES_ECB;
51
52 return hw_sc324_aes_kernel_process_data(&aesCtrl, InData_Key, NULL, num_words, InData_Text, OutData_Text, NULL);
53 }
54