Skip to content

Commit

Permalink
Add SHA-256 code from RFC 6234.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Oct 8, 2021
1 parent 8aef2bf commit 9c05f80
Show file tree
Hide file tree
Showing 3 changed files with 494 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ PUBOBJS = \
pdfio-object.o \
pdfio-page.o \
pdfio-rc4.o \
pdfio-sha256.o \
pdfio-stream.o \
pdfio-string.o \
pdfio-token.o \
Expand Down
13 changes: 13 additions & 0 deletions pdfio-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ typedef struct _pdfio_rc4_s // RC4 encryption state
uint8_t i, j; // Current indices into S boxes
} _pdfio_rc4_t;

typedef struct _pdfio_sha265_s // SHA-256 hash state
{
uint32_t Intermediate_Hash[8]; // Message Digest
uint32_t Length_High; // Message length in bits
uint32_t Length_Low; // Message length in bits
int Message_Block_Index; // Message_Block array index
uint8_t Message_Block[64]; // 512-bit message blocks
int Computed; // Is the hash computed?
int Corrupted; // Cumulative corruption code
} _pdfio_sha256_t;

struct _pdfio_array_s
{
Expand Down Expand Up @@ -325,6 +335,9 @@ extern void _pdfioCryptoMD5Finish(_pdfio_md5_t *pms, uint8_t digest[16]) _PDFIO
extern void _pdfioCryptoMD5Init(_pdfio_md5_t *pms) _PDFIO_INTERNAL;
extern void _pdfioCryptoRC4Init(_pdfio_rc4_t *ctx, const uint8_t *key, size_t keylen) _PDFIO_INTERNAL;
extern void _pdfioCryptoRC4Crypt(_pdfio_rc4_t *ctx, uint8_t *buffer, size_t len) _PDFIO_INTERNAL;
extern void _pdfioCryptoSHA256Append(_pdfio_sha256_t *, const uint8_t *bytes, size_t bytecount) _PDFIO_INTERNAL;
extern void _pdfioCryptoSHA256Init(_pdfio_sha256_t *ctx) _PDFIO_INTERNAL;
extern void _pdfioCryptoSHA256Finish(_pdfio_sha256_t *ctx, uint8_t *Message_Digest) _PDFIO_INTERNAL;

extern void _pdfioDictDebug(pdfio_dict_t *dict, FILE *fp) _PDFIO_INTERNAL;
extern void _pdfioDictDelete(pdfio_dict_t *dict) _PDFIO_INTERNAL;
Expand Down
Loading

0 comments on commit 9c05f80

Please sign in to comment.