/* */ #include "LibgcryptARC4Encryptor.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(ARC4Encryptor class): %s", gcry_strerror(err))); } } // namespace ARC4Encryptor::ARC4Encryptor() {} ARC4Encryptor::~ARC4Encryptor() {} void ARC4Encryptor::init(const unsigned char* key, size_t keyLength) { ctx_.init(key, keyLength); } void ARC4Encryptor::encrypt(unsigned char* out, size_t outLength, const unsigned char* in, size_t inLength) { gcry_error_t r = gcry_cipher_encrypt(ctx_.getCipherContext(), out, outLength, in, inLength); if(r) { handleError(r); } } } // namespace aria2