23#include <core/exceptions/software.h>
24#include <netcomm/crypto/decrypt.h>
26# include <openssl/evp.h>
70 plain_buffer_length = 0;
72 crypt_buffer_length = 0;
91 plain_buffer = buffer;
92 plain_buffer_length = buffer_length;
103 crypt_buffer = buffer;
104 crypt_buffer_length = buffer_length;
114 if ((plain_buffer == NULL) || (plain_buffer_length == 0) || (crypt_buffer == NULL)
115 || (crypt_buffer_length == 0)) {
120 EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
121 if (!EVP_DecryptInit(ctx, EVP_aes_128_ecb(), key, iv)) {
122 EVP_CIPHER_CTX_free(ctx);
126 int outl = plain_buffer_length;
127 if (!EVP_DecryptUpdate(ctx,
128 (
unsigned char *)plain_buffer,
130 (
unsigned char *)crypt_buffer,
131 crypt_buffer_length)) {
132 EVP_CIPHER_CTX_free(ctx);
137 if (!EVP_DecryptFinal(ctx, (
unsigned char *)plain_buffer + outl, &plen)) {
138 EVP_CIPHER_CTX_free(ctx);
143 EVP_CIPHER_CTX_free(ctx);
149 throw Exception(
"Decryption support not available");
Base class for exceptions in Fawkes.
Message decryption failed.
MessageDecryptionException(const char *msg)
Constructor.
void set_crypt_buffer(void *buffer, size_t buffer_length)
Set crypted buffer.
~MessageDecryptor()
Empty destructor.
void set_plain_buffer(void *buffer, size_t buffer_length)
Set plain buffer.
MessageDecryptor(const unsigned char *key, const unsigned char *iv)
Constructor.
Expected parameter is missing.
Fawkes library namespace.