1 /*********************************************************************** 2 * Copyright (c) 2008 - 2016, Shanghai AisinoChip Co.,Ltd . 3 * All rights reserved. 4 * Filename : aes.h 5 * Description : aes driver header file 6 * Author(s) : Eric 7 * version : V1.0 8 * Modify date : 2016-03-24 9 ***********************************************************************/ 10 #ifndef __AES_H__ 11 #define __AES_H__ 12 13 #include "ACM32Fxx_HAL.h" 14 15 #define AES_ENCRYPTION 1 16 #define AES_DECRYPTION 0 17 #define AES_ECB_MODE 0 18 #define AES_CBC_MODE 1 19 #define AES_SWAP_ENABLE 1 20 #define AES_SWAP_DISABLE 0 21 22 #define AES_NORMAL_MODE 0x12345678 23 #define AES_SECURITY_MODE 0 24 25 #define AES_KEY_128 0 26 #define AES_KEY_192 1 27 #define AES_KEY_256 2 28 29 #define AES_FAIL 0x00 30 #define AES_PASS 0xa59ada68 31 32 /****************************************************************************** 33 Name: HAL_AES_Set_Key 34 Function: set aes key for encryption and decryption 35 Input: 36 keyin -- pointer to buffer of key 37 swap_en -- AES_SWAP_ENABLE, AES_SWAP_DISABLE 38 Return: None 39 *******************************************************************************/ 40 void HAL_AES_Set_Key(UINT32 *keyin, UINT8 key_len, UINT8 swap_en); 41 void HAL_AES_Set_Key_U8(UINT8 *keyin, UINT8 key_len, UINT8 swap_en); 42 43 44 /****************************************************************************** 45 46 Name: HAL_Aes_Crypt 47 Function: Function for des encryption and decryption 48 Input: 49 indata -- pointer to buffer of input 50 outdata -- pointer to buffer of result 51 block_len -- block(128bit) length for des cryption 52 operation -- AES_ENCRYPTION,AES_DECRYPTION 53 mode -- AES_ECB_MODE, AES_CBC_MODE, 54 iv -- initial vector for CBC mode 55 security_mode -- AES_NORMAL_MODE, AES_SECURITY_MDOE, 56 Return: None 57 58 *******************************************************************************/ 59 UINT32 HAL_AES_Crypt( 60 UINT32 *indata, 61 UINT32 *outdata, 62 UINT32 block_len, 63 UINT8 operation, 64 UINT8 mode, 65 UINT32 *iv, 66 UINT32 security_mode 67 ); 68 69 70 UINT32 HAL_AES_Crypt_U8( 71 UINT8 *indata, 72 UINT8 *outdata, 73 UINT32 block_len, 74 UINT8 operation, 75 UINT8 mode, 76 UINT8 *iv, 77 UINT32 security_mode 78 ); 79 80 #endif 81 /****************************************************************************** 82 * end of file 83 *******************************************************************************/ 84