X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fecies.cpp;h=dec773f9cecf2d62f65d647d9e0c76b5b2a5fd2c;hb=05df71c9c292877e7469884227fd3ba84d02908b;hp=39fe2d7d1b57071a329e0c741d2f994fa4dae8ba;hpb=4f79246296b55b4894a72a6354898445a21c6996;p=novacoin.git diff --git a/src/ecies.cpp b/src/ecies.cpp index 39fe2d7..dec773f 100644 --- a/src/ecies.cpp +++ b/src/ecies.cpp @@ -556,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; + } }