scales-ppm-ppm_checksum_c.c-openssl-1.1.0.patch

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

Download (2 kB)

ppm-1.0.4/src/crypto/ppm_checksum_c.c 2017-09-25 12:45:12.119896956 -0400
51 51

  
52 52
#ifdef USE_CRYPTO
53 53
#include <openssl/evp.h>
54
#include <openssl/opensslv.h>
54 55
#else
55 56
#include "crypto/md5.h"
56 57
#endif
......
107 108
    {
108 109
      unsigned int md_len;
109 110
      const EVP_MD *md = digest->helper;
111
#if OPENSSL_VERSION_NUMBER < 0x1010000fL
110 112
      EVP_MD_CTX mdctx;
111
      EVP_DigestInit(&mdctx, md);
112
      EVP_DigestUpdate(&mdctx, buf, buf_size);
113
      EVP_DigestFinal(&mdctx, checksum, &md_len);
113
      EVP_MD_CTX_init(&mdctx);
114
      if (!EVP_DigestInit_ex(&mdctx, md, NULL)) {
115
	  PPM_abort(PPM_default_comm, "failed to setup digest context",
116
		    __FILE__, __LINE__);
117
      }
118
      if (!EVP_DigestUpdate(&mdctx, buf, buf_size)) {
119
	  PPM_abort(PPM_default_comm, "failed to hash data into digest context",
120
		    __FILE__, __LINE__);
121
      }
122
      if (!EVP_DigestFinal_ex(&mdctx, checksum, &md_len)) {
123
	  PPM_abort(PPM_default_comm, "failed to retrieve digest value",
124
		    __FILE__, __LINE__);
125
      }
126
#else
127
      EVP_MD_CTX *mdctx;
128
      mdctx = EVP_MD_CTX_new();
129
      if (mdctx == NULL) {
130
	  PPM_abort(PPM_default_comm, "failed to initialize digest context",
131
		    __FILE__, __LINE__);
132
      }
133
      if (!EVP_DigestInit_ex(mdctx, md, NULL)) {
134
	  EVP_MD_CTX_free(mdctx);
135
	  PPM_abort(PPM_default_comm, "failed to setup digest context",
136
		    __FILE__, __LINE__);
137
      }
138
      if (!EVP_DigestUpdate(mdctx, buf, buf_size)) {
139
	  EVP_MD_CTX_free(mdctx);
140
	  PPM_abort(PPM_default_comm, "failed to hash data into digest context",
141
		    __FILE__, __LINE__);
142
      }
143
      if (!EVP_DigestFinal_ex(mdctx, checksum, &md_len)) {
144
	  EVP_MD_CTX_free(mdctx);
145
	  PPM_abort(PPM_default_comm, "failed to retrieve digest value",
146
		    __FILE__, __LINE__);
147
      }
148
      EVP_MD_CTX_free(mdctx);
149
#endif
114 150
    }
115 151
#else
116 152
    PPM_abort(PPM_default_comm, "invalid digest type specified",