author | sandman <sandman> | 2002-04-13 00:47:20 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-04-13 00:47:20 (UTC) |
commit | 98a1e3f36567639344f12932b629e526a8783aa8 (patch) (side-by-side diff) | |
tree | 0433d296857faceeafc54f7deabddb621f45a933 /noncore/unsupported/qpdf/xpdf/Decrypt.h | |
parent | 7e31b1fba119f69929d6744d7295555ff1727f4f (diff) | |
download | opie-98a1e3f36567639344f12932b629e526a8783aa8.zip opie-98a1e3f36567639344f12932b629e526a8783aa8.tar.gz opie-98a1e3f36567639344f12932b629e526a8783aa8.tar.bz2 |
CVS import of QPdf
Diffstat (limited to 'noncore/unsupported/qpdf/xpdf/Decrypt.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/qpdf/xpdf/Decrypt.h | 59 |
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 @@ +//======================================================================== +// +// Decrypt.h +// +// Copyright 1996 Derek B. Noonburg +// +//======================================================================== + +#ifndef DECRYPT_H +#define DECRYPT_H + +#ifdef __GNUC__ +#pragma interface +#endif + +#include "gtypes.h" +#include "GString.h" + +//------------------------------------------------------------------------ +// Decrypt +//------------------------------------------------------------------------ + +class Decrypt { +public: + + // Initialize the decryptor object. + Decrypt(Guchar *fileKey, int keyLength, int objNum, int objGen); + + // Reset decryption. + void reset(); + + // Decrypt one byte. + Guchar decryptByte(Guchar c); + + // Generate a file key. The <fileKey> buffer must have space for at + // least 16 bytes. Checks <ownerPassword> and then <userPassword> + // and returns true if either is correct. Sets <ownerPasswordOk> if + // the owner password was correct. Either or both of the passwords + // may be NULL, which is treated as an empty string. + static GBool makeFileKey(int encVersion, int encRevision, int keyLength, + GString *ownerKey, GString *userKey, + int permissions, GString *fileID, + GString *ownerPassword, GString *userPassword, + Guchar *fileKey, GBool *ownerPasswordOk); + +private: + + static GBool makeFileKey2(int encVersion, int encRevision, int keyLength, + GString *ownerKey, GString *userKey, + int permissions, GString *fileID, + GString *userPassword, Guchar *fileKey); + + int objKeyLength; + Guchar objKey[21]; + Guchar state[256]; + Guchar x, y; +}; + +#endif |