-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtest.c
52 lines (45 loc) · 1006 Bytes
/
test.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
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdio.h>
#include <stdlib.h>
#include "matrix.h"
#include "qc_mdpc.h"
#include "mceliece.h"
#include <time.h>
#include "utility.h"
int main(int argc, char const *argv[])
{
// int n0 = 2;
// int t = 84;
// int p = 4801;
// int w = 90;
int n0 = 2;
int t = 20;
int p = 1000;
int w = 45;
printf("Starting Encryption...\n");
clock_t start, end;
double cpu_time_used;
start = clock();
mcc crypt = mceliece_init(n0, p, w, t);
bin_matrix msg = mat_init(1, crypt->code->k);
//Initializing the message a random message
for(int i = 0; i < crypt->code->k; i++)
{
int z = rand() % 2;
set_matrix_element(msg, 0, i, z);
}
bin_matrix v = encrypt(msg, crypt);
bin_matrix s = decrypt(v, crypt);
if(mat_is_equal(msg, s))
{
end = clock();
printf("Decryption successful...\n");
cpu_time_used = ((double) (end - start))/ CLOCKS_PER_SEC;
printf("Time taken by cryptosystem: %f\n", cpu_time_used);
}
else
{
printf("Failure....\n");
}
delete_mceliece(crypt);
return 0;
}