summaryrefslogtreecommitdiff
path: root/noncore/unsupported/qpdf/xpdf/Decrypt.h
Unidiff
Diffstat (limited to 'noncore/unsupported/qpdf/xpdf/Decrypt.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/qpdf/xpdf/Decrypt.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/xpdf/Decrypt.h b/noncore/unsupported/qpdf/xpdf/Decrypt.h
new file mode 100644
index 0000000..1bdb2b7
--- a/dev/null
+++ b/noncore/unsupported/qpdf/xpdf/Decrypt.h
@@ -0,0 +1,59 @@
1//========================================================================
2//
3// Decrypt.h
4//
5// Copyright 1996 Derek B. Noonburg
6//
7//========================================================================
8
9#ifndef DECRYPT_H
10#define DECRYPT_H
11
12#ifdef __GNUC__
13#pragma interface
14#endif
15
16#include "gtypes.h"
17#include "GString.h"
18
19//------------------------------------------------------------------------
20// Decrypt
21//------------------------------------------------------------------------
22
23class Decrypt {
24public:
25
26 // Initialize the decryptor object.
27 Decrypt(Guchar *fileKey, int keyLength, int objNum, int objGen);
28
29 // Reset decryption.
30 void reset();
31
32 // Decrypt one byte.
33 Guchar decryptByte(Guchar c);
34
35 // Generate a file key. The <fileKey> buffer must have space for at
36 // least 16 bytes. Checks <ownerPassword> and then <userPassword>
37 // and returns true if either is correct. Sets <ownerPasswordOk> if
38 // the owner password was correct. Either or both of the passwords
39 // may be NULL, which is treated as an empty string.
40 static GBool makeFileKey(int encVersion, int encRevision, int keyLength,
41 GString *ownerKey, GString *userKey,
42 int permissions, GString *fileID,
43 GString *ownerPassword, GString *userPassword,
44 Guchar *fileKey, GBool *ownerPasswordOk);
45
46private:
47
48 static GBool makeFileKey2(int encVersion, int encRevision, int keyLength,
49 GString *ownerKey, GString *userKey,
50 int permissions, GString *fileID,
51 GString *userPassword, Guchar *fileKey);
52
53 int objKeyLength;
54 Guchar objKey[21];
55 Guchar state[256];
56 Guchar x, y;
57};
58
59#endif