diff options
author | Tor Andersson <tor@ghostscript.com> | 2009-02-28 13:00:34 +0100 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2009-02-28 13:00:34 +0100 |
commit | f744dace3f0f91b8505979bf244453c9ec713b4b (patch) | |
tree | 86fed467944886a17d4d22038990a8fd8d2e3be8 /fitz/filt_arc4.c | |
parent | d0631f32c95f656d30c90d28c15a56b09fcc86ee (diff) | |
download | mupdf-f744dace3f0f91b8505979bf244453c9ec713b4b.tar.xz |
Moved Fitz files into one directory.
Diffstat (limited to 'fitz/filt_arc4.c')
-rw-r--r-- | fitz/filt_arc4.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/fitz/filt_arc4.c b/fitz/filt_arc4.c new file mode 100644 index 00000000..af038599 --- /dev/null +++ b/fitz/filt_arc4.c @@ -0,0 +1,47 @@ +#include "fitz-base.h" +#include "fitz-stream.h" + +typedef struct fz_arc4c_s fz_arc4c; + +struct fz_arc4c_s +{ + fz_filter super; + fz_arc4 arc4; +}; + +fz_error * +fz_newarc4filter(fz_filter **fp, unsigned char *key, unsigned keylen) +{ + FZ_NEWFILTER(fz_arc4c, f, arc4filter); + fz_arc4init(&f->arc4, key, keylen); + return fz_okay; +} + +void +fz_droparc4filter(fz_filter *f) +{ +} + +fz_error * +fz_processarc4filter(fz_filter *filter, fz_buffer *in, fz_buffer *out) +{ + fz_arc4c *f = (fz_arc4c*)filter; + int n; + + while (1) + { + if (in->rp + 1 > in->wp) { + if (in->eof) + return fz_iodone; + return fz_ioneedin; + } + if (out->wp + 1 > out->ep) + return fz_ioneedout; + + n = MIN(in->wp - in->rp, out->ep - out->wp); + fz_arc4encrypt(&f->arc4, out->wp, in->rp, n); + in->rp += n; + out->wp += n; + } +} + |