forked from wolfgangmauerer/libtrevisan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
primitives.cc
77 lines (64 loc) · 1.37 KB
/
primitives.cc
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<iostream>
#include "primitives.h"
using namespace std;
// Conversion routines between bit extractor/weak design constants and
// textual descriptions
wd_type get_weakdes(const string &wd) {
if (wd == "gf2x")
return wd_type::GF2X;
if (wd == "gfp")
return wd_type::GFP;
if (wd == "block")
return wd_type::BLOCK;
if (wd == "aot")
return wd_type::AOT;
cerr << "Please specify a valid weak design construction!" << endl;
exit(-1);
}
bext_type get_bitext(const string &bx) {
if (bx == "xor")
return bext_type::XOR;
if (bx == "lu")
return bext_type::LU;
if (bx == "rsh")
return bext_type::RSH;
cerr << "Please specify a valid bit extractor construction!" << endl;
exit(-1);
}
string bitext_to_string(bext_type bext) {
switch (bext) {
case bext_type::XOR:
return "XOR";
break;
case bext_type::LU:
return "Lu";
break;
case bext_type::RSH:
return "Reed-Solomon-Hadamard";
break;
default:
// Duh?!
cerr << "Internal error: Unknown bit extractor specified" << endl;
exit(-1);
}
}
string weakdes_to_string(wd_type wdt) {
switch (wdt) {
case wd_type::GF2X:
return "GF(2^m)";
break;
case wd_type::GFP:
return "GF(p)";
break;
case wd_type::BLOCK:
return "Block";
break;
case wd_type::AOT:
return "Ahead of time";
break;
default:
// Duh?!
cerr << "Internal error: Unknown weak design specified" << endl;
exit(-1);
}
}