summaryrefslogtreecommitdiff
path: root/source/pdf
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-11-20 16:54:49 +0800
committerIru Cai <mytbk920423@gmail.com>2018-11-20 16:55:57 +0800
commit2b297f64907f7fcb0ca5c3f67024c49d9d72ba0d (patch)
tree71cf594e419c2a256c8dce870de7c94608b4bf60 /source/pdf
parentf7e1c05ffedf547eddeb444bc494269456825be8 (diff)
downloadmupdf-2b297f64907f7fcb0ca5c3f67024c49d9d72ba0d.tar.xz
final fix - it works!!
Diffstat (limited to 'source/pdf')
-rw-r--r--source/pdf/pdf-crypt.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/source/pdf/pdf-crypt.c b/source/pdf/pdf-crypt.c
index 36ddab0d..5341bff7 100644
--- a/source/pdf/pdf-crypt.c
+++ b/source/pdf/pdf-crypt.c
@@ -503,17 +503,14 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
}
if (crypt->xjc) {
-#if 0
- unsigned char akey[] = "\xCE\x69\x16\xAC\xD3\xA5\x00\x85\xF2\xD0\x22\x2A\x9C\xCE\x64\x4F\x65\xDF\x47\xE4\xE3\x6C\x24\x2B\x1B\x31\x6A\x3D\x3B\xE2\x20\xCC";
-#endif
fz_sha256 sha256;
fz_sha256 xml_hash;
+ fz_sha256 final_hash;
unsigned char xml_hash_sum[32];
unsigned char *r_buf = NULL;
size_t r_size = 0;
mt19937 mtctx;
- // crypt->encrypt_metadata = 0;
obj = pdf_dict_get(ctx, dict, PDF_NAME(Length));
if (pdf_is_int(ctx, obj))
crypt->length = pdf_to_int(ctx, obj);
@@ -523,9 +520,11 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
crypt->strf.method = PDF_CRYPT_AESV3;
crypt->strf.length = crypt->length;
- fz_sha256_update(&sha256, "ProfXJC.General", 15);
fz_warn(ctx, "crypt method: %d, crypt length: %d, crypt perm: %x",
crypt->stmf.method, crypt->length, crypt->p);
+
+ fz_sha256_init(&sha256);
+ fz_sha256_update(&sha256, "ProfXJC.General", 15);
fz_sha256_update(&sha256, &crypt->stmf.method, 4);
unsigned char lenbytes[4] = { crypt->length / 8, 0, 0, 0 };
fz_sha256_update(&sha256, lenbytes, 4);
@@ -603,7 +602,11 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
fz_sha256_update(&sha256, xml_hash_sum, 32);
fz_sha256_final(&sha256, crypt->key);
- // memcpy(crypt->key, akey, 32); /* TODO: kill this */
+ for (int i = 0; i < 43; i++) {
+ fz_sha256_init(&final_hash);
+ fz_sha256_update(&final_hash, crypt->key, 32);
+ fz_sha256_final(&final_hash, crypt->key);
+ }
return crypt;
}
return crypt;