]> git.ipfire.org Git - thirdparty/cups.git/blob - pdftops/Decrypt.h
Merge changes from CUPS 1.4svn-r7199.
[thirdparty/cups.git] / pdftops / Decrypt.h
1 //========================================================================
2 //
3 // Decrypt.h
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
8
9 #ifndef DECRYPT_H
10 #define DECRYPT_H
11
12 #include <config.h>
13
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17
18 #include "gtypes.h"
19 #include "GString.h"
20
21 //------------------------------------------------------------------------
22 // Decrypt
23 //------------------------------------------------------------------------
24
25 class Decrypt {
26 public:
27
28 // Initialize the decryptor object.
29 Decrypt(Guchar *fileKey, int keyLength, int objNum, int objGen);
30
31 // Reset decryption.
32 void reset();
33
34 // Decrypt one byte.
35 Guchar decryptByte(Guchar c);
36
37 // Generate a file key. The <fileKey> buffer must have space for at
38 // least 16 bytes. Checks <ownerPassword> and then <userPassword>
39 // and returns true if either is correct. Sets <ownerPasswordOk> if
40 // the owner password was correct. Either or both of the passwords
41 // may be NULL, which is treated as an empty string.
42 static GBool makeFileKey(int encVersion, int encRevision, int keyLength,
43 GString *ownerKey, GString *userKey,
44 int permissions, GString *fileID,
45 GString *ownerPassword, GString *userPassword,
46 Guchar *fileKey, GBool encryptMetadata,
47 GBool *ownerPasswordOk);
48
49 private:
50
51 static GBool makeFileKey2(int encVersion, int encRevision, int keyLength,
52 GString *ownerKey, GString *userKey,
53 int permissions, GString *fileID,
54 GString *userPassword, Guchar *fileKey,
55 GBool encryptMetadata);
56
57 int objKeyLength;
58 Guchar objKey[21];
59 Guchar state[256];
60 Guchar x, y;
61 };
62
63 #endif