Coverage Report

Created: 2025-12-31 06:08

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cryptofuzz/modules/botan/bn_helper.cpp
Line
Count
Source
1
#include <cryptofuzz/util.h>
2
3
#include "bn_helper.h"
4
5
namespace cryptofuzz {
6
namespace module {
7
namespace Botan_bignum {
8
9
15.9k
void Bignum::modify(void) {
10
15.9k
#if defined(CRYPTOFUZZ_BOTAN_IS_ORACLE)
11
15.9k
    (void)ds;
12
#else
13
    if ( ds == nullptr ) {
14
        return;
15
    }
16
17
    try {
18
        /* Binary encode/decode */
19
        if ( bn >= 0 && ds->Get<bool>() ) {
20
            uint8_t* encoded = util::malloc(bn.bytes());
21
            CF_NORET(bn.binary_encode(encoded, bn.bytes()));
22
            CF_NORET(bn.binary_decode(encoded, bn.bytes()));
23
            util::free(encoded);
24
        }
25
26
        /* Invoke copy constructor */
27
        if ( ds->Get<bool>() ) {
28
            bn = ::Botan::BigInt(bn);
29
        }
30
    } catch ( fuzzing::datasource::Datasource::OutOfData ) { }
31
#endif
32
15.9k
}
33
34
0
Bignum::Bignum() { }
35
36
Bignum::Bignum(Datasource* ds, const ::Botan::BigInt& other) :
37
0
    ds(ds), bn(other) {
38
0
}
39
40
Bignum::Bignum(const ::Botan::BigInt& other) :
41
3.88k
    bn(other) {
42
3.88k
}
43
44
Bignum::Bignum(const int i) :
45
465
    bn(i)
46
465
{ }
47
48
Bignum::Bignum(const ::Botan::word w) :
49
5
    bn(w)
50
5
{ }
51
52
Bignum::Bignum(Datasource* ds, const std::string s) :
53
22.7k
    ds(ds), bn(s) {
54
22.7k
}
55
56
Bignum::Bignum(const std::string s) :
57
178
    bn(s) {
58
178
}
59
60
15.9k
::Botan::BigInt& Bignum::Ref(void) {
61
15.9k
    modify();
62
63
15.9k
    return bn;
64
15.9k
}
65
66
3.88k
const ::Botan::BigInt& Bignum::ConstRef(void) const {
67
3.88k
    return bn;
68
3.88k
}
69
70
} /* namespace Botan_bignum */
71
} /* namespace module */
72
} /* namespace cryptofuzz */