Coverage Report

Created: 2026-01-09 06:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qpdf/libqpdf/Pl_RC4.cc
Line
Count
Source
1
#include <qpdf/Pl_RC4.hh>
2
3
#include <qpdf/QUtil.hh>
4
#include <qpdf/Util.hh>
5
6
using namespace qpdf;
7
8
Pl_RC4::Pl_RC4(char const* identifier, Pipeline* next, std::string key, size_t out_bufsize) :
9
1.82k
    Pipeline(identifier, next),
10
1.82k
    out_bufsize(out_bufsize),
11
1.82k
    rc4(reinterpret_cast<unsigned char const*>(key.data()), static_cast<int>(key.size()))
12
1.82k
{
13
1.82k
    util::assertion(next, "Attempt to create Pl_RC4 with nullptr as next");
14
1.82k
    this->outbuf = QUtil::make_shared_array<unsigned char>(out_bufsize);
15
1.82k
}
16
17
void
18
Pl_RC4::write(unsigned char const* data, size_t len)
19
1.82k
{
20
1.82k
    util::assertion(outbuf.get(), "Pl_RC4: write() called after finish() called");
21
22
1.82k
    size_t bytes_left = len;
23
1.82k
    unsigned char const* p = data;
24
25
3.70k
    while (bytes_left > 0) {
26
1.88k
        size_t bytes = (bytes_left < this->out_bufsize ? bytes_left : out_bufsize);
27
1.88k
        bytes_left -= bytes;
28
1.88k
        rc4.process(p, bytes, outbuf.get());
29
1.88k
        p += bytes;
30
1.88k
        next()->write(outbuf.get(), bytes);
31
1.88k
    }
32
1.82k
}
33
34
void
35
Pl_RC4::finish()
36
1.81k
{
37
1.81k
    outbuf = nullptr;
38
1.81k
    next()->finish();
39
1.81k
}