blob: 888ea7528bf4fa2442b645ff75e101b17aa69daf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#ifndef __PL_AES_PDF_HH__
#define __PL_AES_PDF_HH__
#include <qpdf/Pipeline.hh>
// This pipeline implements AES-128 with CBC and block padding as
// specified in the PDF specification.
class DLL_EXPORT Pl_AES_PDF: public Pipeline
{
public:
// key_data should be a pointer to key_size bytes of data
static unsigned int const key_size = 16;
Pl_AES_PDF(char const* identifier, Pipeline* next,
bool encrypt, unsigned char const key[key_size]);
virtual ~Pl_AES_PDF();
virtual void write(unsigned char* data, int len);
virtual void finish();
// For testing only; PDF always uses CBC
void disableCBC();
private:
void flush(bool discard_padding);
void initializeVector();
static unsigned int const buf_size = 16;
bool encrypt;
bool cbc_mode;
bool first;
unsigned int offset;
unsigned char key[key_size];
uint32_t rk[key_size + 28];
unsigned char inbuf[buf_size];
unsigned char outbuf[buf_size];
unsigned char cbc_block[buf_size];
unsigned int nrounds;
};
#endif // __PL_AES_PDF_HH__
|