www.pudn.com > AES-128Bit-C51.rar > TestAES.c, change:2007-11-13,size:802b


#include <stdio.h> 
#include <reg51.h> 
#include "AES_Lib.h" 
 
AES_U8 in[16]  = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77, 
		          0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff}; 
 
//AES_U8 key[16] = {0xf0,0xe0,0xd0,0xc0,0xb0,0xa0,0x90,0x80, 
//                  0x70,0x60,0x50,0x40,0x30,0x20,0x10,0x00}; 
AES_U8 key[16] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 
                  0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f}; 
 
AES_U8 out[16]; 
 
void main (void) 
{ 
AES_U8  xdata expKey[4 * Nb * (Nr + 1)]; 
AES_U16 idx; 
 
	//以下是在标准MSC51核上运行的时间,24M晶振 
	AES_ExpandKey (key, expKey);		//10.4ms 
	 
	memset(out, 0, sizeof (out));		//45us 
	AES_Encrypt (in, expKey, out);		//8.5ms 
 
	memset(in, 0, sizeof (in));			//45us 
	 
	AES_Decrypt (out, expKey, in);		//10.7ms 
	 
	idx = 0; 
 
}