AES.h
2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef _AES_H
#define _AES_H
#define RoundKeyLEN 300
//#define AES256MODE //AES256 否则AES128 --纯软件实现的
#define AES256EN //支持AES256
#include "crypto.h" //STM32的加密库接口
//void AES_Encrypt(char* pExpressText , char* pCipherText , char* pAeskey);
//void AES_Decrypt(char* pExpressText , char* pCipherText , char* pAeskey);
//void AES_Test(void);
void AES_Encrypt(char* pExpressText , char* pCipherText , char* pAeskey,unsigned char _256_mode);
void AES_Decrypt(char* pExpressText , char* pCipherText , char* pAeskey,unsigned char _256_mode);
/**
* @brief AES ECB Decryption example.
* @param InputMessage: pointer to input message to be decrypted.
* @param InputMessageLength: input data message length in byte.
* @param AES128_Key: pointer to the AES key to be used in the operation
* @param OutputMessage: pointer to output parameter that will handle the decrypted message
* @param OutputMessageLength: pointer to decrypted message length.
* @retval error status: can be AES_SUCCESS if success or one of
* AES_ERR_BAD_INPUT_SIZE, AES_ERR_BAD_OPERATION, AES_ERR_BAD_CONTEXT
* AES_ERR_BAD_PARAMETER if error occured.
*/
int32_t STM32_AES_ECB_Decrypt(uint8_t* InputMessage,
uint32_t InputMessageLength,
uint8_t *AES256_Key,
uint8_t *OutputMessage,
uint32_t *OutputMessageLength,unsigned char _256_mode);
/**
* @brief AES ECB Encryption example.
* @param InputMessage: pointer to input message to be encrypted.
* @param InputMessageLength: input data message length in byte.
* @param AES128_Key: pointer to the AES key to be used in the operation
* @param OutputMessage: pointer to output parameter that will handle the encrypted message
* @param OutputMessageLength: pointer to encrypted message length.
* @retval error status: can be AES_SUCCESS if success or one of
* AES_ERR_BAD_INPUT_SIZE, AES_ERR_BAD_OPERATION, AES_ERR_BAD_CONTEXT
* AES_ERR_BAD_PARAMETER if error occured.
*/
int32_t STM32_AES_ECB_Encrypt(uint8_t* InputMessage,
uint32_t InputMessageLength,
uint8_t *AES256_Key,
uint8_t *OutputMessage,
uint32_t *OutputMessageLength,unsigned char _256_mode);
extern const uint8_t rsbox[256];
#endif