summaryrefslogtreecommitdiff
path: root/source/fitz
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/fitz
parent1724a8ccd667c6ec468e2e8a01161c32bf59d706 (diff)
downloadmupdf-e0b23f941efd7412640cebe71a82a7df170388b2.tar.xz
Use namespace for AES crypto code.
Diffstat (limited to 'source/fitz')
-rw-r--r--source/fitz/crypt-aes.c28
-rw-r--r--source/fitz/filter-basic.c4
2 files changed, 16 insertions, 16 deletions
diff --git a/source/fitz/crypt-aes.c b/source/fitz/crypt-aes.c
index cc298731..87af5626 100644
--- a/source/fitz/crypt-aes.c
+++ b/source/fitz/crypt-aes.c
@@ -176,7 +176,7 @@ static void aes_gen_tables( void )
/*
* AES key schedule (encryption)
*/
-int aes_setkey_enc( aes_context *ctx, const unsigned char *key, int keysize )
+int fz_aes_setkey_enc( aes_context *ctx, const unsigned char *key, int keysize )
{
int i;
unsigned long *RK;
@@ -280,7 +280,7 @@ int aes_setkey_enc( aes_context *ctx, const unsigned char *key, int keysize )
/*
* AES key schedule (decryption)
*/
-int aes_setkey_dec(aes_context *ctx, const unsigned char *key, int keysize)
+int fz_aes_setkey_dec(aes_context *ctx, const unsigned char *key, int keysize)
{
int i, j;
aes_context cty;
@@ -301,7 +301,7 @@ int aes_setkey_dec(aes_context *ctx, const unsigned char *key, int keysize)
ctx->rk = RK = ctx->buf;
#endif
- i = aes_setkey_enc( &cty, key, keysize );
+ i = fz_aes_setkey_enc( &cty, key, keysize );
if (i)
return i;
SK = cty.rk + cty.nr * 4;
@@ -380,7 +380,7 @@ int aes_setkey_dec(aes_context *ctx, const unsigned char *key, int keysize)
/*
* AES-ECB block encryption/decryption
*/
-void aes_crypt_ecb( aes_context *ctx,
+void fz_aes_crypt_ecb( aes_context *ctx,
int mode,
const unsigned char input[16],
unsigned char output[16] )
@@ -403,7 +403,7 @@ void aes_crypt_ecb( aes_context *ctx,
GET_ULONG_LE( X2, input, 8 ); X2 ^= *RK++;
GET_ULONG_LE( X3, input, 12 ); X3 ^= *RK++;
- if( mode == AES_DECRYPT )
+ if( mode == FZ_AES_DECRYPT )
{
for( i = (ctx->nr >> 1) - 1; i > 0; i-- )
{
@@ -433,7 +433,7 @@ void aes_crypt_ecb( aes_context *ctx,
( RSb[ ( Y1 >> 16 ) & 0xFF ] << 16 ) ^
( RSb[ ( Y0 >> 24 ) & 0xFF ] << 24 );
}
- else /* AES_ENCRYPT */
+ else /* FZ_AES_ENCRYPT */
{
for( i = (ctx->nr >> 1) - 1; i > 0; i-- )
{
@@ -473,7 +473,7 @@ void aes_crypt_ecb( aes_context *ctx,
/*
* AES-CBC buffer encryption/decryption
*/
-void aes_crypt_cbc( aes_context *ctx,
+void fz_aes_crypt_cbc( aes_context *ctx,
int mode,
size_t length,
unsigned char iv[16],
@@ -491,12 +491,12 @@ void aes_crypt_cbc( aes_context *ctx,
}
#endif
- if( mode == AES_DECRYPT )
+ if( mode == FZ_AES_DECRYPT )
{
while( length > 0 )
{
memcpy( temp, input, 16 );
- aes_crypt_ecb( ctx, mode, input, output );
+ fz_aes_crypt_ecb( ctx, mode, input, output );
for( i = 0; i < 16; i++ )
output[i] = (unsigned char)( output[i] ^ iv[i] );
@@ -515,7 +515,7 @@ void aes_crypt_cbc( aes_context *ctx,
for( i = 0; i < 16; i++ )
output[i] = (unsigned char)( input[i] ^ iv[i] );
- aes_crypt_ecb( ctx, mode, output, output );
+ fz_aes_crypt_ecb( ctx, mode, output, output );
memcpy( iv, output, 16 );
input += 16;
@@ -528,7 +528,7 @@ void aes_crypt_cbc( aes_context *ctx,
/*
* AES-CFB buffer encryption/decryption
*/
-void aes_crypt_cfb( aes_context *ctx,
+void fz_aes_crypt_cfb( aes_context *ctx,
int mode,
int length,
int *iv_off,
@@ -538,12 +538,12 @@ void aes_crypt_cfb( aes_context *ctx,
{
int c, n = *iv_off;
- if( mode == AES_DECRYPT )
+ if( mode == FZ_AES_DECRYPT )
{
while( length-- )
{
if( n == 0 )
- aes_crypt_ecb( ctx, AES_ENCRYPT, iv, iv );
+ fz_aes_crypt_ecb( ctx, FZ_AES_ENCRYPT, iv, iv );
c = *input++;
*output++ = (unsigned char)( c ^ iv[n] );
@@ -557,7 +557,7 @@ void aes_crypt_cfb( aes_context *ctx,
while( length-- )
{
if( n == 0 )
- aes_crypt_ecb( ctx, AES_ENCRYPT, iv, iv );
+ fz_aes_crypt_ecb( ctx, FZ_AES_ENCRYPT, iv, iv );
iv[n] = *output++ = (unsigned char)( iv[n] ^ *input++ );
diff --git a/source/fitz/filter-basic.c b/source/fitz/filter-basic.c
index 0bc5525a..e3fa1ffa 100644
--- a/source/fitz/filter-basic.c
+++ b/source/fitz/filter-basic.c
@@ -656,7 +656,7 @@ next_aesd(fz_context *ctx, fz_stream *stm, size_t max)
else if (n < 16)
fz_throw(ctx, FZ_ERROR_GENERIC, "partial block in aes filter");
- aes_crypt_cbc(&state->aes, AES_DECRYPT, 16, state->iv, state->bp, state->bp);
+ fz_aes_crypt_cbc(&state->aes, FZ_AES_DECRYPT, 16, state->iv, state->bp, state->bp);
state->rp = state->bp;
state->wp = state->bp + 16;
@@ -704,7 +704,7 @@ fz_open_aesd(fz_context *ctx, fz_stream *chain, unsigned char *key, unsigned key
{
state = fz_malloc_struct(ctx, fz_aesd);
state->chain = chain;
- if (aes_setkey_dec(&state->aes, key, keylen * 8))
+ if (fz_aes_setkey_dec(&state->aes, key, keylen * 8))
fz_throw(ctx, FZ_ERROR_GENERIC, "AES key init failed (keylen=%d)", keylen * 8);
state->ivcount = 0;
state->rp = state->bp;