Coverage Report

Created: 2022-08-24 06:31

/src/cryptofuzz/repository.cpp
Line
Count
Source (jump to first uncovered line)
1
#include <fuzzing/datasource/id.hpp>
2
#include <cryptofuzz/repository.h>
3
#include <map>
4
#include <cstdint>
5
#include <string>
6
#include "repository_map.h"
7
8
namespace cryptofuzz {
9
namespace repository {
10
11
0
bool IsCBC(const uint64_t id) {
12
0
    try {
13
0
        return CipherLUTMap.at(id).CBC;
14
0
    } catch ( std::out_of_range ) {
15
0
        return false;
16
0
    }
17
0
}
18
19
6.48k
bool IsCCM(const uint64_t id) {
20
6.48k
    try {
21
6.48k
        return CipherLUTMap.at(id).CCM;
22
6.48k
    } catch ( std::out_of_range ) {
23
0
        return false;
24
0
    }
25
6.48k
}
26
27
0
bool IsCFB(const uint64_t id) {
28
0
    try {
29
0
        return CipherLUTMap.at(id).CFB;
30
0
    } catch ( std::out_of_range ) {
31
0
        return false;
32
0
    }
33
0
}
34
35
0
bool IsCTR(const uint64_t id) {
36
0
    try {
37
0
        return CipherLUTMap.at(id).CTR;
38
0
    } catch ( std::out_of_range ) {
39
0
        return false;
40
0
    }
41
0
}
42
43
2.97k
bool IsECB(const uint64_t id) {
44
2.97k
    try {
45
2.97k
        return CipherLUTMap.at(id).ECB;
46
2.97k
    } catch ( std::out_of_range ) {
47
0
        return false;
48
0
    }
49
2.97k
}
50
51
304
bool IsGCM(const uint64_t id) {
52
304
    try {
53
304
        return CipherLUTMap.at(id).GCM;
54
304
    } catch ( std::out_of_range ) {
55
0
        return false;
56
0
    }
57
304
}
58
59
0
bool IsOCB(const uint64_t id) {
60
0
    try {
61
0
        return CipherLUTMap.at(id).OCB;
62
0
    } catch ( std::out_of_range ) {
63
0
        return false;
64
0
    }
65
0
}
66
67
0
bool IsOFB(const uint64_t id) {
68
0
    try {
69
0
        return CipherLUTMap.at(id).OFB;
70
0
    } catch ( std::out_of_range ) {
71
0
        return false;
72
0
    }
73
0
}
74
75
3.14k
bool IsXTS(const uint64_t id) {
76
3.14k
    try {
77
3.14k
        return CipherLUTMap.at(id).XTS;
78
3.14k
    } catch ( std::out_of_range ) {
79
0
        return false;
80
0
    }
81
3.14k
}
82
83
0
bool IsAEAD(const uint64_t id) {
84
0
    try {
85
0
        return CipherLUTMap.at(id).AEAD;
86
0
    } catch ( std::out_of_range ) {
87
0
        return false;
88
0
    }
89
0
}
90
91
28.1k
bool IsWRAP(const uint64_t id) {
92
28.1k
    try {
93
28.1k
        return CipherLUTMap.at(id).WRAP;
94
28.1k
    } catch ( std::out_of_range ) {
95
0
        return false;
96
0
    }
97
28.1k
}
98
99
0
bool IsAES(const uint64_t id) {
100
0
    try {
101
0
        return CipherLUTMap.at(id).AES;
102
0
    } catch ( std::out_of_range ) {
103
0
        return false;
104
0
    }
105
0
}
106
107
0
std::string DigestToString(const uint64_t id) {
108
0
    try {
109
0
        return DigestLUTMap.at(id).name;
110
0
    } catch ( std::out_of_range ) {
111
0
        return "(unknown)";
112
0
    }
113
0
}
114
115
0
std::optional<uint64_t> DigestFromString(const std::string& s) {
116
0
    for (const auto& curve : DigestLUTMap) {
117
0
        if ( s == curve.second.name ) {
118
0
            return curve.first;
119
0
        }
120
0
    }
121
122
0
    return std::nullopt;
123
0
}
124
125
0
std::string CipherToString(const uint64_t id) {
126
0
    try {
127
0
        return CipherLUTMap.at(id).name;
128
0
    } catch ( std::out_of_range ) {
129
0
        return "(unknown)";
130
0
    }
131
0
}
132
133
0
std::string ECC_CurveToString(const uint64_t id) {
134
0
    try {
135
0
        return ECC_CurveLUTMap.at(id).name;
136
0
    } catch ( std::out_of_range ) {
137
0
        return "(unknown)";
138
0
    }
139
0
}
140
141
0
std::optional<uint64_t> ECC_CurveFromString(const std::string& s) {
142
0
    for (const auto& curve : ECC_CurveLUTMap) {
143
0
        if ( s == curve.second.name ) {
144
0
            return curve.first;
145
0
        }
146
0
    }
147
148
0
    return std::nullopt;
149
0
}
150
151
853
std::optional<size_t> ECC_CurveToBits(const uint64_t id) {
152
853
    try {
153
853
        return ECC_CurveLUTMap.at(id).bits;
154
853
    } catch ( std::out_of_range ) {
155
0
        return std::nullopt;
156
0
    }
157
853
}
158
159
0
std::optional<std::string> ECC_CurveToPrime(const uint64_t id) {
160
0
    try {
161
0
        return ECC_CurveLUTMap.at(id).prime;
162
0
    } catch ( std::out_of_range ) {
163
0
        return std::nullopt;
164
0
    }
165
0
}
166
167
0
std::optional<std::string> ECC_CurveToA(const uint64_t id) {
168
0
    try {
169
0
        return ECC_CurveLUTMap.at(id).a;
170
0
    } catch ( std::out_of_range ) {
171
0
        return std::nullopt;
172
0
    }
173
0
}
174
175
0
std::optional<std::string> ECC_CurveToB(const uint64_t id) {
176
0
    try {
177
0
        return ECC_CurveLUTMap.at(id).b;
178
0
    } catch ( std::out_of_range ) {
179
0
        return std::nullopt;
180
0
    }
181
0
}
182
183
0
std::optional<std::string> ECC_CurveToX(const uint64_t id) {
184
0
    try {
185
0
        return ECC_CurveLUTMap.at(id).x;
186
0
    } catch ( std::out_of_range ) {
187
0
        return std::nullopt;
188
0
    }
189
0
}
190
191
0
std::optional<std::string> ECC_CurveToY(const uint64_t id) {
192
0
    try {
193
0
        return ECC_CurveLUTMap.at(id).y;
194
0
    } catch ( std::out_of_range ) {
195
0
        return std::nullopt;
196
0
    }
197
0
}
198
199
0
std::optional<std::string> ECC_CurveToOrderMin1(const uint64_t id) {
200
0
    try {
201
0
        return ECC_CurveLUTMap.at(id).order_min_1;
202
0
    } catch ( std::out_of_range ) {
203
0
        return std::nullopt;
204
0
    }
205
0
}
206
207
436
std::optional<std::string> ECC_CurveToOrder(const uint64_t id) {
208
436
    try {
209
436
        return ECC_CurveLUTMap.at(id).order;
210
436
    } catch ( std::out_of_range ) {
211
0
        return std::nullopt;
212
0
    }
213
436
}
214
215
139
std::string CalcOpToString(const uint64_t id) {
216
139
    try {
217
139
        return CalcOpLUTMap.at(id).name;
218
139
    } catch ( std::out_of_range ) {
219
0
        return "(unknown)";
220
0
    }
221
139
}
222
0
size_t CalcOpToNumParams(const uint64_t id) {
223
0
    try {
224
0
        return CalcOpLUTMap.at(id).num_params;
225
0
    } catch ( std::out_of_range ) {
226
0
        ::abort();
227
0
    }
228
0
}
229
230
2.77k
std::optional<size_t> DigestSize(const uint64_t id) {
231
2.77k
    try {
232
2.77k
        return DigestLUTMap.at(id).size;
233
2.77k
    } catch ( std::out_of_range ) {
234
0
        return std::nullopt;
235
0
    }
236
2.77k
}
237
238
} /* namespace repository */
239
} /* namespace cryptofuzz */