| 1 |
/* This is DVIPDFMx, an eXtended version of DVIPDFM by Mark A. Wicks. |
| 2 |
|
| 3 |
Copyright (C) 2003-2020 by Jin-Hwan Cho and Shunsaku Hirata, |
| 4 |
the dvipdfmx project team. |
| 5 |
|
| 6 |
This program is free software; you can redistribute it and/or modify |
| 7 |
it under the terms of the GNU General Public License as published by |
| 8 |
the Free Software Foundation; either version 2 of the License, or |
| 9 |
(at your option) any later version. |
| 10 |
|
| 11 |
This program is distributed in the hope that it will be useful, |
| 12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
GNU General Public License for more details. |
| 15 |
|
| 16 |
You should have received a copy of the GNU General Public License |
| 17 |
along with this program; if not, write to the Free Software |
| 18 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef _DPXCRYPT_H_ |
| 22 |
#define _DPXCRYPT_H_ |
| 23 |
|
| 24 |
#include <stdio.h> |
| 25 |
#ifdef HAVE_INTTYPES_H |
| 26 |
# include <inttypes.h> |
| 27 |
#endif |
| 28 |
#ifdef HAVE_STDINT_H |
| 29 |
# include <stdint.h> |
| 30 |
#endif |
| 31 |
|
| 32 |
/* libgcrypt md5 */ |
| 33 |
typedef struct { |
| 34 |
uint32_t A, B, C, D; /* chaining variables */ |
| 35 |
size_t nblocks; |
| 36 |
unsigned char buf[64]; |
| 37 |
int count; |
| 38 |
} MD5_CONTEXT; |
| 39 |
|
| 40 |
void MD5_init (MD5_CONTEXT *ctx); |
| 41 |
void MD5_write(MD5_CONTEXT *ctx, const unsigned char *inbuf, unsigned int inlen); |
| 42 |
void MD5_final(unsigned char *outbuf, MD5_CONTEXT *ctx); |
| 43 |
|
| 44 |
typedef struct { |
| 45 |
uint32_t h0,h1,h2,h3,h4,h5,h6,h7; |
| 46 |
size_t nblocks; |
| 47 |
unsigned char buf[64]; |
| 48 |
int count; |
| 49 |
} SHA256_CONTEXT; |
| 50 |
|
| 51 |
typedef struct |
| 52 |
{ |
| 53 |
uint64_t h0, h1, h2, h3, h4, h5, h6, h7; |
| 54 |
} SHA512_STATE; |
| 55 |
|
| 56 |
typedef struct |
| 57 |
{ |
| 58 |
SHA512_STATE state; |
| 59 |
size_t nblocks; |
| 60 |
unsigned char buf[128]; |
| 61 |
int count; |
| 62 |
} SHA512_CONTEXT; |
| 63 |
|
| 64 |
void SHA256_init (SHA256_CONTEXT *ctx); |
| 65 |
void SHA256_write(SHA256_CONTEXT *ctx, |
| 66 |
const unsigned char *inbuf, unsigned int inlen); |
| 67 |
void SHA256_final(unsigned char *outbuf, SHA256_CONTEXT *ctx); |
| 68 |
|
| 69 |
void SHA384_init (SHA512_CONTEXT *ctx); |
| 70 |
#define SHA384_write(c,b,l) SHA512_write((c),(b),(l)) |
| 71 |
#define SHA384_final(b,c) SHA512_final((b),(c)) |
| 72 |
void SHA512_init (SHA512_CONTEXT *ctx); |
| 73 |
void SHA512_write(SHA512_CONTEXT *ctx, |
| 74 |
const unsigned char *inbuf, unsigned int inlen); |
| 75 |
void SHA512_final(unsigned char *outbuf, SHA512_CONTEXT *ctx); |
| 76 |
|
| 77 |
/* libgcrypt arcfour */ |
| 78 |
typedef struct { |
| 79 |
int idx_i, idx_j; |
| 80 |
unsigned char sbox[256]; |
| 81 |
} ARC4_CONTEXT; |
| 82 |
|
| 83 |
#define AES_BLOCKSIZE 16 |
| 84 |
|
| 85 |
void ARC4 (ARC4_CONTEXT *ctx, unsigned int len, const unsigned char *inbuf, unsigned char *outbuf); |
| 86 |
void ARC4_set_key (ARC4_CONTEXT *ctx, unsigned int keylen, const unsigned char *key); |
| 87 |
|
| 88 |
void AES_ecb_encrypt (const unsigned char *key, size_t key_len, |
| 89 |
const unsigned char *plain, size_t plain_len, |
| 90 |
unsigned char **cipher, size_t *cipher_len); |
| 91 |
|
| 92 |
void AES_cbc_encrypt (const unsigned char *key, size_t key_len, |
| 93 |
const unsigned char *iv, int padding, |
| 94 |
const unsigned char *plain, size_t plain_len, |
| 95 |
unsigned char **cipher, size_t *cipher_len); |
| 96 |
|
| 97 |
#endif /* _DPXCRYPT_H_ */ |