diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2012-10-08 03:31:55 +0200 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-10-08 16:57:43 +0100 |
commit | 6a7a1f2772a0468055f0d4c31777c8d80e206fa7 (patch) | |
tree | e8208129eb334a89f5bf7780eadeaa8e58046e5d /fitz | |
parent | c03ad411e17d07d27b498a54e2854e035b78e479 (diff) | |
download | mupdf-6a7a1f2772a0468055f0d4c31777c8d80e206fa7.tar.xz |
Fix SHA-384/-512 hash algorithm typos
These prevented PDF 1.7 ExtensionLevel 8 encryption algorithm from
working as intended.
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/crypt_sha2.c | 8 | ||||
-rw-r--r-- | fitz/fitz-internal.h | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/fitz/crypt_sha2.c b/fitz/crypt_sha2.c index 8d6dcbe1..1a91fdda 100644 --- a/fitz/crypt_sha2.c +++ b/fitz/crypt_sha2.c @@ -338,14 +338,14 @@ void fz_sha512_update(fz_sha512 *context, const unsigned char *input, unsigned i } } -void fz_sha512_final(fz_sha512 *context, unsigned char digest[128]) +void fz_sha512_final(fz_sha512 *context, unsigned char digest[64]) { /* Add padding as described in RFC 3174 (it describes SHA-1 but * the same padding style is used for SHA-512 too). */ unsigned int j = context->count[0] & 0x7F; context->buffer.u8[j++] = 0x80; - while (j != 120) + while (j != 112) { if (j == 128) { @@ -363,7 +363,7 @@ void fz_sha512_final(fz_sha512 *context, unsigned char digest[128]) context->buffer.u64[15] = bswap64(context->count[0]); transform512(context->state, context->buffer.u64); - for (j = 0; j < 16; j++) + for (j = 0; j < 8; j++) ((uint64_t *)digest)[j] = bswap64(context->state[j]); memset(context, 0, sizeof(fz_sha512)); } @@ -387,7 +387,7 @@ void fz_sha384_update(fz_sha384 *context, const unsigned char *input, unsigned i fz_sha512_update(context, input, inlen); } -void fz_sha384_final(fz_sha384 *context, unsigned char digest[48]) +void fz_sha384_final(fz_sha384 *context, unsigned char digest[64]) { fz_sha512_final(context, digest); } diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h index 08e9d896..e2e75407 100644 --- a/fitz/fitz-internal.h +++ b/fitz/fitz-internal.h @@ -331,7 +331,7 @@ struct fz_sha512_s void fz_sha512_init(fz_sha512 *state); void fz_sha512_update(fz_sha512 *state, const unsigned char *input, unsigned int inlen); -void fz_sha512_final(fz_sha512 *state, unsigned char digest[32]); +void fz_sha512_final(fz_sha512 *state, unsigned char digest[64]); /* sha-384 digests */ @@ -339,7 +339,7 @@ typedef struct fz_sha512_s fz_sha384; void fz_sha384_init(fz_sha384 *state); void fz_sha384_update(fz_sha384 *state, const unsigned char *input, unsigned int inlen); -void fz_sha384_final(fz_sha384 *state, unsigned char digest[32]); +void fz_sha384_final(fz_sha384 *state, unsigned char digest[64]); /* arc4 crypto */ |