/* */ #include "LibgcryptARC4Decryptor.h" #include #include "DlAbortEx.h" #include "fmt.h" namespace aria2 { namespace { void handleError(gcry_error_t err) { throw DL_ABORT_EX (fmt("Exception in libgcrypt routine(ARC4Decryptor class): %s", gcry_strerror(err))); } } // namespace ARC4Decryptor::ARC4Decryptor() {} ARC4Decryptor::~ARC4Decryptor() {} void ARC4Decryptor::init(const unsigned char* key, size_t keyLength) { ctx_.init(key, keyLength); } void ARC4Decryptor::decrypt (unsigned char* out, size_t outLength, const unsigned char* in, size_t inLength) { gcry_error_t r = gcry_cipher_decrypt(ctx_.getCipherContext(), out, outLength, in, inLength); if(r) { handleError(r); } } } // namespace aria2