summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-crypt.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/pdf/pdf-crypt.c')
-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);