Pajdeg
0.2.2
Pajdeg
|
Cryptography related functionality to deal with encrypted PDF content. More...
Files | |
file | pd_crypto.h |
Typedefs | |
typedef struct pd_crypto * | pd_crypto |
Functions | |
pd_crypto | pd_crypto_create (PDDictionaryRef trailerDict, PDDictionaryRef options) |
void | pd_crypto_destroy (pd_crypto crypto) |
PDInteger | pd_crypto_unescape (char *str) |
PDInteger | pd_crypto_unescape_explicit_len (char *str, int len) |
PDInteger | pd_crypto_escape (char **dst, const char *src, PDInteger srcLen) |
PDInteger | pd_crypto_secure (char **dst, const char *src, PDInteger srcLen) |
PDBool | pd_crypto_authenticate_user (pd_crypto crypto, const char *password) |
PDInteger | pd_crypto_encrypt (pd_crypto crypto, PDInteger obid, PDInteger genid, char **dst, char *src, PDInteger len) |
void | pd_crypto_decrypt (pd_crypto crypto, PDInteger obid, PDInteger genid, char *data) |
void | pd_crypto_convert (pd_crypto crypto, PDInteger obid, PDInteger genid, char *data, PDInteger len) |
PDStringRef | pd_crypto_get_filter (pd_crypto crypto) |
PDStringRef | pd_crypto_get_subfilter (pd_crypto crypto) |
PDInteger | pd_crypto_get_version (pd_crypto crypto) |
PDInteger | pd_crypto_get_revision (pd_crypto crypto) |
PDBool | pd_crypto_get_encrypt_metadata_bool (pd_crypto crypto) |
pd_crypto_method | pd_crypto_get_method (pd_crypto crypto) |
pd_auth_event | pd_crypto_get_auth_event (pd_crypto crypto) |
Cryptography related functionality to deal with encrypted PDF content.
The pd_crypto object.
Cryptography module for PDF encryption/decryption.
The pd_crypto object.
Supply a user password.
crypto | The crypto object. |
password | The user password. |
void pd_crypto_convert | ( | pd_crypto | crypto, |
PDInteger | obid, | ||
PDInteger | genid, | ||
char * | data, | ||
PDInteger | len | ||
) |
Convert data of length len owned by object obid with generation number genid to/from encrypted version.
This is the "low level" function used by the above two methods to encrypt/decrypt content. This version does not escape/unescape or add/remove parentheses, which the above ones do. This version is used directly for streams which aren't escaped.
crypto | Crypto instance. |
obid | Object ID of owning object. |
genid | Generation number of owning object. |
data | Data to convert. |
len | Length of data. |
pd_crypto pd_crypto_create | ( | PDDictionaryRef | trailerDict, |
PDDictionaryRef | options | ||
) |
Create crypto object with given configuration.
trailerDict | The pd_dict of the Trailer dictionary of the given PDF. Needed to obtain the /ID key. |
options | The pd_dict of the Encrypt dictionary of the given PDF. |
Decrypt, unescape and NUL-terminate the value of data in-place.
crypto | Crypto instance. |
obid | The object ID of the object whose content is being decrypted. |
genid | The generation number of the object whose content is being decrypted. |
data | The data to decrypt. The content will be in-place replaced with the new data. |
void pd_crypto_destroy | ( | pd_crypto | crypto | ) |
Destroy crypto object, freeing up resources.
PDInteger pd_crypto_encrypt | ( | pd_crypto | crypto, |
PDInteger | obid, | ||
PDInteger | genid, | ||
char ** | dst, | ||
char * | src, | ||
PDInteger | len | ||
) |
Encrypt the value of src of length len and store the value in dst, escaped and parenthesized.
crypto | Crypto instance. |
obid | The object ID of the object whose content is being encrypted. |
genid | The generation number of the object whose content is being encrypted. |
dst | Pointer to char buffer into which results will be stored. Should not be pre-allocated. |
src | The data to encrypt. The content will be in-place encrypted but escaped results go into *dst. |
len | Length of data in bytes. |
Escape a string. The result will be wrapped in parentheses.
Strings, in particular encrypted strings, are stored using escaping to prevent null termination in the middle of strings and PDF misinterpretations and other nastiness.
Escaping is done to control chars, such as ,
, , , and unreadable ascii characters using (s) (1, 2 or 3).
dst | Pointer to destination string. Should not be pre-allocated. |
src | String to escape. |
srcLen | Length of string. |
Generate a secure string from a given input string.
The input string may optionally be wrapped in parentheses. The resulting string will be, regardless of input string.
This method is roughly the equivalent of doing len = pd_crypto_unescape_explicit_len(src, srcLen); pd_crypto_escape(dst, src, len);
dst | Pointer to destination string. Should not be pre-allocated. |
src | String to escape. |
srcLen | Length of string. |
PDInteger pd_crypto_unescape | ( | char * | str | ) |
Unescape a PDF string which may optionally be wrapped in parentheses. The result is not wrapped in parentheses. The string is unescaped in-place and NUL-terminated.
Strings, in particular encrypted strings, are stored using escaping to prevent null termination in the middle of strings and PDF misinterpretations and other nastiness.
Escaping is done to control chars, such as ,
, , , and unreadable ascii characters using (s) (1, 2 or 3).
str | The string. |
PDInteger pd_crypto_unescape_explicit_len | ( | char * | str, |
int | len | ||
) |
Unescape a PDF string, explicitly defining the length of the string to allow for potential mid-NULs. May optionally be wrapped in parentheses. The result is not wrapped in parentheses. The string is unescaped in-place and NUL-terminated.
Strings, in particular encrypted strings, are stored using escaping to prevent null termination in the middle of strings and PDF misinterpretations and other nastiness.
Escaping is done to control chars, such as ,
, , , and unreadable ascii characters using (s) (1, 2 or 3).
str | The string. |
len | The length of the string; |