X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fecies.cpp;h=dec773f9cecf2d62f65d647d9e0c76b5b2a5fd2c;hb=89d4073d0a6545330af16bb8b2352881b6f55cf5;hp=fe2fb55676432c2febdb383b9bc3d7e24f8b11c7;hpb=92e04fce9c7fc4622a73270719635d314b27e4fb;p=novacoin.git diff --git a/src/ecies.cpp b/src/ecies.cpp index fe2fb55..dec773f 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__) @@ -557,12 +556,18 @@ unsigned char * ecies_decrypt(const ies_ctx_t *ctx, const cryptogram_t *cryptogr ies_ctx_t *create_context(EC_KEY *user_key) { - ies_ctx_t* ctx = (ies_ctx_t*) malloc(sizeof(ies_ctx_t)); - ctx->cipher = EVP_aes_128_cbc(); - ctx->md = EVP_sha1(); - ctx->kdf_md = EVP_sha1(); - ctx->stored_key_length = 33; - ctx->user_key = user_key; - - return ctx; + try { + ies_ctx_t* ctx = new ies_ctx_t; + ctx->cipher = EVP_aes_128_cbc(); + ctx->md = EVP_ripemd160(); + ctx->kdf_md = EVP_ripemd160(); + ctx->stored_key_length = 33; + ctx->user_key = user_key; + return ctx; + } + catch (const std::bad_alloc& e) { + printf("Error: %s in %s:%d\n", e.what(), __FILE__, __LINE__); +// TODO: add checking to NULL where necessary + return NULL; + } }