13#ifndef _PDF_ENCRYPT_H_
14#define _PDF_ENCRYPT_H_
49 void GenerateEncryptionKey(
const wxString& userPassword,
50 const wxString& ownerPassword,
52 const wxString& documentId = wxEmptyString);
69 bool Authenticate(
const wxString& documentID,
const wxString& password,
70 const wxString& uValue,
const wxString& oValue,
71 const wxString& ueValue,
const wxString& oeValue,
const wxString& permsValue,
72 int pValue,
int lengthValue,
int rValue,
int vValue);
79 bool PasswordIsValid(
const wxString& password)
const;
85 const std::string&
GetUValue()
const {
return m_uValue; }
97 const std::string&
GetOValue()
const {
return m_oValue; }
135 void Encrypt(
int n,
int g, wxString& str);
143 void Decrypt(
int n,
int g, wxString& str);
152 void Encrypt(
int n,
int g,
unsigned char* str,
unsigned int len);
161 int Decrypt(
int n,
int g,
unsigned char* str,
unsigned int len);
168 size_t CalculateStreamLength(
size_t length);
174 size_t CalculateStreamOffset();
186 static wxString CreateDocumentId();
190 std::string PadPassword(
const wxString& password);
193 std::string ComputeOwnerKey(
const std::string& userPad,
const std::string& ownerPad,
194 unsigned int keylength,
int revision,
bool authenticate);
197 std::string ComputeEncryptionKey(
const wxString& documentID,
198 const std::string& userPad,
const std::string& ownerKey,
199 int pValue,
unsigned int keyLength,
int revision);
202 bool CheckKey(
const std::string& key1,
const std::string& key2);
205 void RC4(
unsigned char*
key,
unsigned int keylen,
206 const unsigned char* textin,
unsigned int textlen,
207 unsigned char* textout);
210 void AESEncrypt(
unsigned char*
key,
unsigned int keylen,
211 unsigned char* textin,
unsigned int textlen,
212 unsigned char* textout);
215 int AESDecrypt(
unsigned char*
key,
unsigned int keylen,
216 unsigned char* textin,
unsigned int textlen,
217 unsigned char* textout);
220 void AESV3Encrypt(
const unsigned char*
key,
unsigned int keylen,
221 const unsigned char* textin,
unsigned int textlen,
222 unsigned char* textout);
225 int AESV3Decrypt(
const unsigned char*
key,
unsigned int keylen,
226 unsigned char* textin,
unsigned int textlen,
227 unsigned char* textout);
230 static void GetMD5Binary(
const unsigned char* data,
unsigned int length,
unsigned char* digest);
233 static void GenerateInitialVector(
unsigned char iv[16]);
237 void ComputeEncryptionParameters(
const wxString& userPassword,
const wxString& ownerPassword);
240 void ComputeEncryptionParametersV5(
const wxString& userPassword,
const wxString& ownerPassword);
243 std::string PreparePasswordV5(
const std::string& password);
246 void ComputeUandUEforV5(
const std::string& userPassword,
const std::string& encryptionKey);
249 void ComputeOandOEforV5(
const std::string& ownerPassword,
const std::string& encryptionKey);
252 void ComputePermsV5(
const std::string& encryptionKey);
255 std::string HashV5(
const std::string& password,
const std::string& salt,
const std::string& udata);
258 bool CheckEncryptionParameters(
const wxString& password);
261 bool CheckEncryptionParametersV5(
const wxString& password);
264 bool CheckOwnerPasswordV5(
const std::string& password);
267 bool CheckUserPasswordV5(
const std::string& userPassword);
269 wxString m_documentId;
270 std::string m_uValue;
271 std::string m_oValue;
275 unsigned char m_encryptionKey[16];
276 unsigned int m_keyLength;
277 unsigned char m_rc4key[16];
278 unsigned char m_rc4last[256];
282 std::string m_uValidSalt;
283 std::string m_uKeySalt;
286 std::string m_oValidSalt;
287 std::string m_oKeySalt;
288 std::string m_permsValue;
289 std::string m_fileEncryptionKey;
290 bool m_encryptMetaData;
Class representing PDF encryption methods. (For internal use only)
Definition: pdfencrypt.h:30
unsigned int GetKeyLength() const
Get the key length of the encryption key in bits.
Definition: pdfencrypt.h:127
int GetRevision() const
Get the revision number of the encryption method.
Definition: pdfencrypt.h:121
const std::string & GetPermsValue() const
Get the Perms object value (protection)
Definition: pdfencrypt.h:115
const std::string & GetUValue() const
Get the U object value (user)
Definition: pdfencrypt.h:85
int GetPValue() const
Get the P object value (protection)
Definition: pdfencrypt.h:109
const std::string & GetUEValue() const
Get the UE object value (user)
Definition: pdfencrypt.h:91
const std::string & GetOEValue() const
Get the OE object value (owner)
Definition: pdfencrypt.h:103
const std::string & GetOValue() const
Get the O object value (owner)
Definition: pdfencrypt.h:97
wxString GetDocumentId() const
Get document id.
Definition: pdfencrypt.h:180
Definition: pdfencrypt.cpp:45
Class implementing the Rijndael cipher. (For internal use only)
Definition: pdfrijndael.h:104
Class representing SHA2 hashing methods. (For internal use only)
Definition: pdfencrypt.h:299
Compile time switches for the wxPdfDocument component.