rt-thread-official/bsp/essemi/es8p508x/libraries/Library/Include/lib_aes.h

75 lines
1.7 KiB
C
Raw Normal View History

2019-11-07 10:00:14 +08:00
/***************************************************************
*Copyright (C), 2017, Shanghai Eastsoft Microelectronics Co., Ltd
*<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> lib_aes.c
*<EFBFBD><EFBFBD> <EFBFBD>ߣ<EFBFBD> zoux
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> V1.00
*<EFBFBD><EFBFBD> <EFBFBD>ڣ<EFBFBD> 2017/07/14
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> AESģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*<EFBFBD><EFBFBD> ע<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ES8P508xоƬ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧϰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>κη<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ρ<EFBFBD>
***************************************************************/
#ifndef __LIBAES_H__
#define __LIBAES_H__
#include "ES8P508x.h"
#include "type.h"
/* <20><><EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD>ģʽѡ<CABD><D1A1>λ */
typedef enum {
AES_MODE_DECRYPT = 0, /* <20><><EFBFBD><EFBFBD> */
AES_MODE_ENCRYPT = 1, /* <20><><EFBFBD><EFBFBD> */
}AES_TYPE_MODE;
/* <20><><EFBFBD><EFBFBD>/<2F><><EFBFBD>ܿ<EFBFBD><DCBF><EFBFBD>λ */
typedef enum {
AES_DONE_YES = 0, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
AES_DONE_NO = 1, /* <20><><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD> */
}AES_TYPE_DONE;
/* <20>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9> */
typedef struct {
uint32_t DATA[4];
}AES_DATA_TypeDef;
typedef enum {
AES_IF_IF = 0x80,
}AES_TYPE_IF;
typedef enum {
AES_IT_IT = 0x40,
}AES_TYPE_IT;
/* <20>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><EFBFBD><E1B9B9> */
typedef struct {
uint32_t KEY[4];
}AES_KEY_TypeDef;
/* <20>ӽ<EFBFBD><D3BD>ܳ<EFBFBD>ʼ<EFBFBD><EFBFBD><E1B9B9> */
typedef struct {
AES_TYPE_MODE MODE; /* <20><><EFBFBD>ܻ<EFBFBD><DCBB>߽<EFBFBD><DFBD><EFBFBD> */
}AES_InitStruType;
/* <20>ӽ<EFBFBD><D3BD><EFBFBD>ʹ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> */
#define AES_Enable() (AES->CON.GO_DONE = 1)
/* <20><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>ر<EFBFBD> */
#define AES_Disable() (AES->CON.GO_DONE = 0)
/********************* ADCģ<43><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *********************/
void AES_Init(AES_InitStruType * AES_InitStruct);
void AES_WriteKey(uint32_t *AES_KEY);
void AES_ReadKey(uint32_t * AES_KEY);
void AES_WriteData(uint32_t *AES_DATA);
void AES_ReadData(uint32_t * AES_DATA);
void AES_ITConfig(AES_TYPE_IT AES_IE, TYPE_FUNCEN NewState);
void AES_ClearITPendingBit(void);
FlagStatus AES_GetFlagStatus(AES_TYPE_IF Flag);
AES_TYPE_DONE AES_GetDoneStatus(void);
void AES_Reset(void);
#endif