Coverage Report

Created: 2024-09-11 06:39

/src/cryptofuzz/entry.cpp
Line
Count
Source
1
#include <cstddef>
2
#include <cstdint>
3
#include <memory>
4
#include <set>
5
#include <vector>
6
#include <string>
7
#include <cryptofuzz/options.h>
8
#include <fuzzing/datasource/id.hpp>
9
#include "repository_tbl.h"
10
#include "driver.h"
11
#include "numbers.h"
12
#include "mutatorpool.h"
13
14
#if defined(CRYPTOFUZZ_LIBTOMMATH) && defined(CRYPTOFUZZ_NSS)
15
#error "libtommath and NSS cannot be used together due to symbol collisions"
16
#endif
17
18
#if defined(CRYPTOFUZZ_TREZOR_FIRMWARE) && defined(CRYPTOFUZZ_RELIC)
19
#error "trezor-firmware and relic cannot be used together due to symbol collisions"
20
#endif
21
22
#if !defined(CRYPTOFUZZ_NO_OPENSSL)
23
  #include <modules/openssl/module.h>
24
  #ifdef SHA1
25
    #undef SHA1
26
  #endif
27
  #ifdef SHA224
28
    #undef SHA224
29
  #endif
30
  #ifdef SHA256
31
    #undef SHA256
32
  #endif
33
  #ifdef SHA384
34
    #undef SHA384
35
  #endif
36
  #ifdef SHA512
37
    #undef SHA512
38
  #endif
39
#endif
40
41
#if defined(CRYPTOFUZZ_BITCOIN)
42
  #include <modules/bitcoin/module.h>
43
#endif
44
45
#if defined(CRYPTOFUZZ_REFERENCE)
46
  #include <modules/reference/module.h>
47
#endif
48
49
#if defined(CRYPTOFUZZ_CPPCRYPTO)
50
  #include <modules/cppcrypto/module.h>
51
#endif
52
53
#if defined(CRYPTOFUZZ_MBEDTLS)
54
  #include <modules/mbedtls/module.h>
55
#endif
56
57
#if defined(CRYPTOFUZZ_TF_PSA_CRYPTO)
58
  #include <modules/tf-psa-crypto/module.h>
59
#endif
60
61
#if defined(CRYPTOFUZZ_BOOST)
62
  #include <modules/boost/module.h>
63
#endif
64
65
#if defined(CRYPTOFUZZ_MONERO)
66
  #include <modules/monero/module.h>
67
#endif
68
69
#if defined(CRYPTOFUZZ_VERACRYPT)
70
  #include <modules/veracrypt/module.h>
71
#endif
72
73
#if defined(CRYPTOFUZZ_LIBSODIUM)
74
  #include <modules/libsodium/module.h>
75
#endif
76
77
#if defined(CRYPTOFUZZ_LIBTOMCRYPT)
78
  #include <modules/libtomcrypt/module.h>
79
#endif
80
81
#if defined(CRYPTOFUZZ_CRYPTOPP)
82
  #include <modules/cryptopp/module.h>
83
#endif
84
85
#if defined(CRYPTOFUZZ_LIBGCRYPT)
86
  #include <modules/libgcrypt/module.h>
87
#endif
88
89
#if defined(CRYPTOFUZZ_EVERCRYPT)
90
  #include <modules/evercrypt/module.h>
91
#endif
92
93
#if defined(CRYPTOFUZZ_GOLANG)
94
  #include <modules/golang/module.h>
95
#endif
96
97
#if defined(CRYPTOFUZZ_RING)
98
  #include <modules/ring/module.h>
99
#endif
100
101
#if defined(CRYPTOFUZZ_NSS)
102
  #include <modules/nss/module.h>
103
#endif
104
105
#if defined(CRYPTOFUZZ_BOTAN)
106
  #include <modules/botan/module.h>
107
#endif
108
109
#if defined(CRYPTOFUZZ_NETTLE)
110
  #include <modules/nettle/module.h>
111
#endif
112
113
#if defined(CRYPTOFUZZ_WOLFCRYPT)
114
  #include <modules/wolfcrypt/module.h>
115
#endif
116
117
#if defined(CRYPTOFUZZ_LIBGMP)
118
  #include <modules/libgmp/module.h>
119
#endif
120
121
#if defined(CRYPTOFUZZ_BN_JS)
122
  #include <modules/bn.js/module.h>
123
#endif
124
125
#if defined(CRYPTOFUZZ_CRYPTO_JS)
126
  #include <modules/crypto-js/module.h>
127
#endif
128
129
#if defined(CRYPTOFUZZ_BIGNUMBER_JS)
130
  #include <modules/bignumber.js/module.h>
131
#endif
132
133
#if defined(CRYPTOFUZZ_MPDECIMAL)
134
  #include <modules/mpdecimal/module.h>
135
#endif
136
137
#if defined(CRYPTOFUZZ_LINUX)
138
  #include <modules/linux/module.h>
139
#endif
140
141
#if defined(CRYPTOFUZZ_SYMCRYPT)
142
  #include <modules/symcrypt/module.h>
143
#endif
144
145
#if defined(CRYPTOFUZZ_LIBTOMMATH)
146
  #include <modules/libtommath/module.h>
147
#endif
148
149
#if defined(CRYPTOFUZZ_SJCL)
150
  #include <modules/sjcl/module.h>
151
#endif
152
153
#if defined(CRYPTOFUZZ_WOLFCRYPT_OPENSSL)
154
  #include <modules/wolfcrypt-openssl/module.h>
155
#endif
156
157
#if defined(CRYPTOFUZZ_MONOCYPHER)
158
  #include <modules/monocypher/module.h>
159
#endif
160
161
#if defined(CRYPTOFUZZ_SECP256K1)
162
  #include <modules/secp256k1/module.h>
163
#endif
164
165
#if defined(CRYPTOFUZZ_RUST_LIBSECP256K1)
166
  #include <modules/rust-libsecp256k1/module.h>
167
#endif
168
169
#if defined(CRYPTOFUZZ_TREZOR_FIRMWARE)
170
  #include <modules/trezor/module.h>
171
#endif
172
173
#if defined(CRYPTOFUZZ_ELLIPTIC)
174
  #include <modules/elliptic/module.h>
175
#endif
176
177
#if defined(CRYPTOFUZZ_DECRED)
178
  #include <modules/decred/module.h>
179
#endif
180
181
#if defined(CRYPTOFUZZ_BEARSSL)
182
  #include <modules/bearssl/module.h>
183
#endif
184
185
#if defined(CRYPTOFUZZ_MICRO_ECC)
186
  #include <modules/micro-ecc/module.h>
187
#endif
188
189
#if defined(CRYPTOFUZZ_CIFRA)
190
  #include <modules/cifra/module.h>
191
#endif
192
193
#if defined(CRYPTOFUZZ_RELIC)
194
  #include <modules/relic/module.h>
195
#endif
196
197
#if defined(CRYPTOFUZZ_LIBECC)
198
  #include <modules/libecc/module.h>
199
#endif
200
201
#if defined(CRYPTOFUZZ_CHIA_BLS)
202
  #include <modules/chia_bls/module.h>
203
#endif
204
205
#if defined(CRYPTOFUZZ_K256)
206
  #include <modules/k256/module.h>
207
#endif
208
209
#if defined(CRYPTOFUZZ_SCHNORRKEL)
210
  #include <modules/schnorrkel/module.h>
211
#endif
212
213
#if defined(CRYPTOFUZZ_NOBLE_SECP256K1)
214
  #include <modules/noble-secp256k1/module.h>
215
#endif
216
217
#if defined(CRYPTOFUZZ_NOBLE_CURVES)
218
  #include <modules/noble-curves/module.h>
219
#endif
220
221
#if defined(CRYPTOFUZZ_BLST)
222
  #include <modules/blst/module.h>
223
#endif
224
225
#if defined(CRYPTOFUZZ_MCL)
226
  #include <modules/mcl/module.h>
227
#endif
228
229
#if defined(CRYPTOFUZZ_PY_ECC)
230
  #include <modules/py_ecc/module.h>
231
#endif
232
233
#if defined(CRYPTOFUZZ_KILIC_BLS12_381)
234
  #include <modules/kilic-bls12-381/module.h>
235
#endif
236
237
#if defined(CRYPTOFUZZ_NOBLE_ED25519)
238
  #include <modules/noble-ed25519/module.h>
239
#endif
240
241
#if defined(CRYPTOFUZZ_NOBLE_BLS12_381)
242
  #include <modules/noble-bls12-381/module.h>
243
#endif
244
245
#if defined(CRYPTOFUZZ_SCHNORR_FUN)
246
  #include <modules/schnorr_fun/module.h>
247
#endif
248
249
#if defined(CRYPTOFUZZ_QUICKJS)
250
  #include <modules/quickjs/module.h>
251
#endif
252
253
#if defined(CRYPTOFUZZ_UINT128_T)
254
  #include <modules/uint128_t/module.h>
255
#endif
256
257
#if defined(CRYPTOFUZZ_LIBFF)
258
  #include <modules/libff/module.h>
259
#endif
260
261
#if defined(CRYPTOFUZZ_GNARK_BN254)
262
  #include <modules/gnark-bn254/module.h>
263
#endif
264
265
#if defined(CRYPTOFUZZ_GOOGLE_BN256)
266
  #include <modules/google-bn256/module.h>
267
#endif
268
269
#if defined(CRYPTOFUZZ_CLOUDFLARE_BN256)
270
  #include <modules/cloudflare-bn256/module.h>
271
#endif
272
273
#if defined(CRYPTOFUZZ_NOBLE_HASHES)
274
  #include <modules/noble-hashes/module.h>
275
#endif
276
277
#if defined(CRYPTOFUZZ_SKALE_SOLIDITY)
278
  #include <modules/skalesolidity/module.h>
279
#endif
280
281
#if defined(CRYPTOFUZZ_GOOGLE_INTEGERS)
282
  #include <modules/google-integers/module.h>
283
#endif
284
285
#if defined(CRYPTOFUZZ_NIMCRYPTO)
286
  #include <modules/nimcrypto/module.h>
287
#endif
288
289
#if defined(CRYPTOFUZZ_RUSTCRYPTO)
290
  #include <modules/rustcrypto/module.h>
291
#endif
292
293
#if defined(CRYPTOFUZZ_NUM_BIGINT)
294
  #include <modules/num-bigint/module.h>
295
#endif
296
297
#if defined(CRYPTOFUZZ_INTX)
298
  #include <modules/intx/module.h>
299
#endif
300
301
#if defined(CRYPTOFUZZ_DECRED_UINT256)
302
  #include <modules/decred-uint256/module.h>
303
#endif
304
305
#if defined(CRYPTOFUZZ_LIBDIVIDE)
306
  #include <modules/libdivide/module.h>
307
#endif
308
309
#if defined(CRYPTOFUZZ_RUST_UINT)
310
  #include <modules/rust-uint/module.h>
311
#endif
312
313
#if defined(CRYPTOFUZZ_BC)
314
  #include <modules/bc/module.h>
315
#endif
316
317
#if defined(CRYPTOFUZZ_JAVA)
318
  #include <modules/java/module.h>
319
#endif
320
321
#if defined(CRYPTOFUZZ_SOLIDITY_MATH)
322
  #include <modules/soliditymath/module.h>
323
#endif
324
325
#if defined(CRYPTOFUZZ_V8)
326
  #include <modules/v8/module.h>
327
#endif
328
329
#if defined(CRYPTOFUZZ_V8_EMBEDDED)
330
  #include <modules/v8-embedded/module.h>
331
#endif
332
333
#if defined(CRYPTOFUZZ_CIRCL)
334
  #include <modules/circl/module.h>
335
#endif
336
337
#if defined(CRYPTOFUZZ_SPL_MATH)
338
  #include <modules/spl_math/module.h>
339
#endif
340
341
#if defined(CRYPTOFUZZ_ZIG)
342
  #include <modules/zig/module.h>
343
#endif
344
345
#if defined(CRYPTOFUZZ_PRYSMATICLABS_HASHTREE)
346
  #include <modules/prysmaticlabs-hashtree/module.h>
347
#endif
348
349
#if defined(CRYPTOFUZZ_STARKWARE)
350
  #include <modules/starkware/module.h>
351
#endif
352
353
#if defined(CRYPTOFUZZ_PORNIN_BINGCD)
354
  #include <modules/pornin-bingcd/module.h>
355
#endif
356
357
#if defined(CRYPTOFUZZ_STINT)
358
  #include <modules/stint/module.h>
359
#endif
360
361
#if defined(CRYPTOFUZZ_KRYPTOLOGY)
362
  #include <modules/kryptology/module.h>
363
#endif
364
365
#if defined(CRYPTOFUZZ_NIM_BIGINTS)
366
  #include <modules/nim-bigints/module.h>
367
#endif
368
369
#if defined(CRYPTOFUZZ_HOLIMAN_UINT256)
370
  #include <modules/holiman-uint256/module.h>
371
#endif
372
373
#if defined(CRYPTOFUZZ_CPU)
374
  #include <modules/cpu/module.h>
375
#endif
376
377
#if defined(CRYPTOFUZZ_GETH)
378
  #include <modules/geth/module.h>
379
#endif
380
381
#if defined(CRYPTOFUZZ_JSBN)
382
  #include <modules/jsbn/module.h>
383
#endif
384
385
#if defined(CRYPTOFUZZ_WIDE_INTEGER)
386
  #include <modules/wide-integer/module.h>
387
#endif
388
389
#if defined(CRYPTOFUZZ_TINY_KECCAK)
390
  #include <modules/tiny-keccak/module.h>
391
#endif
392
393
#if defined(CRYPTOFUZZ_ARKWORKS_ALGEBRA)
394
  #include <modules/arkworks-algebra/module.h>
395
#endif
396
397
#if defined(CRYPTOFUZZ_FF)
398
  #include <modules/ff/module.h>
399
#endif
400
401
#if defined(CRYPTOFUZZ_ALEO)
402
  #include <modules/aleo/module.h>
403
#endif
404
405
#if defined(CRYPTOFUZZ_SHAMATAR)
406
  #include <modules/shamatar/module.h>
407
#endif
408
409
#if defined(CRYPTOFUZZ_MICROSOFT_CALCULATOR)
410
  #include <modules/microsoft-calculator/module.h>
411
#endif
412
413
#if defined(CRYPTOFUZZ_POLYGON_ZKEVM_PROVER)
414
  #include <modules/polygon-zkevm-prover/module.h>
415
#endif
416
417
#if defined(CRYPTOFUZZ_GOLDILOCKS)
418
  #include <modules/goldilocks/module.h>
419
#endif
420
421
#if defined(CRYPTOFUZZ_D)
422
  #include <modules/d/module.h>
423
#endif
424
425
#if defined(CRYPTOFUZZ_PAIRING_CE)
426
  #include <modules/pairing_ce/module.h>
427
#endif
428
429
#if defined(CRYPTOFUZZ_PASTA_CURVES)
430
  #include <modules/pasta_curves/module.h>
431
#endif
432
433
#if defined(CRYPTOFUZZ_BOUNCYCASTLE)
434
  #include <modules/bouncycastle/module.h>
435
#endif
436
437
#if defined(CRYPTOFUZZ_FAHEEL_BIGINT)
438
  #include <modules/faheel-bigint/module.h>
439
#endif
440
441
#if defined(CRYPTOFUZZ_SUBSTRATE_BN)
442
  #include <modules/substrate-bn/module.h>
443
#endif
444
445
#if defined(CRYPTOFUZZ_AURORA_ENGINE_MODEXP)
446
  #include <modules/aurora-engine-modexp/module.h>
447
#endif
448
449
#if defined(CRYPTOFUZZ_CONSTANTINE)
450
  #include <modules/constantine/module.h>
451
#endif
452
453
std::shared_ptr<cryptofuzz::Driver> driver = nullptr;
454
455
const cryptofuzz::Options* cryptofuzz_options = nullptr;
456
457
6
static void setOptions(int argc, char** argv) {
458
6
    std::vector<std::string> extraArguments;
459
460
6
    const std::string cmdline(
461
6
#include "extra_options.h"
462
6
    );
463
6
    boost::split(extraArguments, cmdline, boost::is_any_of(" "));
464
465
6
    const cryptofuzz::Options options(argc, argv, extraArguments);
466
467
6
    driver = std::make_shared<cryptofuzz::Driver>(options);
468
6
    cryptofuzz_options = driver->GetOptionsPtr();
469
6
}
470
471
6
static void addNumbers(void) {
472
6
    std::set<std::string> curveNumbers;
473
474
690
    for (size_t i = 0; i < (sizeof(ECC_CurveLUT) / sizeof(ECC_CurveLUT[0])); i++) {
475
684
        if ( !cryptofuzz_options->curves.Empty() ) {
476
684
            if ( !cryptofuzz_options->curves.Have(ECC_CurveLUT[i].id) ) {
477
678
                continue;
478
678
            }
479
684
        }
480
6
        if ( ECC_CurveLUT[i].prime ) curveNumbers.insert(*ECC_CurveLUT[i].prime);
481
6
        if ( ECC_CurveLUT[i].a ) curveNumbers.insert(*ECC_CurveLUT[i].a);
482
6
        if ( ECC_CurveLUT[i].b ) curveNumbers.insert(*ECC_CurveLUT[i].b);
483
6
        if ( ECC_CurveLUT[i].x ) curveNumbers.insert(*ECC_CurveLUT[i].x);
484
6
        if ( ECC_CurveLUT[i].y ) curveNumbers.insert(*ECC_CurveLUT[i].y);
485
6
        if ( ECC_CurveLUT[i].order_min_1 ) curveNumbers.insert(*ECC_CurveLUT[i].order_min_1);
486
6
        if ( ECC_CurveLUT[i].order ) curveNumbers.insert(*ECC_CurveLUT[i].order);
487
6
        if ( ECC_CurveLUT[i].cube_root_of_unity ) curveNumbers.insert(*ECC_CurveLUT[i].cube_root_of_unity);
488
6
    }
489
490
48
    for (const auto& s : curveNumbers) {
491
48
        cryptofuzz::numbers.push_back(s);
492
48
    }
493
6
}
494
495
6
static void addDHParameters(void) {
496
#if 0
497
    Pool_DSA_PQG.Set(
498
            {.p = "1",
499
            .q = "2",
500
            .g = "3"});
501
#endif
502
6
    Pool_DSA_PQG.Set(
503
6
            {.p = "150231251465501053065289730830479539031267100291054217656119618775188714462742252299995155757488154161365770046117427638242442140226792437461696203428042747814919633220489019161055283800701437723694062141157721435870605677289344980419875189236552985653350450140879697446183075783979747578514684880689288047799",
504
6
            .q = "1294481460557625951125096174768278956450379329019",
505
6
            .g = "123176323926370145306905001771640082099315258804911565991781248774641279332286091530406470110108628420952674474326303976152638457646984169382680970876359186878615754700522570368203249170942652654272930135088255007459054551060675803532305465059607033300717516344741377807058295415130769662943475898885953255340"});
506
6
    Pool_DSA_PQG.Set(
507
6
            {.p = "106509719202367738942907301715621764539176496646576730633405674043673327856034496732123285709035111374434625191651676418221653833534278937120432644397709949603105722781668399360019469472968954460534436252768055503483520304713097271043340825087067201677304620852378413654560436979990703753937487367926506348269",
508
6
            .q = "1118288236462792761843833248187413414208173350127",
509
6
            .g = "72435671226965183258018862642795284302154495588562538482929411018310293659579761499337602974793436767341017333127333555852102593771624671345177391442816067820254123593555250556535136260966363205479876316378634773122750273117965996152020834617159357433557924693138598393331986343698108999770366446752278926383"});
510
6
    Pool_DSA_PQG.Set(
511
6
            {.p = "138004309818347094291132867053619499223956524961247192036762792751710974956820647583519309378416103935248269857717426029960774699149947213109440086871278734506662709841063082677937025903550210186986005638869595390211739861476658649538254442080037424128091536935132784096865076724077340725421734957662003955733",
512
6
            .q = "1182250927352833565111471235946595886633807053753",
513
6
            .g = "50981117407618898907676270875500924244946234557748656321451486290931484477672699528123700670310821778249759666738775273571334004072876741139654244496478237072456811279416350268794526824840182161332334555442145925212778889513472053306551473115435240639581353186943034554008455203164569371804149410594860147535"});
514
6
    Pool_DSA_PQG.Set(
515
6
            {.p = "109946688229802800321045008502525855019018343635199811459637834412277718704275426696546931048200193867073853699694661301100987130977969037055869145785556128499893546459160327648034486774397840709962126663410720743324891206859744100608443126416778329748285936795477961285242132107013514469104031276590639145529",
516
6
            .q = "1097017798574652758688027153013343959247758036379",
517
6
            .g = "90853802403425362444834708006843703424758064889418913931212173026894777531419682953836039048180446572898657640543499059154888760571238291120015914403667178235563530884249409802138323217540531374295893371508604222324367014390024227163670654837119886355437741902577247163114711575830541075372536310906966739501"});
518
6
    Pool_DSA_PQG.Set(
519
6
            {.p = "124209509072024958275166637845461843473168024436234587545357618943183152164739154230608140142817940602971118647920318657635219309456829210930848667888289103140463427808821865872498412912378809701133733363511757593195923487399372820407763609428150569455525396831100333605708326427075191467209382555105711963299",
520
6
            .q = "1156817815916336365281547542987775955291851935871",
521
6
            .g = "43439798865518148079170184647168882910799658250950112656992473391369195267567114318131636772383729066568167011041675228166469202932063704475384188208092171311430491566372323746821632363680716780126497417783638448391870877258448510742322506027897962466869528155419123258766935809190262469523993336422700725318"});
522
6
    Pool_DSA_PQG.Set(
523
6
            {.p = "126331233628980840165184565942245385096513091144740711497864308287507943295406615416955002027235910171772121228535928494648768972393171048104219309808822924104348781037865255204637472392028547550836119757782109037132097469719594436136398329796267499263632942017207769135383159876183961765810415630873971115233",
524
6
            .q = "1203327632657956941015344776779451299508739578129",
525
6
            .g = "97452668285819865055659311415043913678401634848512133077315151404416203000244082651639944515890002752552299640827969897097594332745578954618134141809516813588353374434067098749478884011839257971032639225273289142277635977389715811787650901754149760120488823365859750048315630946360036462942314143557183124982"});
526
6
    Pool_DSA_PQG.Set(
527
6
            {.p = "139250883301823483908883928083839064003745916441650255007772870154941172395087178752876101091005767662213271334443940570474680019084601422955747232370282598419697274421195681275556947624938410397537906338955131228297990585299263933664717169274974367925488384465967202651868677400555284280096337099191959071787",
528
6
            .q = "1325100766121833447183259101226453517842221286507",
529
6
            .g = "58646846595225538779696035374886298089421912241195003782810584053398797793591727045576166116215795078184706343867027617123952824238923027973165246674943121228498251801328224621075003565013070726915672626019475087221545030092892828436386114258346864840836351933570664379118571919793182205573116727058719375661"});
530
6
    Pool_DSA_PQG.Set(
531
6
            {.p = "144701324401598336550884152343368172277609864124511490596617105828057159991373774941016821760687266369338519486490004072145971111466542758853015017509128499051606282143736677640332301617479652949405201725583682831439755381248675286661684002938741047451713467379330091941738855468955951557713143970579349864457",
532
6
            .q = "1439434426242082501974975807657668984105633014787",
533
6
            .g = "113600692930456433400748782777975166451962648651602592974909826945350314246206069661699011991844511030599644698164383474978927329888470480371116765437437655015511396253863826561268272020107619231686538845226921909438712847791416806266736495398219697258274310643814113505622803337678429494610934192497815903365"});
534
6
    Pool_DSA_PQG.Set(
535
6
            {.p = "135341197697226724892903083596165054694790625986023071616356886245846043038405567011291087532200081879605164155216745486229649520257309932549000914144450824446643782112243492160717188886767122817207763789165868343163481202614492491575215866530116235028761963662218876392260598504340050277595263388586602546747",
536
6
            .q = "1169054189952016903829256751948870806314450386513",
537
6
            .g = "30572099485446824777611559392355316740353774202040161762373834574766256266332511696873593659519522274210266790041815776129917472702566335252550578138435000898308011273223392155586550839178056561166656269827651537030610266906854193629082719056305327623289093720593961976531902349641250618073959820008293423729"});
538
6
    Pool_DSA_PQG.Set(
539
6
            {.p = "127351864753493277268739385478165721559729466727175877720818107624823856755558221219347691856288532870918552584721097877527832510124917679520208660409823797024889655990544958921667883652156168599993183854739635683709671125815430824244885672208722762544165061369990843770047348269058869140280321943549216357991",
540
6
            .q = "1156961398255600519725597002666342085415806424529",
541
6
            .g = "106257931303095074533103986366433211062343163442228036675016417802383259373755687507866521855899403669620543075167608985212468902139533924762542871308909385486893394211775148650040778024210387468981928471252790681933685353324695021902141191542978389064246508147865484230435458524929665990269930783999629249441"});
542
6
    Pool_DSA_PQG.Set(
543
6
            {.p = "131039458455155250090174200145321228172977476476885551980435528702610913389079590939737522784805216856991866456707299626829238352232572218199747475524103264307799994317996352504194705753236329996801042545987006513074758983109144174154780904219653269610458162384667077307435251147347179290650561637905921672683",
544
6
            .q = "1170715624353437458381293805110022939445185488259",
545
6
            .g = "126742934784779681813194779376736668434375433467445616299439666618831396063812870504003367398372147678231830460960085383230032539099660760734275638091575317361409298198873148524067936524126541952740212599133188511748079844136886266936035053990867071777029697349092865480561238401432352105670316197944641993372"});
546
6
    Pool_DSA_PQG.Set(
547
6
            {.p = "113501887847313654923482478343337570064130386651110593957519724786021990228602191373446721521338119059972385547173111082437621139282278796862795599570090388898648541512966469137375762705045818898892127936907280478802811793893711980582500291057764626146803929832480402191770765381629264026303953585630138960173",
548
6
            .q = "1210118463151965859368281774842614821435692691527",
549
6
            .g = "7368690161464245595369357421049794571202878323927473530430901957824912081535284584536397796919942606122666864397318876947854645101607578840959967924770322750454906727500380020624862129397409509250521115423635650551518713996861995296315890736439522758915319733553857973686465993050136329199277364851750662840"});
550
6
}
551
552
6
extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
553
6
    setOptions(*argc, *argv);
554
6
    addNumbers();
555
6
    addDHParameters();
556
557
#if !defined(CRYPTOFUZZ_NO_OPENSSL)
558
    driver->LoadModule( std::make_shared<cryptofuzz::module::OpenSSL>() );
559
#endif
560
561
6
#if defined(CRYPTOFUZZ_BITCOIN)
562
6
    driver->LoadModule( std::make_shared<cryptofuzz::module::Bitcoin>() );
563
6
#endif
564
565
#if defined(CRYPTOFUZZ_REFERENCE)
566
    driver->LoadModule( std::make_shared<cryptofuzz::module::Reference>() );
567
#endif
568
569
#if defined(CRYPTOFUZZ_CPPCRYPTO)
570
    driver->LoadModule( std::make_shared<cryptofuzz::module::CPPCrypto>() );
571
#endif
572
573
#if defined(CRYPTOFUZZ_MBEDTLS)
574
    driver->LoadModule( std::make_shared<cryptofuzz::module::mbedTLS>() );
575
#endif
576
577
#if defined(CRYPTOFUZZ_TF_PSA_CRYPTO)
578
    driver->LoadModule( std::make_shared<cryptofuzz::module::TF_PSA_Crypto>() );
579
#endif
580
581
#if defined(CRYPTOFUZZ_BOOST)
582
    driver->LoadModule( std::make_shared<cryptofuzz::module::Boost>() );
583
#endif
584
585
#if defined(CRYPTOFUZZ_MONERO)
586
    driver->LoadModule( std::make_shared<cryptofuzz::module::Monero>() );
587
#endif
588
589
#if defined(CRYPTOFUZZ_VERACRYPT)
590
    driver->LoadModule( std::make_shared<cryptofuzz::module::Veracrypt>() );
591
#endif
592
593
#if defined(CRYPTOFUZZ_LIBSODIUM)
594
    driver->LoadModule( std::make_shared<cryptofuzz::module::libsodium>() );
595
#endif
596
597
#if defined(CRYPTOFUZZ_LIBTOMCRYPT)
598
    driver->LoadModule( std::make_shared<cryptofuzz::module::libtomcrypt>() );
599
#endif
600
601
#if defined(CRYPTOFUZZ_CRYPTOPP)
602
    driver->LoadModule( std::make_shared<cryptofuzz::module::CryptoPP>() );
603
#endif
604
605
#if defined(CRYPTOFUZZ_LIBGCRYPT)
606
    driver->LoadModule( std::make_shared<cryptofuzz::module::libgcrypt>() );
607
#endif
608
609
#if defined(CRYPTOFUZZ_EVERCRYPT)
610
    driver->LoadModule( std::make_shared<cryptofuzz::module::EverCrypt>() );
611
#endif
612
613
#if defined(CRYPTOFUZZ_GOLANG)
614
    driver->LoadModule( std::make_shared<cryptofuzz::module::Golang>() );
615
#endif
616
617
#if defined(CRYPTOFUZZ_RING)
618
    driver->LoadModule( std::make_shared<cryptofuzz::module::Ring>() );
619
#endif
620
621
#if defined(CRYPTOFUZZ_NSS)
622
    driver->LoadModule( std::make_shared<cryptofuzz::module::NSS>() );
623
#endif
624
625
6
#if defined(CRYPTOFUZZ_BOTAN)
626
6
    driver->LoadModule( std::make_shared<cryptofuzz::module::Botan>() );
627
6
#endif
628
629
#if defined(CRYPTOFUZZ_NETTLE)
630
    driver->LoadModule( std::make_shared<cryptofuzz::module::Nettle>() );
631
#endif
632
633
#if defined(CRYPTOFUZZ_WOLFCRYPT)
634
    driver->LoadModule( std::make_shared<cryptofuzz::module::wolfCrypt>() );
635
#endif
636
637
#if defined(CRYPTOFUZZ_LIBGMP)
638
    driver->LoadModule( std::make_shared<cryptofuzz::module::libgmp>() );
639
#endif
640
641
#if defined(CRYPTOFUZZ_BN_JS)
642
    driver->LoadModule( std::make_shared<cryptofuzz::module::bn_js>() );
643
#endif
644
645
#if defined(CRYPTOFUZZ_CRYPTO_JS)
646
    driver->LoadModule( std::make_shared<cryptofuzz::module::crypto_js>() );
647
#endif
648
649
#if defined(CRYPTOFUZZ_BIGNUMBER_JS)
650
    driver->LoadModule( std::make_shared<cryptofuzz::module::bignumber_js>() );
651
#endif
652
653
#if defined(CRYPTOFUZZ_MPDECIMAL)
654
    driver->LoadModule( std::make_shared<cryptofuzz::module::mpdecimal>() );
655
#endif
656
657
#if defined(CRYPTOFUZZ_LINUX)
658
    driver->LoadModule( std::make_shared<cryptofuzz::module::Linux>() );
659
#endif
660
661
#if defined(CRYPTOFUZZ_SYMCRYPT)
662
    driver->LoadModule( std::make_shared<cryptofuzz::module::SymCrypt>() );
663
#endif
664
665
#if defined(CRYPTOFUZZ_LIBTOMMATH)
666
    driver->LoadModule( std::make_shared<cryptofuzz::module::libtommath>() );
667
#endif
668
669
#if defined(CRYPTOFUZZ_SJCL)
670
    driver->LoadModule( std::make_shared<cryptofuzz::module::sjcl>() );
671
#endif
672
673
#if defined(CRYPTOFUZZ_WOLFCRYPT_OPENSSL)
674
    driver->LoadModule( std::make_shared<cryptofuzz::module::wolfCrypt_OpenSSL>() );
675
#endif
676
677
#if defined(CRYPTOFUZZ_MONOCYPHER)
678
    driver->LoadModule( std::make_shared<cryptofuzz::module::Monocypher>() );
679
#endif
680
681
6
#if defined(CRYPTOFUZZ_SECP256K1)
682
6
    driver->LoadModule( std::make_shared<cryptofuzz::module::secp256k1>() );
683
6
#endif
684
685
#if defined(CRYPTOFUZZ_RUST_LIBSECP256K1)
686
    driver->LoadModule( std::make_shared<cryptofuzz::module::rust_libsecp256k1>() );
687
#endif
688
689
6
#if defined(CRYPTOFUZZ_TREZOR_FIRMWARE)
690
6
    driver->LoadModule( std::make_shared<cryptofuzz::module::trezor_firmware>() );
691
6
#endif
692
693
#if defined(CRYPTOFUZZ_ELLIPTIC)
694
    driver->LoadModule( std::make_shared<cryptofuzz::module::elliptic>() );
695
#endif
696
697
#if defined(CRYPTOFUZZ_DECRED)
698
    driver->LoadModule( std::make_shared<cryptofuzz::module::Decred>() );
699
#endif
700
701
#if defined(CRYPTOFUZZ_BEARSSL)
702
    driver->LoadModule( std::make_shared<cryptofuzz::module::BearSSL>() );
703
#endif
704
705
#if defined(CRYPTOFUZZ_MICRO_ECC)
706
    driver->LoadModule( std::make_shared<cryptofuzz::module::micro_ecc>() );
707
#endif
708
709
#if defined(CRYPTOFUZZ_CIFRA)
710
    driver->LoadModule( std::make_shared<cryptofuzz::module::cifra>() );
711
#endif
712
713
#if defined(CRYPTOFUZZ_RELIC)
714
    driver->LoadModule( std::make_shared<cryptofuzz::module::relic>() );
715
#endif
716
717
#if defined(CRYPTOFUZZ_LIBECC)
718
    driver->LoadModule( std::make_shared<cryptofuzz::module::libecc>() );
719
#endif
720
721
#if defined(CRYPTOFUZZ_CHIA_BLS)
722
    driver->LoadModule( std::make_shared<cryptofuzz::module::chia_bls>() );
723
#endif
724
725
#if defined(CRYPTOFUZZ_K256)
726
    driver->LoadModule( std::make_shared<cryptofuzz::module::k256>() );
727
#endif
728
729
#if defined(CRYPTOFUZZ_SCHNORRKEL)
730
    driver->LoadModule( std::make_shared<cryptofuzz::module::schnorrkel>() );
731
#endif
732
733
#if defined(CRYPTOFUZZ_NOBLE_SECP256K1)
734
    driver->LoadModule( std::make_shared<cryptofuzz::module::noble_secp256k1>() );
735
#endif
736
737
#if defined(CRYPTOFUZZ_NOBLE_CURVES)
738
    driver->LoadModule( std::make_shared<cryptofuzz::module::noble_curves>() );
739
#endif
740
741
742
#if defined(CRYPTOFUZZ_BLST)
743
    driver->LoadModule( std::make_shared<cryptofuzz::module::blst>() );
744
#endif
745
746
#if defined(CRYPTOFUZZ_MCL)
747
    driver->LoadModule( std::make_shared<cryptofuzz::module::mcl>() );
748
#endif
749
750
#if defined(CRYPTOFUZZ_PY_ECC)
751
    driver->LoadModule( std::make_shared<cryptofuzz::module::py_ecc>() );
752
#endif
753
754
#if defined(CRYPTOFUZZ_KILIC_BLS12_381)
755
    driver->LoadModule( std::make_shared<cryptofuzz::module::kilic_bls12_381>() );
756
#endif
757
758
#if defined(CRYPTOFUZZ_NOBLE_ED25519)
759
    driver->LoadModule( std::make_shared<cryptofuzz::module::noble_ed25519>() );
760
#endif
761
762
#if defined(CRYPTOFUZZ_NOBLE_BLS12_381)
763
    driver->LoadModule( std::make_shared<cryptofuzz::module::noble_bls12_381>() );
764
#endif
765
766
#if defined(CRYPTOFUZZ_SCHNORR_FUN)
767
    driver->LoadModule( std::make_shared<cryptofuzz::module::schnorr_fun>() );
768
#endif
769
770
#if defined(CRYPTOFUZZ_QUICKJS)
771
    driver->LoadModule( std::make_shared<cryptofuzz::module::quickjs>() );
772
#endif
773
774
#if defined(CRYPTOFUZZ_UINT128_T)
775
    driver->LoadModule( std::make_shared<cryptofuzz::module::uint128_t>() );
776
#endif
777
778
#if defined(CRYPTOFUZZ_LIBFF)
779
    driver->LoadModule( std::make_shared<cryptofuzz::module::_libff>() );
780
#endif
781
782
#if defined(CRYPTOFUZZ_GNARK_BN254)
783
    driver->LoadModule( std::make_shared<cryptofuzz::module::Gnark_bn254>() );
784
#endif
785
786
#if defined(CRYPTOFUZZ_GOOGLE_BN256)
787
    driver->LoadModule( std::make_shared<cryptofuzz::module::Google_bn256>() );
788
#endif
789
790
#if defined(CRYPTOFUZZ_CLOUDFLARE_BN256)
791
    driver->LoadModule( std::make_shared<cryptofuzz::module::Cloudflare_bn256>() );
792
#endif
793
794
#if defined(CRYPTOFUZZ_NOBLE_HASHES)
795
    driver->LoadModule( std::make_shared<cryptofuzz::module::noble_hashes>() );
796
#endif
797
798
#if defined(CRYPTOFUZZ_SKALE_SOLIDITY)
799
    driver->LoadModule( std::make_shared<cryptofuzz::module::SkaleSolidity>() );
800
#endif
801
802
#if defined(CRYPTOFUZZ_GOOGLE_INTEGERS)
803
    driver->LoadModule( std::make_shared<cryptofuzz::module::Google_Integers>() );
804
#endif
805
806
#if defined(CRYPTOFUZZ_NIMCRYPTO)
807
    driver->LoadModule( std::make_shared<cryptofuzz::module::nimcrypto>() );
808
#endif
809
810
#if defined(CRYPTOFUZZ_RUSTCRYPTO)
811
    driver->LoadModule( std::make_shared<cryptofuzz::module::rustcrypto>() );
812
#endif
813
814
#if defined(CRYPTOFUZZ_NUM_BIGINT)
815
    driver->LoadModule( std::make_shared<cryptofuzz::module::num_bigint>() );
816
#endif
817
818
#if defined(CRYPTOFUZZ_INTX)
819
    driver->LoadModule( std::make_shared<cryptofuzz::module::intx>() );
820
#endif
821
822
#if defined(CRYPTOFUZZ_DECRED_UINT256)
823
    driver->LoadModule( std::make_shared<cryptofuzz::module::decred_uint256>() );
824
#endif
825
826
#if defined(CRYPTOFUZZ_LIBDIVIDE)
827
    driver->LoadModule( std::make_shared<cryptofuzz::module::libdivide>() );
828
#endif
829
830
#if defined(CRYPTOFUZZ_RUST_UINT)
831
    driver->LoadModule( std::make_shared<cryptofuzz::module::rust_uint>() );
832
#endif
833
834
#if defined(CRYPTOFUZZ_BC)
835
    driver->LoadModule( std::make_shared<cryptofuzz::module::bc>() );
836
#endif
837
838
#if defined(CRYPTOFUZZ_JAVA)
839
    driver->LoadModule( std::make_shared<cryptofuzz::module::Java>() );
840
#endif
841
842
#if defined(CRYPTOFUZZ_SOLIDITY_MATH)
843
    driver->LoadModule( std::make_shared<cryptofuzz::module::SolidityMath>() );
844
#endif
845
846
#if defined(CRYPTOFUZZ_V8)
847
    driver->LoadModule( std::make_shared<cryptofuzz::module::V8>() );
848
#endif
849
850
#if defined(CRYPTOFUZZ_CIRCL)
851
    driver->LoadModule( std::make_shared<cryptofuzz::module::circl>() );
852
#endif
853
854
#if defined(CRYPTOFUZZ_SPL_MATH)
855
    driver->LoadModule( std::make_shared<cryptofuzz::module::spl_math>() );
856
#endif
857
858
#if defined(CRYPTOFUZZ_ZIG)
859
    driver->LoadModule( std::make_shared<cryptofuzz::module::Zig>() );
860
#endif
861
862
#if defined(CRYPTOFUZZ_PRYSMATICLABS_HASHTREE)
863
    driver->LoadModule( std::make_shared<cryptofuzz::module::prysmaticlabs_hashtree>() );
864
#endif
865
866
#if defined(CRYPTOFUZZ_STARKWARE)
867
    driver->LoadModule( std::make_shared<cryptofuzz::module::Starkware>() );
868
#endif
869
870
#if defined(CRYPTOFUZZ_PORNIN_BINGCD)
871
    driver->LoadModule( std::make_shared<cryptofuzz::module::Pornin_BinGCD>() );
872
#endif
873
874
#if defined(CRYPTOFUZZ_STINT)
875
    driver->LoadModule( std::make_shared<cryptofuzz::module::stint>() );
876
#endif
877
878
#if defined(CRYPTOFUZZ_KRYPTOLOGY)
879
    driver->LoadModule( std::make_shared<cryptofuzz::module::Kryptology>() );
880
#endif
881
882
#if defined(CRYPTOFUZZ_NIM_BIGINTS)
883
    driver->LoadModule( std::make_shared<cryptofuzz::module::nim_bigints>() );
884
#endif
885
886
#if defined(CRYPTOFUZZ_HOLIMAN_UINT256)
887
    driver->LoadModule( std::make_shared<cryptofuzz::module::holiman_uint256>() );
888
#endif
889
890
#if defined(CRYPTOFUZZ_CPU)
891
    driver->LoadModule( std::make_shared<cryptofuzz::module::CPU>() );
892
#endif
893
894
#if defined(CRYPTOFUZZ_GETH)
895
    driver->LoadModule( std::make_shared<cryptofuzz::module::Geth>() );
896
#endif
897
898
#if defined(CRYPTOFUZZ_JSBN)
899
    driver->LoadModule( std::make_shared<cryptofuzz::module::jsbn>() );
900
#endif
901
902
#if defined(CRYPTOFUZZ_WIDE_INTEGER)
903
    driver->LoadModule( std::make_shared<cryptofuzz::module::wide_integer>() );
904
#endif
905
906
#if defined(CRYPTOFUZZ_TINY_KECCAK)
907
    driver->LoadModule( std::make_shared<cryptofuzz::module::tiny_keccak>() );
908
#endif
909
910
#if defined(CRYPTOFUZZ_ARKWORKS_ALGEBRA)
911
    driver->LoadModule( std::make_shared<cryptofuzz::module::arkworks_algebra>() );
912
#endif
913
914
#if defined(CRYPTOFUZZ_FF)
915
    driver->LoadModule( std::make_shared<cryptofuzz::module::ff>() );
916
#endif
917
918
#if defined(CRYPTOFUZZ_ALEO)
919
    driver->LoadModule( std::make_shared<cryptofuzz::module::Aleo>() );
920
#endif
921
922
#if defined(CRYPTOFUZZ_SHAMATAR)
923
    driver->LoadModule( std::make_shared<cryptofuzz::module::Shamatar>() );
924
#endif
925
926
#if defined(CRYPTOFUZZ_MICROSOFT_CALCULATOR)
927
    driver->LoadModule( std::make_shared<cryptofuzz::module::MicrosoftCalculator>() );
928
#endif
929
930
#if defined(CRYPTOFUZZ_POLYGON_ZKEVM_PROVER)
931
    driver->LoadModule( std::make_shared<cryptofuzz::module::polygon_zkevm_prover>() );
932
#endif
933
934
#if defined(CRYPTOFUZZ_GOLDILOCKS)
935
    driver->LoadModule( std::make_shared<cryptofuzz::module::Goldilocks>() );
936
#endif
937
938
#if defined(CRYPTOFUZZ_D)
939
    driver->LoadModule( std::make_shared<cryptofuzz::module::D>() );
940
#endif
941
942
#if defined(CRYPTOFUZZ_PAIRING_CE)
943
    driver->LoadModule( std::make_shared<cryptofuzz::module::pairing_ce>() );
944
#endif
945
946
#if defined(CRYPTOFUZZ_PASTA_CURVES)
947
    driver->LoadModule( std::make_shared<cryptofuzz::module::pasta_curves>() );
948
#endif
949
950
#if defined(CRYPTOFUZZ_BOUNCYCASTLE)
951
    driver->LoadModule( std::make_shared<cryptofuzz::module::BouncyCastle>() );
952
#endif
953
954
#if defined(CRYPTOFUZZ_FAHEEL_BIGINT)
955
    driver->LoadModule( std::make_shared<cryptofuzz::module::faheel_BigInt>() );
956
#endif
957
958
#if defined(CRYPTOFUZZ_SUBSTRATE_BN)
959
    driver->LoadModule( std::make_shared<cryptofuzz::module::substrate_bn>() );
960
#endif
961
962
#if defined(CRYPTOFUZZ_AURORA_ENGINE_MODEXP)
963
    driver->LoadModule( std::make_shared<cryptofuzz::module::aurora_engine_modexp>() );
964
#endif
965
966
#if defined(CRYPTOFUZZ_V8_EMBEDDED)
967
    driver->LoadModule( std::make_shared<cryptofuzz::module::V8_embedded>() );
968
#endif
969
970
#if defined(CRYPTOFUZZ_CONSTANTINE)
971
    driver->LoadModule( std::make_shared<cryptofuzz::module::Constantine>() );
972
#endif
973
974
    /* TODO check if options.forceModule (if set) refers to a module that is
975
     * actually loaded, warn otherwise.
976
     */
977
6
    return 0;
978
6
}
979
980
469k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
981
469k
    driver->Run(data, size);
982
983
469k
    return 0;
984
469k
}