summaryrefslogtreecommitdiffstats
path: root/libqpdf/qpdf/RC4_native.hh
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-11-04 14:57:40 +0100
committerJay Berkenbilt <ejb@ql.org>2019-11-09 14:18:02 +0100
commit0cdcd10228b1845a1c66ba97527e612eed1f5e2f (patch)
tree4d69ce109ac8bd3f3d029366255bbab89df72218 /libqpdf/qpdf/RC4_native.hh
parentce8f9b6608ebcc3e88fbb1655be3e9363fa671b6 (diff)
downloadqpdf-0cdcd10228b1845a1c66ba97527e612eed1f5e2f.tar.zst
Rename RC4 implementation (non-bisectable)
Diffstat (limited to 'libqpdf/qpdf/RC4_native.hh')
-rw-r--r--libqpdf/qpdf/RC4_native.hh28
1 files changed, 28 insertions, 0 deletions
diff --git a/libqpdf/qpdf/RC4_native.hh b/libqpdf/qpdf/RC4_native.hh
new file mode 100644
index 00000000..a2aa5dce
--- /dev/null
+++ b/libqpdf/qpdf/RC4_native.hh
@@ -0,0 +1,28 @@
+#ifndef RC4_HH
+#define RC4_HH
+
+#include <stddef.h>
+
+class RC4
+{
+ public:
+ // key_len of -1 means treat key_data as a null-terminated string
+ RC4(unsigned char const* key_data, int key_len = -1);
+
+ // out_data = 0 means to encrypt/decrypt in place
+ void process(unsigned char* in_data, size_t len,
+ unsigned char* out_data = 0);
+
+ private:
+ class RC4Key
+ {
+ public:
+ unsigned char state[256];
+ unsigned char x;
+ unsigned char y;
+ };
+
+ RC4Key key;
+};
+
+#endif // RC4_HH