7 static double gettimedouble(
void) {
9 gettimeofday(&tv, NULL);
10 return tv.tv_usec * 0.000001 + tv.tv_sec;
28 double min = HUGE_VAL;
31 for (i = 0; i <
count; i++) {
36 begin = gettimedouble();
38 total = gettimedouble() - begin;
39 if (teardown != NULL) {
59 static void bench_AES128_init(
void* data) {
62 for (i = 0; i < 50000; i++) {
67 static void bench_AES128_encrypt_setup(
void* data) {
69 static const unsigned char key[16] = {0};
73 static void bench_AES128_encrypt(
void* data) {
75 unsigned char scratch[16] = {0};
77 for (i = 0; i < 4000000 / 16; i++) {
82 static void bench_AES128_decrypt(
void* data) {
84 unsigned char scratch[16] = {0};
86 for (i = 0; i < 4000000 / 16; i++) {
91 static void bench_AES192_init(
void* data) {
94 for (i = 0; i < 50000; i++) {
99 static void bench_AES192_encrypt_setup(
void* data) {
101 static const unsigned char key[16] = {0};
105 static void bench_AES192_encrypt(
void* data) {
107 unsigned char scratch[16] = {0};
109 for (i = 0; i < 4000000 / 16; i++) {
114 static void bench_AES192_decrypt(
void* data) {
116 unsigned char scratch[16] = {0};
118 for (i = 0; i < 4000000 / 16; i++) {
123 static void bench_AES256_init(
void* data) {
126 for (i = 0; i < 50000; i++) {
132 static void bench_AES256_encrypt_setup(
void* data) {
134 static const unsigned char key[16] = {0};
138 static void bench_AES256_encrypt(
void* data) {
140 unsigned char scratch[16] = {0};
142 for (i = 0; i < 4000000 / 16; i++) {
147 static void bench_AES256_decrypt(
void* data) {
149 unsigned char scratch[16] = {0};
151 for (i = 0; i < 4000000 / 16; i++) {
160 run_benchmark(
"aes128_init", bench_AES128_init, NULL, NULL, &ctx128, 20, 50000);
161 run_benchmark(
"aes128_encrypt_byte", bench_AES128_encrypt, bench_AES128_encrypt_setup, NULL, &ctx128, 20, 4000000);
162 run_benchmark(
"aes128_decrypt_byte", bench_AES128_decrypt, bench_AES128_encrypt_setup, NULL, &ctx128, 20, 4000000);
163 run_benchmark(
"aes192_init", bench_AES192_init, NULL, NULL, &ctx192, 20, 50000);
164 run_benchmark(
"aes192_encrypt_byte", bench_AES192_encrypt, bench_AES192_encrypt_setup, NULL, &ctx192, 20, 4000000);
165 run_benchmark(
"aes192_decrypt_byte", bench_AES192_decrypt, bench_AES192_encrypt_setup, NULL, &ctx192, 20, 4000000);
166 run_benchmark(
"aes256_init", bench_AES256_init, NULL, NULL, &ctx256, 20, 50000);
167 run_benchmark(
"aes256_encrypt_byte", bench_AES256_encrypt, bench_AES256_encrypt_setup, NULL, &ctx256, 20, 4000000);
168 run_benchmark(
"aes256_decrypt_byte", bench_AES256_decrypt, bench_AES256_encrypt_setup, NULL, &ctx256, 20, 4000000);
void AES256_init(AES256_ctx *ctx, const unsigned char *key32)
void AES128_encrypt(const AES128_ctx *ctx, size_t blocks, unsigned char *cipher16, const unsigned char *plain16)
void AES192_encrypt(const AES192_ctx *ctx, size_t blocks, unsigned char *cipher16, const unsigned char *plain16)
void AES256_encrypt(const AES256_ctx *ctx, size_t blocks, unsigned char *cipher16, const unsigned char *plain16)
void AES128_decrypt(const AES128_ctx *ctx, size_t blocks, unsigned char *plain16, const unsigned char *cipher16)
void AES256_decrypt(const AES256_ctx *ctx, size_t blocks, unsigned char *plain16, const unsigned char *cipher16)
void run_benchmark(char *name, void(*benchmark)(void *), void(*setup)(void *), void(*teardown)(void *), void *data, int count, int iter)
void print_number(double x)
void AES128_init(AES128_ctx *ctx, const unsigned char *key16)
void AES192_init(AES192_ctx *ctx, const unsigned char *key24)
void AES192_decrypt(const AES192_ctx *ctx, size_t blocks, unsigned char *plain16, const unsigned char *cipher16)