2019-11-04 14:04:25 +00:00
|
|
|
#ifndef RC4_NATIVE_HH
|
|
|
|
#define RC4_NATIVE_HH
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2019-11-04 14:04:25 +00:00
|
|
|
#include <cstring>
|
2019-06-21 03:35:23 +00:00
|
|
|
|
2019-11-04 14:04:25 +00:00
|
|
|
class RC4_native
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// key_len of -1 means treat key_data as a null-terminated string
|
2019-11-04 14:04:25 +00:00
|
|
|
RC4_native(unsigned char const* key_data, int key_len = -1);
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
// out_data = 0 means to encrypt/decrypt in place
|
2022-05-03 21:43:07 +00:00
|
|
|
void process(unsigned char const* in_data, size_t len, unsigned char* out_data = 0);
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
class RC4Key
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
unsigned char state[256];
|
|
|
|
unsigned char x;
|
|
|
|
unsigned char y;
|
|
|
|
};
|
|
|
|
|
|
|
|
RC4Key key;
|
|
|
|
};
|
|
|
|
|
2019-11-04 14:04:25 +00:00
|
|
|
#endif // RC4_NATIVE_HH
|