24 #include <core/exceptions/software.h>
25 #include <netcomm/worldinfo/decrypt.h>
27 # include <openssl/evp.h>
74 plain_buffer_length = 0;
76 crypt_buffer_length = 0;
97 plain_buffer = buffer;
98 plain_buffer_length = buffer_length;
110 crypt_buffer = buffer;
111 crypt_buffer_length = buffer_length;
122 if ( (plain_buffer == NULL) || (plain_buffer_length == 0) ||
123 (crypt_buffer == NULL) || (crypt_buffer_length == 0) ) {
127 #ifdef HAVE_LIBCRYPTO
129 if ( ! EVP_DecryptInit(&ctx, EVP_aes_128_ecb(), key, iv) ) {
133 int outl = plain_buffer_length;
134 if ( ! EVP_DecryptUpdate(&ctx,
135 (
unsigned char *)plain_buffer, &outl,
136 (
unsigned char *)crypt_buffer, crypt_buffer_length) ) {
141 if ( ! EVP_DecryptFinal(&ctx, (
unsigned char *)plain_buffer + outl, &plen) ) {
149 memcpy(plain_buffer, crypt_buffer, crypt_buffer_length);
150 return crypt_buffer_length;