/* */ #ifndef _D_LIBSSL_ARC4_DECRYPTOR_H_ #define _D_LIBSSL_ARC4_DECRYPTOR_H_ #include "common.h" #include "DlAbortEx.h" #include "LibsslARC4Context.h" #include #include namespace aria2 { class ARC4Decryptor { private: LibsslARC4Context _ctx; void handleError() const { throw new DlAbortEx("Exception in libssl routine(ARC4Decryptor class): %s", ERR_error_string(ERR_get_error(), 0)); } public: ARC4Decryptor() {} ~ARC4Decryptor() {} void init(const unsigned char* key, size_t keyLength) { _ctx.init(key, keyLength, 0); } void decrypt(unsigned char* out, size_t outLength, const unsigned char* in, size_t inLength) { int soutLength = outLength; if(!EVP_CipherUpdate(_ctx.getCipherContext(), out, &soutLength, in, inLength)) { handleError(); } } }; } // namespace aria2 #endif // _D_LIBSSL_ARC4_DECRYPTOR_H_