[openssl] AES test program I
void aes_test(){
AES_KEY ekey, dkey;
unsigned char key[16]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F };
unsigned char plaintext[16];
unsigned char ciphertext[16];
int i;
strcpy((char*)plaintext, "test1234567");
AES_set_encrypt_key(key,128,&ekey);
AES_set_decrypt_key(key,128,&dkey);
AES_encrypt(plaintext, ciphertext,&ekey);
printf("\nciphertext:\n");
for( i=0 ; i<16 ; i++)
printf("%02x ",buf[i]);
memset(plaintext,0,16);
AES_decrypt(ciphertext, plaintext,&dkey);
printf("\n"plaintext:\n");
for( i=0 ; i<16 ; i++)
printf("%02x ",in[i]);
}
0 Comments:
Post a Comment
<< Home