summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-11-20 11:46:51 +0800
committerIru Cai <mytbk920423@gmail.com>2018-11-20 11:46:51 +0800
commit5c9b2ab761bb8aedda619e6fab62e08c1a32374f (patch)
tree51eb53b87fa77e1812865f35f248e0314c27a948
parent9d043aa1e110021b91593cdbea4954faf2572d46 (diff)
downloadmupdf-5c9b2ab761bb8aedda619e6fab62e08c1a32374f.tar.xz
hash r_buf
-rw-r--r--source/pdf/pdf-crypt.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/source/pdf/pdf-crypt.c b/source/pdf/pdf-crypt.c
index a8a1bdb5..b9cbc05f 100644
--- a/source/pdf/pdf-crypt.c
+++ b/source/pdf/pdf-crypt.c
@@ -294,7 +294,7 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
obj = pdf_dict_gets(ctx, dict, "Recipients");
if (pdf_is_string(ctx, obj)) {
unsigned char idstr[32];
- int l = pdf_to_str_len(ctx, obj);
+ r_size = pdf_to_str_len(ctx, obj);
if (pdf_is_array(ctx, id) && pdf_array_len(ctx, id) == 2)
{
@@ -320,22 +320,23 @@ pdf_new_crypt(fz_context *ctx, pdf_obj *dict, pdf_obj *id)
fz_warn(ctx, "length of id[1] is %ld", osz);
}
}
- r_buf = fz_malloc(ctx, l);
- memcpy(r_buf, pdf_to_str_buf(ctx, obj), l);
+ r_buf = fz_malloc(ctx, r_size);
+ memcpy(r_buf, pdf_to_str_buf(ctx, obj), r_size);
unsigned char tmpbyte = 0xff;
int ididx = 0;
- for (int i = 0; i < l; i++) {
+ for (int i = 0; i < r_size; i++) {
tmpbyte ^= idstr[ididx];
ididx = (ididx + 1) % 32;
r_buf[i] ^= tmpbyte;
- // printf("%c", r_buf[i]);
}
}
/* hash some weird thing */
- /* hash an XML */
+ fz_sha256_update(&sha256, r_buf, r_size);
+
fz_sha256_init(&xml_hash);
- /* hash an XML */
+ fz_sha256_update(&xml_hash, r_buf, r_size);
fz_sha256_final(&xml_hash, xml_hash_sum);
+
fz_sha256_update(&sha256, xml_hash_sum, 32);
fz_sha256_final(&sha256, crypt->key);