/src/cryptofuzz-openssl-api/modules/wolfcrypt-openssl/module_internal.h
Line | Count | Source (jump to first uncovered line) |
1 | | #pragma once |
2 | | |
3 | | namespace cryptofuzz { |
4 | | namespace module { |
5 | | |
6 | | template <class T> |
7 | | class CTX_Copier { |
8 | | private: |
9 | | T* ctx = nullptr; |
10 | | Datasource& ds; |
11 | | |
12 | | T* newCTX(void) const; |
13 | | int copyCTX(T* dest, T* src) const; |
14 | | void freeCTX(T* ctx) const; |
15 | | |
16 | 108k | T* copy(void) { |
17 | 108k | return ctx; |
18 | 0 | bool doCopyCTX = true; |
19 | 0 | try { |
20 | 0 | doCopyCTX = ds.Get<bool>(); |
21 | 0 | } catch ( fuzzing::datasource::Datasource::OutOfData ) { } |
22 | |
|
23 | 0 | if ( doCopyCTX == true ) { |
24 | 0 | T* tmpCtx = newCTX(); |
25 | 0 | if ( tmpCtx != nullptr ) { |
26 | 0 | if ( copyCTX(tmpCtx, ctx) == 1 ) { |
27 | | /* Copy succeeded, free the old ctx */ |
28 | 0 | freeCTX(ctx); |
29 | | |
30 | | /* Use the copied ctx */ |
31 | 0 | ctx = tmpCtx; |
32 | 0 | } else { |
33 | 0 | freeCTX(tmpCtx); |
34 | 0 | } |
35 | 0 | } |
36 | 0 | } |
37 | |
|
38 | 0 | return ctx; |
39 | 0 | } cryptofuzz::module::CTX_Copier<WOLFSSL_EVP_MD_CTX>::copy() Line | Count | Source | 16 | 33.8k | T* copy(void) { | 17 | 33.8k | return ctx; | 18 | 0 | bool doCopyCTX = true; | 19 | 0 | try { | 20 | 0 | doCopyCTX = ds.Get<bool>(); | 21 | 0 | } catch ( fuzzing::datasource::Datasource::OutOfData ) { } | 22 | |
| 23 | 0 | if ( doCopyCTX == true ) { | 24 | 0 | T* tmpCtx = newCTX(); | 25 | 0 | if ( tmpCtx != nullptr ) { | 26 | 0 | if ( copyCTX(tmpCtx, ctx) == 1 ) { | 27 | | /* Copy succeeded, free the old ctx */ | 28 | 0 | freeCTX(ctx); | 29 | | | 30 | | /* Use the copied ctx */ | 31 | 0 | ctx = tmpCtx; | 32 | 0 | } else { | 33 | 0 | freeCTX(tmpCtx); | 34 | 0 | } | 35 | 0 | } | 36 | 0 | } | 37 | |
| 38 | 0 | return ctx; | 39 | 0 | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_HMAC_CTX>::copy() Line | Count | Source | 16 | 4.15k | T* copy(void) { | 17 | 4.15k | return ctx; | 18 | 0 | bool doCopyCTX = true; | 19 | 0 | try { | 20 | 0 | doCopyCTX = ds.Get<bool>(); | 21 | 0 | } catch ( fuzzing::datasource::Datasource::OutOfData ) { } | 22 | |
| 23 | 0 | if ( doCopyCTX == true ) { | 24 | 0 | T* tmpCtx = newCTX(); | 25 | 0 | if ( tmpCtx != nullptr ) { | 26 | 0 | if ( copyCTX(tmpCtx, ctx) == 1 ) { | 27 | | /* Copy succeeded, free the old ctx */ | 28 | 0 | freeCTX(ctx); | 29 | | | 30 | | /* Use the copied ctx */ | 31 | 0 | ctx = tmpCtx; | 32 | 0 | } else { | 33 | 0 | freeCTX(tmpCtx); | 34 | 0 | } | 35 | 0 | } | 36 | 0 | } | 37 | |
| 38 | 0 | return ctx; | 39 | 0 | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_EVP_CIPHER_CTX>::copy() Line | Count | Source | 16 | 60.7k | T* copy(void) { | 17 | 60.7k | return ctx; | 18 | 0 | bool doCopyCTX = true; | 19 | 0 | try { | 20 | 0 | doCopyCTX = ds.Get<bool>(); | 21 | 0 | } catch ( fuzzing::datasource::Datasource::OutOfData ) { } | 22 | |
| 23 | 0 | if ( doCopyCTX == true ) { | 24 | 0 | T* tmpCtx = newCTX(); | 25 | 0 | if ( tmpCtx != nullptr ) { | 26 | 0 | if ( copyCTX(tmpCtx, ctx) == 1 ) { | 27 | | /* Copy succeeded, free the old ctx */ | 28 | 0 | freeCTX(ctx); | 29 | | | 30 | | /* Use the copied ctx */ | 31 | 0 | ctx = tmpCtx; | 32 | 0 | } else { | 33 | 0 | freeCTX(tmpCtx); | 34 | 0 | } | 35 | 0 | } | 36 | 0 | } | 37 | |
| 38 | 0 | return ctx; | 39 | 0 | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_CMAC_CTX>::copy() Line | Count | Source | 16 | 2.06k | T* copy(void) { | 17 | 2.06k | return ctx; | 18 | 0 | bool doCopyCTX = true; | 19 | 0 | try { | 20 | 0 | doCopyCTX = ds.Get<bool>(); | 21 | 0 | } catch ( fuzzing::datasource::Datasource::OutOfData ) { } | 22 | |
| 23 | 0 | if ( doCopyCTX == true ) { | 24 | 0 | T* tmpCtx = newCTX(); | 25 | 0 | if ( tmpCtx != nullptr ) { | 26 | 0 | if ( copyCTX(tmpCtx, ctx) == 1 ) { | 27 | | /* Copy succeeded, free the old ctx */ | 28 | 0 | freeCTX(ctx); | 29 | | | 30 | | /* Use the copied ctx */ | 31 | 0 | ctx = tmpCtx; | 32 | 0 | } else { | 33 | 0 | freeCTX(tmpCtx); | 34 | 0 | } | 35 | 0 | } | 36 | 0 | } | 37 | |
| 38 | 0 | return ctx; | 39 | 0 | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_EC_KEY>::copy() Line | Count | Source | 16 | 7.23k | T* copy(void) { | 17 | 7.23k | return ctx; | 18 | 0 | bool doCopyCTX = true; | 19 | 0 | try { | 20 | 0 | doCopyCTX = ds.Get<bool>(); | 21 | 0 | } catch ( fuzzing::datasource::Datasource::OutOfData ) { } | 22 | |
| 23 | 0 | if ( doCopyCTX == true ) { | 24 | 0 | T* tmpCtx = newCTX(); | 25 | 0 | if ( tmpCtx != nullptr ) { | 26 | 0 | if ( copyCTX(tmpCtx, ctx) == 1 ) { | 27 | | /* Copy succeeded, free the old ctx */ | 28 | 0 | freeCTX(ctx); | 29 | | | 30 | | /* Use the copied ctx */ | 31 | 0 | ctx = tmpCtx; | 32 | 0 | } else { | 33 | 0 | freeCTX(tmpCtx); | 34 | 0 | } | 35 | 0 | } | 36 | 0 | } | 37 | |
| 38 | 0 | return ctx; | 39 | 0 | } |
|
40 | | |
41 | | public: |
42 | | CTX_Copier(Datasource& ds) : |
43 | 10.9k | ds(ds) { |
44 | 10.9k | ctx = newCTX(); |
45 | 10.9k | if ( ctx == nullptr ) { |
46 | 0 | abort(); |
47 | 0 | } |
48 | 10.9k | } cryptofuzz::module::CTX_Copier<WOLFSSL_EVP_MD_CTX>::CTX_Copier(fuzzing::datasource::Datasource&) Line | Count | Source | 43 | 1.63k | ds(ds) { | 44 | 1.63k | ctx = newCTX(); | 45 | 1.63k | if ( ctx == nullptr ) { | 46 | 0 | abort(); | 47 | 0 | } | 48 | 1.63k | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_HMAC_CTX>::CTX_Copier(fuzzing::datasource::Datasource&) Line | Count | Source | 43 | 136 | ds(ds) { | 44 | 136 | ctx = newCTX(); | 45 | 136 | if ( ctx == nullptr ) { | 46 | 0 | abort(); | 47 | 0 | } | 48 | 136 | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_EVP_CIPHER_CTX>::CTX_Copier(fuzzing::datasource::Datasource&) Line | Count | Source | 43 | 5.13k | ds(ds) { | 44 | 5.13k | ctx = newCTX(); | 45 | 5.13k | if ( ctx == nullptr ) { | 46 | 0 | abort(); | 47 | 0 | } | 48 | 5.13k | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_CMAC_CTX>::CTX_Copier(fuzzing::datasource::Datasource&) Line | Count | Source | 43 | 702 | ds(ds) { | 44 | 702 | ctx = newCTX(); | 45 | 702 | if ( ctx == nullptr ) { | 46 | 0 | abort(); | 47 | 0 | } | 48 | 702 | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_EC_KEY>::CTX_Copier(fuzzing::datasource::Datasource&) Line | Count | Source | 43 | 3.31k | ds(ds) { | 44 | 3.31k | ctx = newCTX(); | 45 | 3.31k | if ( ctx == nullptr ) { | 46 | 0 | abort(); | 47 | 0 | } | 48 | 3.31k | } |
|
49 | | |
50 | 108k | T* GetPtr(void) { |
51 | 108k | return copy(); |
52 | 108k | } cryptofuzz::module::CTX_Copier<WOLFSSL_EVP_MD_CTX>::GetPtr() Line | Count | Source | 50 | 33.8k | T* GetPtr(void) { | 51 | 33.8k | return copy(); | 52 | 33.8k | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_HMAC_CTX>::GetPtr() Line | Count | Source | 50 | 4.15k | T* GetPtr(void) { | 51 | 4.15k | return copy(); | 52 | 4.15k | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_EVP_CIPHER_CTX>::GetPtr() Line | Count | Source | 50 | 60.7k | T* GetPtr(void) { | 51 | 60.7k | return copy(); | 52 | 60.7k | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_CMAC_CTX>::GetPtr() Line | Count | Source | 50 | 2.06k | T* GetPtr(void) { | 51 | 2.06k | return copy(); | 52 | 2.06k | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_EC_KEY>::GetPtr() Line | Count | Source | 50 | 7.23k | T* GetPtr(void) { | 51 | 7.23k | return copy(); | 52 | 7.23k | } |
|
53 | | |
54 | 10.9k | ~CTX_Copier() { |
55 | 10.9k | freeCTX(ctx); |
56 | 10.9k | } cryptofuzz::module::CTX_Copier<WOLFSSL_EVP_MD_CTX>::~CTX_Copier() Line | Count | Source | 54 | 1.63k | ~CTX_Copier() { | 55 | 1.63k | freeCTX(ctx); | 56 | 1.63k | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_HMAC_CTX>::~CTX_Copier() Line | Count | Source | 54 | 136 | ~CTX_Copier() { | 55 | 136 | freeCTX(ctx); | 56 | 136 | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_EVP_CIPHER_CTX>::~CTX_Copier() Line | Count | Source | 54 | 5.13k | ~CTX_Copier() { | 55 | 5.13k | freeCTX(ctx); | 56 | 5.13k | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_CMAC_CTX>::~CTX_Copier() Line | Count | Source | 54 | 702 | ~CTX_Copier() { | 55 | 702 | freeCTX(ctx); | 56 | 702 | } |
cryptofuzz::module::CTX_Copier<WOLFSSL_EC_KEY>::~CTX_Copier() Line | Count | Source | 54 | 3.31k | ~CTX_Copier() { | 55 | 3.31k | freeCTX(ctx); | 56 | 3.31k | } |
|
57 | | }; |
58 | | |
59 | | class EC_GROUP_Copier { |
60 | | private: |
61 | | bool locked = false; |
62 | | const int curveNID; |
63 | | EC_GROUP* group = nullptr; |
64 | | Datasource& ds; |
65 | | |
66 | 3.61k | EC_GROUP* newGroup(void) { |
67 | 3.61k | return EC_GROUP_new_by_curve_name(curveNID); |
68 | 3.61k | } |
69 | | |
70 | | #if !defined(CRYPTOFUZZ_BORINGSSL) && !defined(CRYPTOFUZZ_WOLFCRYPT_OPENSSL) |
71 | | int copyGroup(EC_GROUP* dest, EC_GROUP* src) { |
72 | | return EC_GROUP_copy(dest, src); |
73 | | } |
74 | | #endif |
75 | 3.61k | void freeGroup(EC_GROUP* group) { |
76 | 3.61k | /* noret */ EC_GROUP_free(group); |
77 | 3.61k | } |
78 | | |
79 | 0 | EC_GROUP* copy(void) { |
80 | 0 | bool doCopyGroup = true; |
81 | 0 | try { |
82 | 0 | doCopyGroup = ds.Get<bool>(); |
83 | 0 | } catch ( fuzzing::datasource::Datasource::OutOfData ) { } |
84 | |
|
85 | 0 | if ( doCopyGroup == true ) { |
86 | | #if !defined(CRYPTOFUZZ_BORINGSSL) && !defined(CRYPTOFUZZ_WOLFCRYPT_OPENSSL) |
87 | | EC_GROUP* tmpGroup = newGroup(); |
88 | | if ( tmpGroup != nullptr ) { |
89 | | if ( copyGroup(tmpGroup, group) == 1 ) { |
90 | | /* Copy succeeded, free the old group */ |
91 | | freeGroup(group); |
92 | | |
93 | | /* Use the copied group */ |
94 | | group = tmpGroup; |
95 | | } else { |
96 | | freeGroup(tmpGroup); |
97 | | } |
98 | | } |
99 | | #endif |
100 | 0 | } |
101 | |
|
102 | 0 | return group; |
103 | 0 | } |
104 | | |
105 | | public: |
106 | | EC_GROUP_Copier(Datasource& ds, const int curveNID) : |
107 | 3.61k | curveNID(curveNID), ds(ds) { |
108 | 3.61k | group = newGroup(); |
109 | 3.61k | } |
110 | | |
111 | 3.61k | void Lock(void) { |
112 | 3.61k | locked = true; |
113 | 3.61k | } |
114 | | |
115 | 22.5k | EC_GROUP* GetPtr(void) { |
116 | 22.5k | if ( locked == true ) { |
117 | 22.5k | return group; |
118 | 22.5k | } else { |
119 | 0 | return copy(); |
120 | 0 | } |
121 | 22.5k | } |
122 | | |
123 | 3.61k | ~EC_GROUP_Copier() { |
124 | 3.61k | freeGroup(group); |
125 | 3.61k | } |
126 | | }; |
127 | | |
128 | | class EC_POINT_Copier { |
129 | | private: |
130 | | std::shared_ptr<EC_GROUP_Copier> group; |
131 | | EC_POINT* point = nullptr; |
132 | | Datasource& ds; |
133 | | |
134 | 10.2k | EC_POINT* newPoint(void) { |
135 | 10.2k | return EC_POINT_new(group->GetPtr()); |
136 | 10.2k | } |
137 | | |
138 | 6.40k | int copyPoint(EC_POINT* dest, EC_POINT* src) { |
139 | 6.40k | return EC_POINT_copy(dest, src); |
140 | 6.40k | } |
141 | 10.2k | void freePoint(EC_POINT* point) { |
142 | 10.2k | /* noret */ EC_POINT_free(point); |
143 | 10.2k | } |
144 | | |
145 | 7.13k | EC_POINT* copy(void) { |
146 | 7.13k | bool doCopyPoint = true; |
147 | 7.13k | try { |
148 | 7.13k | doCopyPoint = ds.Get<bool>(); |
149 | 7.13k | } catch ( fuzzing::datasource::Datasource::OutOfData ) { } |
150 | | |
151 | 7.13k | if ( doCopyPoint == true ) { |
152 | 6.40k | EC_POINT* tmpPoint = newPoint(); |
153 | 6.40k | if ( tmpPoint != nullptr ) { |
154 | 6.40k | if ( copyPoint(tmpPoint, point) == 1 ) { |
155 | | /* Copy succeeded, free the old point */ |
156 | 6.40k | freePoint(point); |
157 | | |
158 | | /* Use the copied point */ |
159 | 6.40k | point = tmpPoint; |
160 | 6.40k | } else { |
161 | 0 | freePoint(tmpPoint); |
162 | 0 | } |
163 | 6.40k | } |
164 | 6.40k | } |
165 | | |
166 | 7.13k | return point; |
167 | 7.13k | } |
168 | | |
169 | 2.07k | bool set(OpenSSL_bignum::Bignum& pub_x, OpenSSL_bignum::Bignum& pub_y) { |
170 | 2.07k | bool ret = false; |
171 | | |
172 | 2.07k | CF_CHECK_NE(EC_POINT_set_affine_coordinates(group->GetPtr(), GetPtr(), pub_x.GetPtr(), pub_y.GetPtr(), nullptr), 0); |
173 | | |
174 | 1.50k | ret = true; |
175 | 2.07k | end: |
176 | 2.07k | return ret; |
177 | 1.50k | } |
178 | | |
179 | | public: |
180 | | EC_POINT_Copier(Datasource& ds, std::shared_ptr<EC_GROUP_Copier> group) : |
181 | 3.86k | group(group), ds(ds) { |
182 | 3.86k | point = newPoint(); |
183 | 3.86k | if ( point == nullptr ) { |
184 | 0 | abort(); |
185 | 0 | } |
186 | 3.86k | } |
187 | | |
188 | 2.07k | bool Set(OpenSSL_bignum::Bignum& pub_x, OpenSSL_bignum::Bignum& pub_y) { |
189 | 2.07k | return set(pub_x, pub_y); |
190 | 2.07k | } |
191 | | |
192 | 2.12k | bool Set(const component::Bignum& pub_x, const component::Bignum& pub_y) { |
193 | 2.12k | bool ret = false; |
194 | | |
195 | 2.12k | OpenSSL_bignum::Bignum _pub_x(ds), _pub_y(ds); |
196 | | |
197 | 2.12k | CF_CHECK_EQ(_pub_x.Set(pub_x.ToString(ds)), true); |
198 | 2.09k | CF_CHECK_EQ(_pub_y.Set(pub_y.ToString(ds)), true); |
199 | | |
200 | 2.07k | CF_CHECK_TRUE(Set(_pub_x, _pub_y)); |
201 | | |
202 | 1.50k | ret = true; |
203 | 2.12k | end: |
204 | 2.12k | return ret; |
205 | 1.50k | } |
206 | | |
207 | 147 | bool Get(OpenSSL_bignum::Bignum& pub_x, OpenSSL_bignum::Bignum& pub_y) { |
208 | 147 | bool ret = false; |
209 | | |
210 | 147 | CF_CHECK_NE(EC_POINT_get_affine_coordinates(group->GetPtr(), GetPtr(), pub_x.GetDestPtr(), pub_y.GetDestPtr(), nullptr), 0); |
211 | | |
212 | 134 | ret = true; |
213 | 147 | end: |
214 | 147 | return ret; |
215 | 134 | } |
216 | | |
217 | 147 | std::optional<component::ECC_Point> Get(void) { |
218 | 147 | std::optional<component::ECC_Point> ret = std::nullopt; |
219 | | |
220 | 147 | char* x_str = nullptr; |
221 | 147 | char* y_str = nullptr; |
222 | | |
223 | 147 | OpenSSL_bignum::Bignum x(ds); |
224 | 147 | OpenSSL_bignum::Bignum y(ds); |
225 | | |
226 | 147 | CF_CHECK_EQ(x.New(), true); |
227 | 147 | CF_CHECK_EQ(y.New(), true); |
228 | | |
229 | 147 | CF_CHECK_TRUE(Get(x, y)); |
230 | | |
231 | 134 | CF_CHECK_NE(x_str = BN_bn2dec(x.GetPtr()), nullptr); |
232 | 134 | CF_CHECK_NE(y_str = BN_bn2dec(y.GetPtr()), nullptr); |
233 | | |
234 | 134 | ret = { std::string(x_str), std::string(y_str) }; |
235 | | |
236 | 147 | end: |
237 | 147 | OPENSSL_free(x_str); |
238 | 147 | OPENSSL_free(y_str); |
239 | | |
240 | 147 | return ret; |
241 | 134 | } |
242 | | |
243 | 7.13k | EC_POINT* GetPtr(void) { |
244 | 7.13k | return copy(); |
245 | 7.13k | } |
246 | | |
247 | 3.86k | ~EC_POINT_Copier() { |
248 | 3.86k | freePoint(point); |
249 | 3.86k | } |
250 | | }; |
251 | | |
252 | | #if !defined(CRYPTOFUZZ_OPENSSL_102) |
253 | 1.63k | template<> EVP_MD_CTX* CTX_Copier<EVP_MD_CTX>::newCTX(void) const { return EVP_MD_CTX_new(); } |
254 | | #else |
255 | | template<> EVP_MD_CTX* CTX_Copier<EVP_MD_CTX>::newCTX(void) const { |
256 | | EVP_MD_CTX* ret = (EVP_MD_CTX*)malloc(sizeof(*ret)); |
257 | | EVP_MD_CTX_init(ret); |
258 | | return ret; |
259 | | } |
260 | | #endif |
261 | | |
262 | 0 | template<> int CTX_Copier<EVP_MD_CTX>::copyCTX(EVP_MD_CTX* dest, EVP_MD_CTX* src) const { return EVP_MD_CTX_copy(dest, src); } |
263 | | |
264 | | #if !defined(CRYPTOFUZZ_OPENSSL_102) |
265 | 1.63k | template<> void CTX_Copier<EVP_MD_CTX>::freeCTX(EVP_MD_CTX* ctx) const { EVP_MD_CTX_free(ctx); } |
266 | | #else |
267 | | template<> void CTX_Copier<EVP_MD_CTX>::freeCTX(EVP_MD_CTX* ctx) const { EVP_MD_CTX_cleanup(ctx); free(ctx); } |
268 | | #endif |
269 | | |
270 | 5.13k | template<> EVP_CIPHER_CTX* CTX_Copier<EVP_CIPHER_CTX>::newCTX(void) const { return EVP_CIPHER_CTX_new(); } |
271 | 0 | template<> int CTX_Copier<EVP_CIPHER_CTX>::copyCTX(EVP_CIPHER_CTX* dest, EVP_CIPHER_CTX* src) const { |
272 | | #if !defined(CRYPTOFUZZ_WOLFCRYPT_OPENSSL) |
273 | | return EVP_CIPHER_CTX_copy(dest, src); |
274 | | #else |
275 | 0 | (void)dest; |
276 | 0 | (void)src; |
277 | | |
278 | | /* EVP_CIPHER_CTX_copy is not implemented in wolfCrypt; return failure */ |
279 | 0 | return 0; |
280 | 0 | #endif |
281 | 0 | } |
282 | 5.13k | template<> void CTX_Copier<EVP_CIPHER_CTX>::freeCTX(EVP_CIPHER_CTX* ctx) const { return EVP_CIPHER_CTX_free(ctx); } |
283 | | |
284 | | #if !defined(CRYPTOFUZZ_OPENSSL_102) |
285 | 136 | template<> HMAC_CTX* CTX_Copier<HMAC_CTX>::newCTX(void) const { return HMAC_CTX_new(); } |
286 | 0 | template<> int CTX_Copier<HMAC_CTX>::copyCTX(HMAC_CTX* dest, HMAC_CTX* src) const { return HMAC_CTX_copy(dest, src); } |
287 | 136 | template<> void CTX_Copier<HMAC_CTX>::freeCTX(HMAC_CTX* ctx) const { return HMAC_CTX_free(ctx); } |
288 | | #endif |
289 | | |
290 | 702 | template<> CMAC_CTX* CTX_Copier<CMAC_CTX>::newCTX(void) const { return CMAC_CTX_new(); } |
291 | 0 | template<> int CTX_Copier<CMAC_CTX>::copyCTX(CMAC_CTX* dest, CMAC_CTX* src) const { |
292 | 0 | (void)dest; |
293 | 0 | (void)src; |
294 | 0 | return 0; |
295 | 0 | } |
296 | 702 | template<> void CTX_Copier<CMAC_CTX>::freeCTX(CMAC_CTX* ctx) const { return CMAC_CTX_free(ctx); } |
297 | | |
298 | 3.31k | template<> EC_KEY* CTX_Copier<EC_KEY>::newCTX(void) const { return EC_KEY_new(); } |
299 | 0 | template<> int CTX_Copier<EC_KEY>::copyCTX(EC_KEY* dest, EC_KEY* src) const { |
300 | | #if !defined(CRYPTOFUZZ_BORINGSSL) && !defined(CRYPTOFUZZ_WOLFCRYPT_OPENSSL) |
301 | | return EC_KEY_copy(dest, src) == nullptr ? 0 : 1; |
302 | | #else |
303 | 0 | (void)dest; |
304 | 0 | (void)src; |
305 | 0 | return 0; |
306 | 0 | #endif |
307 | 0 | } |
308 | 3.31k | template<> void CTX_Copier<EC_KEY>::freeCTX(EC_KEY* ctx) const { return EC_KEY_free(ctx); } |
309 | | |
310 | | using CF_EVP_MD_CTX = CTX_Copier<EVP_MD_CTX>; |
311 | | using CF_EVP_CIPHER_CTX = CTX_Copier<EVP_CIPHER_CTX>; |
312 | | using CF_HMAC_CTX = CTX_Copier<HMAC_CTX>; |
313 | | using CF_CMAC_CTX = CTX_Copier<CMAC_CTX>; |
314 | | using CF_EC_KEY = CTX_Copier<EC_KEY>; |
315 | | using CF_EC_POINT = EC_POINT_Copier; |
316 | | using CF_EC_GROUP = EC_GROUP_Copier; |
317 | | } /* namespace module */ |
318 | | } /* namespace cryptofuzz */ |