aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/plugins/openssl/openssl_crypter.c
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2009-05-14 13:53:16 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2009-05-14 13:55:56 +0200
commit24400cf617ac8c0ade033de6d4de8c41fbf2a8c0 (patch)
treea60f7c30d41f799b4cce004f1311c03cacf01fb6 /src/libstrongswan/plugins/openssl/openssl_crypter.c
parent6e0ff31e073c7951d606244b9ff1292f6247fb61 (diff)
downloadstrongswan-24400cf617ac8c0ade033de6d4de8c41fbf2a8c0.tar.bz2
strongswan-24400cf617ac8c0ade033de6d4de8c41fbf2a8c0.tar.xz
fixed setting of variable key length
Diffstat (limited to 'src/libstrongswan/plugins/openssl/openssl_crypter.c')
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_crypter.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_crypter.c b/src/libstrongswan/plugins/openssl/openssl_crypter.c
index 86e10f621..7f48f1009 100644
--- a/src/libstrongswan/plugins/openssl/openssl_crypter.c
+++ b/src/libstrongswan/plugins/openssl/openssl_crypter.c
@@ -131,10 +131,12 @@ static void crypt(private_openssl_crypter_t *this, chunk_t data,
}
EVP_CIPHER_CTX ctx;
EVP_CIPHER_CTX_init(&ctx);
- EVP_CipherInit_ex(&ctx, this->cipher, NULL, this->key.ptr, iv.ptr, enc);
- EVP_CIPHER_CTX_set_padding(&ctx, 0); /* disable padding */
+ EVP_CipherInit_ex(&ctx, this->cipher, NULL, NULL, NULL, enc);
+ EVP_CIPHER_CTX_set_padding(&ctx, 0); /* disable padding */
+ EVP_CIPHER_CTX_set_key_length(&ctx, this->key.len);
+ EVP_CipherInit_ex(&ctx, NULL, NULL, this->key.ptr, iv.ptr, enc);
EVP_CipherUpdate(&ctx, out, &len, data.ptr, data.len);
- EVP_CipherFinal_ex(&ctx, out, &len); /* since padding is disabled this does nothing */
+ EVP_CipherFinal_ex(&ctx, out + len, &len); /* since padding is disabled this does nothing */
EVP_CIPHER_CTX_cleanup(&ctx);
}