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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
// -*- C++ -*-
//========================================================================
//
// Decrypt.h
//
// Copyright 1996-2002 Glyph & Cog, LLC
//
//========================================================================
#ifndef DECRYPT_H
#define DECRYPT_H
#include "aconf.h"
#ifdef USE_GCC_PRAGMAS
#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
|