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/Decryption with CTR Mode > //
9 // Procedure number: 08 //
10 // File name : SC324_p08.prc //
11 // State Diagram : main(FSM1) //
12 // Start State : main03 //
13 // End State : main03 //
14 // Input Data : InData_Key[4] //
15 // : InData_IV[4] //
16 // : InData_Text[MAX_CNT] //
17 // Output Data : OutData_Text[MAX_CNT] //
18 // : (MAX_CNT is Multiples of four.) //
19 // OutData_IV[4] //
20 // Return Value : Pass, Fail or Resource_Conflict //
21 // ---------------------------------------------------------------------//
22 // total cycle : polling + write access + read access //
23 // polling : //
24 // polling access : //
25 // write access : //
26 // read access : //
27 /////////////////////////////////////////////////////////////////////////
28
29 #include "sc324_aes_private.h"
30
31 #include "hw_sce_aes_private.h"
32
33 /*******************************************************************************************************************//**
34 * AES-128 Encryption/Decryption with CTR Mode
35 *
36 * @param[in] InData_Key In data key
37 * @param[in] InData_IV In data iv
38 * @param[in] num_words The number words
39 * @param[in] InData_Text In data text
40 * @param OutData_Text The out data text
41 * @param OutData_IV The out data iv
42 *
43 * @retval FSP_SUCCESS The operation completed successfully.
44 * @retval FSP_ERR_CRYPTO_INVALID_SIZE The size of the data must be multiples of 4 WORDS / 16 bytes.
45 **********************************************************************************************************************/
HW_SCE_AES_128CtrEncrypt(const uint32_t * InData_Key,const uint32_t * InData_IV,const uint32_t num_words,const uint32_t * InData_Text,uint32_t * OutData_Text,uint32_t * OutData_IV)46 fsp_err_t HW_SCE_AES_128CtrEncrypt (const uint32_t * InData_Key,
47 const uint32_t * InData_IV,
48 const uint32_t num_words,
49 const uint32_t * InData_Text,
50 uint32_t * OutData_Text,
51 uint32_t * OutData_IV)
52 {
53 hw_sc324_aes_ctrl_t aesCtrl;
54
55 aesCtrl.encrypt_flag = SC324_AES_ENCRYPT;
56 aesCtrl.keysize = SC324_AES_KEYSIZE_128;
57 aesCtrl.mode = SC324_AES_CTR;
58
59 return hw_sc324_aes_kernel_process_data(&aesCtrl,
60 InData_Key,
61 InData_IV,
62 num_words,
63 InData_Text,
64 OutData_Text,
65 OutData_IV);
66 }
67