Coverage Report

Created: 2026-03-12 07:01

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
49.4k
    Pipeline(identifier, next),
10
49.4k
    out_bufsize(out_bufsize),
11
49.4k
    rc4(reinterpret_cast<unsigned char const*>(key.data()), static_cast<int>(key.size()))
12
49.4k
{
13
49.4k
    util::assertion(next, "Attempt to create Pl_RC4 with nullptr as next");
14
49.4k
    this->outbuf = QUtil::make_shared_array<unsigned char>(out_bufsize);
15
49.4k
}
16
17
void
18
Pl_RC4::write(unsigned char const* data, size_t len)
19
49.4k
{
20
49.4k
    util::assertion(outbuf.get(), "Pl_RC4: write() called after finish() called");
21
22
49.4k
    size_t bytes_left = len;
23
49.4k
    unsigned char const* p = data;
24
25
115k
    while (bytes_left > 0) {
26
65.6k
        size_t bytes = (bytes_left < this->out_bufsize ? bytes_left : out_bufsize);
27
65.6k
        bytes_left -= bytes;
28
65.6k
        rc4.process(p, bytes, outbuf.get());
29
65.6k
        p += bytes;
30
65.6k
        next()->write(outbuf.get(), bytes);
31
65.6k
    }
32
49.4k
}
33
34
void
35
Pl_RC4::finish()
36
49.3k
{
37
49.3k
    outbuf = nullptr;
38
49.3k
    next()->finish();
39
49.3k
}