Project

General

Profile

Feature #344 ยป scales-ppm-ppm_checksum_c.c-openssl-1.1.0.patch

Matthew Krupcale, 09/25/2017 07:24 PM

View differences:

ppm-1.0.4/src/crypto/ppm_checksum_c.c 2017-09-25 12:45:12.119896956 -0400
#ifdef USE_CRYPTO
#include <openssl/evp.h>
#include <openssl/opensslv.h>
#else
#include "crypto/md5.h"
#endif
......
{
unsigned int md_len;
const EVP_MD *md = digest->helper;
#if OPENSSL_VERSION_NUMBER < 0x1010000fL
EVP_MD_CTX mdctx;
EVP_DigestInit(&mdctx, md);
EVP_DigestUpdate(&mdctx, buf, buf_size);
EVP_DigestFinal(&mdctx, checksum, &md_len);
EVP_MD_CTX_init(&mdctx);
if (!EVP_DigestInit_ex(&mdctx, md, NULL)) {
PPM_abort(PPM_default_comm, "failed to setup digest context",
__FILE__, __LINE__);
}
if (!EVP_DigestUpdate(&mdctx, buf, buf_size)) {
PPM_abort(PPM_default_comm, "failed to hash data into digest context",
__FILE__, __LINE__);
}
if (!EVP_DigestFinal_ex(&mdctx, checksum, &md_len)) {
PPM_abort(PPM_default_comm, "failed to retrieve digest value",
__FILE__, __LINE__);
}
#else
EVP_MD_CTX *mdctx;
mdctx = EVP_MD_CTX_new();
if (mdctx == NULL) {
PPM_abort(PPM_default_comm, "failed to initialize digest context",
__FILE__, __LINE__);
}
if (!EVP_DigestInit_ex(mdctx, md, NULL)) {
EVP_MD_CTX_free(mdctx);
PPM_abort(PPM_default_comm, "failed to setup digest context",
__FILE__, __LINE__);
}
if (!EVP_DigestUpdate(mdctx, buf, buf_size)) {
EVP_MD_CTX_free(mdctx);
PPM_abort(PPM_default_comm, "failed to hash data into digest context",
__FILE__, __LINE__);
}
if (!EVP_DigestFinal_ex(mdctx, checksum, &md_len)) {
EVP_MD_CTX_free(mdctx);
PPM_abort(PPM_default_comm, "failed to retrieve digest value",
__FILE__, __LINE__);
}
EVP_MD_CTX_free(mdctx);
#endif
}
#else
PPM_abort(PPM_default_comm, "invalid digest type specified",
    (1-1/1)