# Correct the needed linklibs in curl-config also.
[AROS-Contrib.git] / arospdf / xpdf / Decrypt.h
blob56f34b77f26c280ae3f93c0593867cf6573d11df
1 //========================================================================
2 //
3 // Decrypt.h
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
9 #ifndef DECRYPT_H
10 #define DECRYPT_H
12 #include <aconf.h>
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
18 #include "gtypes.h"
19 #include "GString.h"
20 #include "Object.h"
21 #include "Stream.h"
23 //------------------------------------------------------------------------
24 // Decrypt
25 //------------------------------------------------------------------------
27 class Decrypt {
28 public:
30 // Generate a file key. The <fileKey> buffer must have space for at
31 // least 16 bytes. Checks <ownerPassword> and then <userPassword>
32 // and returns true if either is correct. Sets <ownerPasswordOk> if
33 // the owner password was correct. Either or both of the passwords
34 // may be NULL, which is treated as an empty string.
35 static GBool makeFileKey(int encVersion, int encRevision, int keyLength,
36 GString *ownerKey, GString *userKey,
37 int permissions, GString *fileID,
38 GString *ownerPassword, GString *userPassword,
39 Guchar *fileKey, GBool encryptMetadata,
40 GBool *ownerPasswordOk);
42 private:
44 static GBool makeFileKey2(int encVersion, int encRevision, int keyLength,
45 GString *ownerKey, GString *userKey,
46 int permissions, GString *fileID,
47 GString *userPassword, Guchar *fileKey,
48 GBool encryptMetadata);
51 //------------------------------------------------------------------------
52 // DecryptStream
53 //------------------------------------------------------------------------
55 struct DecryptRC4State {
56 Guchar state[256];
57 Guchar x, y;
58 int buf;
61 struct DecryptAESState {
62 Guint w[44];
63 Guchar state[16];
64 Guchar cbc[16];
65 Guchar buf[16];
66 int bufIdx;
69 class DecryptStream: public FilterStream {
70 public:
72 DecryptStream(Stream *strA, Guchar *fileKey,
73 CryptAlgorithm algoA, int keyLength,
74 int objNum, int objGen);
75 virtual ~DecryptStream();
76 virtual StreamKind getKind() { return strWeird; }
77 virtual void reset();
78 virtual int getChar();
79 virtual int lookChar();
80 virtual GBool isBinary(GBool last);
81 virtual Stream *getUndecodedStream() { return this; }
83 private:
85 CryptAlgorithm algo;
86 int objKeyLength;
87 Guchar objKey[16 + 9];
89 union {
90 DecryptRC4State rc4;
91 DecryptAESState aes;
92 } state;
95 #endif