Coverage Report

Created: 2024-11-21 06:38

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