/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  | 0  | bool IsCCM(const uint64_t id) { | 
20  | 0  |     try { | 
21  | 0  |         return CipherLUTMap.at(id).CCM;  | 
22  | 0  |     } catch ( std::out_of_range& ) { | 
23  | 0  |         return false;  | 
24  | 0  |     }  | 
25  | 0  | }  | 
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  | 0  | bool IsECB(const uint64_t id) { | 
44  | 0  |     try { | 
45  | 0  |         return CipherLUTMap.at(id).ECB;  | 
46  | 0  |     } catch ( std::out_of_range& ) { | 
47  | 0  |         return false;  | 
48  | 0  |     }  | 
49  | 0  | }  | 
50  |  |  | 
51  | 0  | bool IsGCM(const uint64_t id) { | 
52  | 0  |     try { | 
53  | 0  |         return CipherLUTMap.at(id).GCM;  | 
54  | 0  |     } catch ( std::out_of_range& ) { | 
55  | 0  |         return false;  | 
56  | 0  |     }  | 
57  | 0  | }  | 
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  | 0  | bool IsXTS(const uint64_t id) { | 
76  | 0  |     try { | 
77  | 0  |         return CipherLUTMap.at(id).XTS;  | 
78  | 0  |     } catch ( std::out_of_range& ) { | 
79  | 0  |         return false;  | 
80  | 0  |     }  | 
81  | 0  | }  | 
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  | 0  | bool IsWRAP(const uint64_t id) { | 
92  | 0  |     try { | 
93  | 0  |         return CipherLUTMap.at(id).WRAP;  | 
94  | 0  |     } catch ( std::out_of_range& ) { | 
95  | 0  |         return false;  | 
96  | 0  |     }  | 
97  | 0  | }  | 
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  | 0  | std::optional<size_t> ECC_CurveToBits(const uint64_t id) { | 
152  | 0  |     try { | 
153  | 0  |         return ECC_CurveLUTMap.at(id).bits;  | 
154  | 0  |     } catch ( std::out_of_range& ) { | 
155  | 0  |         return std::nullopt;  | 
156  | 0  |     }  | 
157  | 0  | }  | 
158  |  |  | 
159  | 11.1k  | std::optional<std::string> ECC_CurveToPrime(const uint64_t id) { | 
160  | 11.1k  |     try { | 
161  | 11.1k  |         return ECC_CurveLUTMap.at(id).prime;  | 
162  | 11.1k  |     } catch ( std::out_of_range& ) { | 
163  | 0  |         return std::nullopt;  | 
164  | 0  |     }  | 
165  | 11.1k  | }  | 
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  | 0  | std::optional<std::string> ECC_CurveToOrder(const uint64_t id) { | 
208  | 0  |     try { | 
209  | 0  |         return ECC_CurveLUTMap.at(id).order;  | 
210  | 0  |     } catch ( std::out_of_range& ) { | 
211  | 0  |         return std::nullopt;  | 
212  | 0  |     }  | 
213  | 0  | }  | 
214  |  |  | 
215  | 3.06k  | std::string CalcOpToString(const uint64_t id) { | 
216  | 3.06k  |     try { | 
217  | 3.06k  |         return CalcOpLUTMap.at(id).name;  | 
218  | 3.06k  |     } catch ( std::out_of_range& ) { | 
219  | 0  |         return "(unknown)";  | 
220  | 0  |     }  | 
221  | 3.06k  | }  | 
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  |         return 0;  | 
227  | 0  |     }  | 
228  | 0  | }  | 
229  |  |  | 
230  | 222  | std::optional<size_t> DigestSize(const uint64_t id) { | 
231  | 222  |     try { | 
232  | 222  |         return DigestLUTMap.at(id).size;  | 
233  | 222  |     } catch ( std::out_of_range& ) { | 
234  | 0  |         return std::nullopt;  | 
235  | 0  |     }  | 
236  | 222  | }  | 
237  |  |  | 
238  |  | } /* namespace repository */  | 
239  |  | } /* namespace cryptofuzz */  |