diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-04-14 13:51:44 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-04-14 13:51:44 +0200 |
commit | 59bb5110e78bf15f41a58af80d716a76f3722b94 (patch) | |
tree | a962a5a7743422a2a415cc18c58930bc0e5da71a /pdf | |
parent | 997a4fcacbc0e4767d61f89d1f66b6715e6ded0e (diff) | |
download | mupdf-59bb5110e78bf15f41a58af80d716a76f3722b94.tar.xz |
Expose informational encryption details.
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/mupdf.h | 5 | ||||
-rw-r--r-- | pdf/pdf_crypt.c | 41 |
2 files changed, 46 insertions, 0 deletions
diff --git a/pdf/mupdf.h b/pdf/mupdf.h index 428bd7e9..d9d6355d 100644 --- a/pdf/mupdf.h +++ b/pdf/mupdf.h @@ -128,6 +128,11 @@ int pdf_needs_password(pdf_xref *xref); int pdf_authenticate_password(pdf_xref *xref, char *pw); int pdf_has_permission(pdf_xref *xref, int p); +int pdf_get_crypt_revision(pdf_xref *xref); +char *pdf_get_crypt_method(pdf_xref *xref); +int pdf_get_crypt_length(pdf_xref *xref); +unsigned char *pdf_get_crypt_key(pdf_xref *xref); + void pdf_debug_crypt(pdf_crypt *crypt); /* diff --git a/pdf/pdf_crypt.c b/pdf/pdf_crypt.c index edd3e985..e1243d24 100644 --- a/pdf/pdf_crypt.c +++ b/pdf/pdf_crypt.c @@ -609,6 +609,47 @@ pdf_has_permission(pdf_xref *xref, int p) return xref->crypt->p & p; } +unsigned char * +pdf_get_crypt_key(pdf_xref *xref) +{ + if (xref->crypt) + return xref->crypt->key; + return NULL; +} + +int +pdf_get_crypt_revision(pdf_xref *xref) +{ + if (xref->crypt) + return xref->crypt->v; + return 0; +} + +char * +pdf_get_crypt_method(pdf_xref *xref) +{ + if (xref->crypt) + { + switch (xref->crypt->strf.method) + { + case PDF_CRYPT_NONE: return "None"; + case PDF_CRYPT_RC4: return "RC4"; + case PDF_CRYPT_AESV2: return "AES"; + case PDF_CRYPT_AESV3: return "AES"; + case PDF_CRYPT_UNKNOWN: return "Unknown"; + } + } + return "None"; +} + +int +pdf_get_crypt_length(pdf_xref *xref) +{ + if (xref->crypt) + return xref->crypt->length; + return 0; +} + /* * PDF 1.7 algorithm 3.1 and ExtensionLevel 3 algorithm 3.1a * |