-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtfetest.c
40 lines (32 loc) · 811 Bytes
/
tfetest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include "tfdef.h"
#include "tfe.h"
#include "tfsupport.h"
static uint64_t encbytes;
static char key[TF_KEY_SIZE] = "\a\x76syR_\x98?";
static char data[DATASIZE];
static struct tfe_stream tfe;
static unsigned do_break;
static void do_stop_sig(int unused)
{
do_break = 1;
}
int main(void)
{
tfe_init(&tfe, key);
printf("Doing stream encryption loop for next %u seconds...\n", TESTTIME);
signal(SIGALRM, do_stop_sig);
alarm(TESTTIME);
while (1) {
if (do_break) break;
tfe_emit(data, sizeof(data), &tfe);
encbytes += sizeof(data);
}
tfe_emit(NULL, 0, &tfe);
printf("Done. Stats: encrypted: %llu, byps: %llu\n", encbytes, encbytes / TESTTIME);
puts("Threefish stream cipher testing program done.");
return 0;
}