#include "msp430x26x.h"
#include "aes.h"
#include
#include
#include
int main( void )
{
int i;
int len;
unsigned char state[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
// unsigned char state[] ="AES加密AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
//unsigned char ciphertext[] = {0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
// 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a};
unsigned char key[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
unsigned char data[128];
FILE* fpsrc,*fpdst;
if( (fpsrc = fopen("f:\cp.exe","rb" )) == NULL)
{
printf("Open SRC File Error!\n");
exit( 1 );
}
fpdst = fopen( "f:\test_decrypt.exe","wb" );
while( ( len = fread( data,1,sizeof( data ),fpsrc )) > 0 )
{
if( len < sizeof( data ))
{
printf("Go to file end!\n");
}
aes_decrypt( data,key);
fwrite( data,1,sizeof( data ),fpdst );
memset( data,0,sizeof(data));
}
fclose( fpsrc);
fclose( fpdst );
aes_encrypt(state,key);
//aes_decrypt(state,key);
printf("%s\n",state );
for( i = 0; i < sizeof( state ); ++i )
{
printf("0x%02x\t",state[i] );
}
aes_decrypt(state,key);
for( i = 0; i < sizeof( state ); ++i )
{
printf("0x%02x\t",state[i] );
}
printf("%s\n",state );
return 0;
}
还有一个.c和.h的文件,用devc++运行main函数显示没有msp430x26x.h