PIR/lib/test_chiffrement.c

34 lines
624 B
C

#include "rondoudouPatch.h"
#include <stdio.h>
#include <time.h>
int h(int a) {
cipher(__builtin_return_address(0));
if (a > 0) {
int ret = h(a - 1);
decipher();
return ret;
}
decipher();
return 5;
}
char *ebp;
char *esp;
int main() {
struct timespec start, end;
clock_gettime(CLOCK_MONOTONIC, &start);
rondoudou_patch_init();
cipher(__builtin_return_address(0));
for (int i = 0; i < 1000; ++i) {
h(25);
}
decipher();
clock_gettime(CLOCK_MONOTONIC, &end);
unsigned long ns = (end.tv_sec - start.tv_sec) * 1000000000ul + end.tv_nsec - start.tv_nsec;
printf("%.3lfμs\n", (double) ns / 1000.0);
}