summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-crypt.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2017-04-24 11:28:32 +0200
committerTor Andersson <tor.andersson@artifex.com>2017-04-27 12:02:58 +0200
commite0b23f941efd7412640cebe71a82a7df170388b2 (patch)
tree2b296a491f5cd59fe9b9045a0ae52e4b6c960b5f /source/pdf/pdf-crypt.c
parent1724a8ccd667c6ec468e2e8a01161c32bf59d706 (diff)
downloadmupdf-e0b23f941efd7412640cebe71a82a7df170388b2.tar.xz
Use namespace for AES crypto code.
Diffstat (limited to 'source/pdf/pdf-crypt.c')
-rw-r--r--source/pdf/pdf-crypt.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/source/pdf/pdf-crypt.c b/source/pdf/pdf-crypt.c
index 8dfeb9ad..0d78844b 100644
--- a/source/pdf/pdf-crypt.c
+++ b/source/pdf/pdf-crypt.c
@@ -467,9 +467,9 @@ pdf_compute_encryption_key_r5(fz_context *ctx, pdf_crypt *crypt, unsigned char *
/* clear password buffer and use it as iv */
memset(buffer + 32, 0, sizeof(buffer) - 32);
- if (aes_setkey_dec(&aes, buffer, crypt->length))
+ if (fz_aes_setkey_dec(&aes, buffer, crypt->length))
fz_throw(ctx, FZ_ERROR_GENERIC, "AES key init failed (keylen=%d)", crypt->length);
- aes_crypt_cbc(&aes, AES_DECRYPT, 32, buffer + 32, ownerkey ? crypt->oe : crypt->ue, crypt->key);
+ fz_aes_crypt_cbc(&aes, FZ_AES_DECRYPT, 32, buffer + 32, ownerkey ? crypt->oe : crypt->ue, crypt->key);
}
/*
@@ -513,9 +513,9 @@ pdf_compute_hardened_hash_r6(fz_context *ctx, unsigned char *password, size_t pw
memcpy(data + j * data_len, data, data_len);
/* Step 3: encrypt data using data block as key and iv */
- if (aes_setkey_enc(&aes, block, 128))
+ if (fz_aes_setkey_enc(&aes, block, 128))
fz_throw(ctx, FZ_ERROR_GENERIC, "AES key init failed (keylen=%d)", 128);
- aes_crypt_cbc(&aes, AES_ENCRYPT, data_len * 64, block + 16, data, data);
+ fz_aes_crypt_cbc(&aes, FZ_AES_ENCRYPT, data_len * 64, block + 16, data, data);
/* Step 4: determine SHA-2 hash size for this round */
for (j = 0, sum = 0; j < 16; j++)
@@ -566,10 +566,9 @@ pdf_compute_encryption_key_r6(fz_context *ctx, pdf_crypt *crypt, unsigned char *
hash);
memset(iv, 0, sizeof(iv));
- if (aes_setkey_dec(&aes, hash, 256))
+ if (fz_aes_setkey_dec(&aes, hash, 256))
fz_throw(ctx, FZ_ERROR_GENERIC, "AES key init failed (keylen=256)");
- aes_crypt_cbc(&aes, AES_DECRYPT, 32, iv,
- ownerkey ? crypt->oe : crypt->ue, crypt->key);
+ fz_aes_crypt_cbc(&aes, FZ_AES_DECRYPT, 32, iv, ownerkey ? crypt->oe : crypt->ue, crypt->key);
}
/*
@@ -948,9 +947,9 @@ pdf_crypt_obj_imp(fz_context *ctx, pdf_crypt *crypt, pdf_obj *obj, unsigned char
unsigned char iv[16];
fz_aes aes;
memcpy(iv, s, 16);
- if (aes_setkey_dec(&aes, key, keylen * 8))
+ if (fz_aes_setkey_dec(&aes, key, keylen * 8))
fz_throw(ctx, FZ_ERROR_GENERIC, "AES key init failed (keylen=%d)", keylen * 8);
- aes_crypt_cbc(&aes, AES_DECRYPT, n - 16, iv, s + 16, s);
+ fz_aes_crypt_cbc(&aes, FZ_AES_DECRYPT, n - 16, iv, s + 16, s);
/* delete space used for iv and padding bytes at end */
if (s[n - 17] < 1 || s[n - 17] > 16)
fz_warn(ctx, "aes padding out of range");