Coverage Report

Created: 2025-12-31 06:16

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
6.53k
void Bignum::modify(void) {
10
6.53k
#if defined(CRYPTOFUZZ_BOTAN_IS_ORACLE)
11
6.53k
    (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
6.53k
}
33
34
27
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
2.82k
    bn(other) {
42
2.82k
}
43
44
Bignum::Bignum(const int i) :
45
441
    bn(i)
46
441
{ }
47
48
Bignum::Bignum(const ::Botan::word w) :
49
6
    bn(w)
50
6
{ }
51
52
Bignum::Bignum(Datasource* ds, const std::string s) :
53
9.37k
    ds(ds), bn(s) {
54
9.37k
}
55
56
Bignum::Bignum(const std::string s) :
57
1.87k
    bn(s) {
58
1.87k
}
59
60
6.53k
::Botan::BigInt& Bignum::Ref(void) {
61
6.53k
    modify();
62
63
6.53k
    return bn;
64
6.53k
}
65
66
4.30k
const ::Botan::BigInt& Bignum::ConstRef(void) const {
67
4.30k
    return bn;
68
4.30k
}
69
70
} /* namespace Botan_bignum */
71
} /* namespace module */
72
} /* namespace cryptofuzz */