本帖最后由 wdluo 于 2012-7-29 22:43 编辑
用C语言实现了适合在单片机上运行的AES加密算法,如下是加密算法测试程序:- #include "AES.h"
- int main()
- {
- // 测试AES算法
- unsigned char key[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}; // 密钥
- unsigned char IV[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}; // 初始化向量
- unsigned char PlainText[16] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; // 明文
- unsigned char CipherText[16] = {0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a};// 密文
- AES_Init(key); // 89us @60MHz
- AES_Encrypt(PlainText, CipherText, sizeof(PlainText), IV); // 201us @60MHz
- AES_Decrypt(PlainText, CipherText, sizeof(PlainText), IV); // 226us @60MHz
- return 0;
- }
复制代码
AES_ARM.rar
(11.61 KB, 下载次数: 69)
|