You are on page 1of 3

#include <stdio.

h>

#include <time.h>

//#include "hc128_opt32.h"

//#include "hc128_ref.h"

int main()

unsigned char key[16],iv[16];

unsigned char message[1024],ciphertext[1024];

unsigned long long msglength;

// HC128_State state;

unsigned long i;

clock_t start, finish;

double duration, speed;

/*set the value of the key and iv*/

for (i = 0; i < 16; i++) {key[i] = 0; iv[i] = 0;}

/*key[0] = 0x55;*/

/*initialize the message*/

for (i = 0; i < 1024; i++) message[i] = 0;


/*key and iv setup*/

// Initialization(&state,key,iv);

/*mesure the encryption speed by encrypting a 64-byte message repeatedly for 2*0x4000000
times*/

msglength = 1009;

start = clock();

for (i = 0; i < 0x4000000; i++) {

// EncryptMessage(&state,message,ciphertext,msglength);

// EncryptMessage(&state,ciphertext,message,msglength);

finish = clock();

/*compute the speed*/

duration = ((double)(finish - start))/ CLOCKS_PER_SEC;

speed = duration*2.53*1000*1000*1000/(((double)i)*2*msglength); /* 2.53*1000*1000*1000


indicates a 2.53GHz CPU */

/*print out the speed*/

printf("\n\nThe encryption takes %4.4f seconds.\nThe encryption speed is %3.4f cycles/byte


\n",duration,speed);

/*print out part of the contents of message

It is to prevent the over-optimization of compiler so as to


ensure that the above cipher computation must be computed*/

printf("\nPart of the message after being repeatedly encrypted: \n");

for (i = 0; i < 16; i++) printf("%x%x",message[i] >> 4, message[i] & 0xf);

printf("\n");

return (0);

You might also like