8 #include <botan/internal/openssl_engine.h> 9 #include <botan/parsing.h> 10 #include <openssl/opensslconf.h> 11 #if !defined(OPENSSL_NO_RC4) 12 #include <openssl/rc4.h> 17 #if !defined(OPENSSL_NO_RC4) 23 class ARC4_OpenSSL :
public StreamCipher
26 void clear() { std::memset(&state, 0,
sizeof(state)); }
27 std::string name()
const;
28 StreamCipher* clone()
const {
return new ARC4_OpenSSL(SKIP); }
30 Key_Length_Specification key_spec()
const 32 return Key_Length_Specification(1, 32);
36 ARC4_OpenSSL(
size_t s = 0) : SKIP(s) { clear(); }
37 ~ARC4_OpenSSL() { clear(); }
39 void cipher(
const byte[],
byte[],
size_t);
40 void key_schedule(
const byte[],
size_t);
49 std::string ARC4_OpenSSL::name()
const 51 if(SKIP == 0)
return "ARC4";
52 if(SKIP == 256)
return "MARK-4";
53 else return "RC4_skip(" +
to_string(SKIP) +
")";
59 void ARC4_OpenSSL::key_schedule(
const byte key[],
size_t length)
61 RC4_set_key(&state, length, key);
63 for(
size_t i = 0; i != SKIP; ++i)
64 RC4(&state, 1, &dummy, &dummy);
70 void ARC4_OpenSSL::cipher(
const byte in[],
byte out[],
size_t length)
72 RC4(&state, length, in, out);
85 #if !defined(OPENSSL_NO_RC4) 89 return new ARC4_OpenSSL(768);
size_t arg_as_integer(size_t i, size_t def_value) const
StreamCipher * find_stream_cipher(const SCAN_Name &, Algorithm_Factory &) const
std::string to_string(u64bit n, size_t min_len)
std::string algo_name() const