summaryrefslogtreecommitdiff
path: root/src/LibsslARC4Encryptor.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-11-08 00:50:07 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2011-11-08 00:50:07 +0900
commit72a1847ba88f4ba15f9ba946b4c16b39a8db003a (patch)
treefa475176f72f43b4cc7352c2f11084bffe2b8e24 /src/LibsslARC4Encryptor.cc
parentf6f053cae1e3a1788385aa3f1c59c2fe45a458da (diff)
Rewritten *ARC4Encryptor. Removed *ARC4Context.
Now *ARC4Encryptor supports in-place encryption.
Diffstat (limited to 'src/LibsslARC4Encryptor.cc')
-rw-r--r--src/LibsslARC4Encryptor.cc28
1 files changed, 6 insertions, 22 deletions
diff --git a/src/LibsslARC4Encryptor.cc b/src/LibsslARC4Encryptor.cc
index f128fe5a..fcbf29dc 100644
--- a/src/LibsslARC4Encryptor.cc
+++ b/src/LibsslARC4Encryptor.cc
@@ -34,39 +34,23 @@
/* copyright --> */
#include "LibsslARC4Encryptor.h"
-#include <openssl/err.h>
-
-#include "DlAbortEx.h"
-#include "fmt.h"
-
namespace aria2 {
-namespace {
-void handleError()
-{
- throw DL_ABORT_EX
- (fmt("Exception in libssl routine(ARC4Encryptor class): %s",
- ERR_error_string(ERR_get_error(), 0)));
-}
-} // namespace
-
ARC4Encryptor::ARC4Encryptor() {}
ARC4Encryptor::~ARC4Encryptor() {}
void ARC4Encryptor::init(const unsigned char* key, size_t keyLength)
{
- ctx_.init(key, keyLength, 1);
+ RC4_set_key(&key_, keyLength, key);
}
-void ARC4Encryptor::encrypt(unsigned char* out, size_t outLength,
- const unsigned char* in, size_t inLength)
+void ARC4Encryptor::encrypt
+(size_t len,
+ unsigned char* out,
+ const unsigned char* in)
{
- int soutLength = outLength;
- if(!EVP_CipherUpdate(ctx_.getCipherContext(), out, &soutLength,
- in, inLength)) {
- handleError();
- }
+ RC4(&key_, len, in, out);
}
} // namespace aria2