X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fecies.cpp;h=39fe2d7d1b57071a329e0c741d2f994fa4dae8ba;hb=1ebe5b92ef18395cdae9b88fc38b0ed6166c3243;hp=215d390ada5b0fd1fc59e1808e3d3b460b257c79;hpb=b8dd44c350c3fb0b958cea2baba8aab268f44cf2;p=novacoin.git diff --git a/src/ecies.cpp b/src/ecies.cpp index 215d390..39fe2d7 100644 --- a/src/ecies.cpp +++ b/src/ecies.cpp @@ -11,7 +11,6 @@ #include "ies.h" #include #include -#include #define SET_ERROR(string) \ sprintf(error, "%s %s:%d", (string), __FILE__, __LINE__) @@ -273,16 +272,16 @@ static int store_mac_tag(const ies_ctx_t *ctx, const unsigned char *envelope_key cryptogram_t * ecies_encrypt(const ies_ctx_t *ctx, const unsigned char *data, size_t length, char *error) { - const size_t block_length = EVP_CIPHER_block_size(ctx->cipher); - const size_t mac_length = EVP_MD_size(ctx->md); - cryptogram_t *cryptogram = NULL; - unsigned char *envelope_key = NULL; - if (!ctx || !data || !length) { SET_ERROR("Invalid arguments"); return NULL; } + const size_t block_length = EVP_CIPHER_block_size(ctx->cipher); + const size_t mac_length = EVP_MD_size(ctx->md); + cryptogram_t *cryptogram = NULL; + unsigned char *envelope_key = NULL; + if (block_length == 0 || block_length > EVP_MAX_BLOCK_LENGTH) { SET_ERROR("Derived block size is incorrect"); return NULL;