summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/regress/lib/libcrypto/dh/dhtest.c12
-rw-r--r--src/regress/lib/libcrypto/ec/ectest.c21
-rw-r--r--src/regress/lib/libcrypto/ecdh/ecdhtest.c12
-rw-r--r--src/regress/lib/libcrypto/ecdsa/ecdsatest.c35
-rw-r--r--src/regress/lib/libcrypto/engine/enginetest.c16
-rw-r--r--src/regress/lib/libcrypto/evp/evptest.c3
6 files changed, 22 insertions, 77 deletions
diff --git a/src/regress/lib/libcrypto/dh/dhtest.c b/src/regress/lib/libcrypto/dh/dhtest.c
index 916d7aeff0..9851c4f0c6 100644
--- a/src/regress/lib/libcrypto/dh/dhtest.c
+++ b/src/regress/lib/libcrypto/dh/dhtest.c
@@ -86,10 +86,6 @@ int main(int argc, char *argv[])
86 int i,alen,blen,aout,bout,ret=1; 86 int i,alen,blen,aout,bout,ret=1;
87 BIO *out; 87 BIO *out;
88 88
89 CRYPTO_malloc_debug_init();
90 CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
91 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
92
93 out=BIO_new(BIO_s_file()); 89 out=BIO_new(BIO_s_file());
94 if (out == NULL) exit(1); 90 if (out == NULL) exit(1);
95 BIO_set_fp(out,stdout,BIO_NOCLOSE); 91 BIO_set_fp(out,stdout,BIO_NOCLOSE);
@@ -141,7 +137,7 @@ int main(int argc, char *argv[])
141 BIO_puts(out,"\n"); 137 BIO_puts(out,"\n");
142 138
143 alen=DH_size(a); 139 alen=DH_size(a);
144 abuf=(unsigned char *)OPENSSL_malloc(alen); 140 abuf=malloc(alen);
145 aout=DH_compute_key(abuf,b->pub_key,a); 141 aout=DH_compute_key(abuf,b->pub_key,a);
146 142
147 BIO_puts(out,"key1 ="); 143 BIO_puts(out,"key1 =");
@@ -153,7 +149,7 @@ int main(int argc, char *argv[])
153 BIO_puts(out,"\n"); 149 BIO_puts(out,"\n");
154 150
155 blen=DH_size(b); 151 blen=DH_size(b);
156 bbuf=(unsigned char *)OPENSSL_malloc(blen); 152 bbuf=malloc(blen);
157 bout=DH_compute_key(bbuf,a->pub_key,b); 153 bout=DH_compute_key(bbuf,a->pub_key,b);
158 154
159 BIO_puts(out,"key2 ="); 155 BIO_puts(out,"key2 =");
@@ -173,8 +169,8 @@ int main(int argc, char *argv[])
173err: 169err:
174 ERR_print_errors_fp(stderr); 170 ERR_print_errors_fp(stderr);
175 171
176 if (abuf != NULL) OPENSSL_free(abuf); 172 free(abuf);
177 if (bbuf != NULL) OPENSSL_free(bbuf); 173 free(bbuf);
178 if(b != NULL) DH_free(b); 174 if(b != NULL) DH_free(b);
179 if(a != NULL) DH_free(a); 175 if(a != NULL) DH_free(a);
180 BIO_free(out); 176 BIO_free(out);
diff --git a/src/regress/lib/libcrypto/ec/ectest.c b/src/regress/lib/libcrypto/ec/ectest.c
index e3028881e0..efb9a529ef 100644
--- a/src/regress/lib/libcrypto/ec/ectest.c
+++ b/src/regress/lib/libcrypto/ec/ectest.c
@@ -1070,14 +1070,14 @@ static void internal_curve_test(void)
1070 1070
1071 crv_len = EC_get_builtin_curves(NULL, 0); 1071 crv_len = EC_get_builtin_curves(NULL, 0);
1072 1072
1073 curves = OPENSSL_malloc(sizeof(EC_builtin_curve) * crv_len); 1073 curves = reallocarray(NULL, sizeof(EC_builtin_curve), crv_len);
1074 1074
1075 if (curves == NULL) 1075 if (curves == NULL)
1076 return; 1076 return;
1077 1077
1078 if (!EC_get_builtin_curves(curves, crv_len)) 1078 if (!EC_get_builtin_curves(curves, crv_len))
1079 { 1079 {
1080 OPENSSL_free(curves); 1080 free(curves);
1081 return; 1081 return;
1082 } 1082 }
1083 1083
@@ -1115,7 +1115,7 @@ static void internal_curve_test(void)
1115 fprintf(stdout, " failed\n\n"); 1115 fprintf(stdout, " failed\n\n");
1116 ABORT; 1116 ABORT;
1117 } 1117 }
1118 OPENSSL_free(curves); 1118 free(curves);
1119 return; 1119 return;
1120 } 1120 }
1121 1121
@@ -1289,20 +1289,7 @@ void nistp_tests()
1289#endif 1289#endif
1290 1290
1291int main(int argc, char *argv[]) 1291int main(int argc, char *argv[])
1292 { 1292 {
1293
1294 /* enable memory leak checking unless explicitly disabled */
1295 if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) && (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
1296 {
1297 CRYPTO_malloc_debug_init();
1298 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
1299 }
1300 else
1301 {
1302 /* OPENSSL_DEBUG_MEMORY=off */
1303 CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
1304 }
1305 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
1306 ERR_load_crypto_strings(); 1293 ERR_load_crypto_strings();
1307 1294
1308 prime_field_tests(); 1295 prime_field_tests();
diff --git a/src/regress/lib/libcrypto/ecdh/ecdhtest.c b/src/regress/lib/libcrypto/ecdh/ecdhtest.c
index bf362245bb..385f6803aa 100644
--- a/src/regress/lib/libcrypto/ecdh/ecdhtest.c
+++ b/src/regress/lib/libcrypto/ecdh/ecdhtest.c
@@ -160,14 +160,14 @@ static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out)
160 (void)BIO_flush(out); 160 (void)BIO_flush(out);
161 161
162 alen=KDF1_SHA1_len; 162 alen=KDF1_SHA1_len;
163 abuf=(unsigned char *)OPENSSL_malloc(alen); 163 abuf=malloc(alen);
164 aout=ECDH_compute_key(abuf,alen,EC_KEY_get0_public_key(b),a,KDF1_SHA1); 164 aout=ECDH_compute_key(abuf,alen,EC_KEY_get0_public_key(b),a,KDF1_SHA1);
165 165
166 BIO_printf(out,"."); 166 BIO_printf(out,".");
167 (void)BIO_flush(out); 167 (void)BIO_flush(out);
168 168
169 blen=KDF1_SHA1_len; 169 blen=KDF1_SHA1_len;
170 bbuf=(unsigned char *)OPENSSL_malloc(blen); 170 bbuf=malloc(blen);
171 bout=ECDH_compute_key(bbuf,blen,EC_KEY_get0_public_key(a),b,KDF1_SHA1); 171 bout=ECDH_compute_key(bbuf,blen,EC_KEY_get0_public_key(a),b,KDF1_SHA1);
172 172
173 BIO_printf(out,"."); 173 BIO_printf(out,".");
@@ -218,8 +218,8 @@ static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out)
218err: 218err:
219 ERR_print_errors_fp(stderr); 219 ERR_print_errors_fp(stderr);
220 220
221 if (abuf != NULL) OPENSSL_free(abuf); 221 free(abuf);
222 if (bbuf != NULL) OPENSSL_free(bbuf); 222 free(bbuf);
223 if (x_a) BN_free(x_a); 223 if (x_a) BN_free(x_a);
224 if (y_a) BN_free(y_a); 224 if (y_a) BN_free(y_a);
225 if (x_b) BN_free(x_b); 225 if (x_b) BN_free(x_b);
@@ -235,10 +235,6 @@ int main(int argc, char *argv[])
235 int ret=1; 235 int ret=1;
236 BIO *out; 236 BIO *out;
237 237
238 CRYPTO_malloc_debug_init();
239 CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
240 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
241
242 out=BIO_new(BIO_s_file()); 238 out=BIO_new(BIO_s_file());
243 if (out == NULL) exit(1); 239 if (out == NULL) exit(1);
244 BIO_set_fp(out,stdout,BIO_NOCLOSE); 240 BIO_set_fp(out,stdout,BIO_NOCLOSE);
diff --git a/src/regress/lib/libcrypto/ecdsa/ecdsatest.c b/src/regress/lib/libcrypto/ecdsa/ecdsatest.c
index 232fb9b4d1..eadb43d652 100644
--- a/src/regress/lib/libcrypto/ecdsa/ecdsatest.c
+++ b/src/regress/lib/libcrypto/ecdsa/ecdsatest.c
@@ -184,7 +184,7 @@ int test_builtin(BIO *out)
184 /* get a list of all internal curves */ 184 /* get a list of all internal curves */
185 crv_len = EC_get_builtin_curves(NULL, 0); 185 crv_len = EC_get_builtin_curves(NULL, 0);
186 186
187 curves = OPENSSL_malloc(sizeof(EC_builtin_curve) * crv_len); 187 curves = reallocarray(NULL, sizeof(EC_builtin_curve), crv_len);
188 188
189 if (curves == NULL) 189 if (curves == NULL)
190 { 190 {
@@ -257,7 +257,7 @@ int test_builtin(BIO *out)
257 (void)BIO_flush(out); 257 (void)BIO_flush(out);
258 /* create signature */ 258 /* create signature */
259 sig_len = ECDSA_size(eckey); 259 sig_len = ECDSA_size(eckey);
260 if ((signature = OPENSSL_malloc(sig_len)) == NULL) 260 if ((signature = malloc(sig_len)) == NULL)
261 goto builtin_err; 261 goto builtin_err;
262 if (!ECDSA_sign(0, digest, 20, signature, &sig_len, eckey)) 262 if (!ECDSA_sign(0, digest, 20, signature, &sig_len, eckey))
263 { 263 {
@@ -322,10 +322,8 @@ int test_builtin(BIO *out)
322 goto builtin_err; 322 goto builtin_err;
323 } 323 }
324 buf_len = 2 * bn_len; 324 buf_len = 2 * bn_len;
325 if ((raw_buf = OPENSSL_malloc(buf_len)) == NULL) 325 if ((raw_buf = calloc(1, buf_len)) == NULL)
326 goto builtin_err; 326 goto builtin_err;
327 /* Pad the bignums with leading zeroes. */
328 memset(raw_buf, 0, buf_len);
329 BN_bn2bin(ecdsa_sig->r, raw_buf + bn_len - r_len); 327 BN_bn2bin(ecdsa_sig->r, raw_buf + bn_len - r_len);
330 BN_bn2bin(ecdsa_sig->s, raw_buf + buf_len - s_len); 328 BN_bn2bin(ecdsa_sig->s, raw_buf + buf_len - s_len);
331 329
@@ -365,7 +363,7 @@ int test_builtin(BIO *out)
365 /* cleanup */ 363 /* cleanup */
366 /* clean bogus errors */ 364 /* clean bogus errors */
367 ERR_clear_error(); 365 ERR_clear_error();
368 OPENSSL_free(signature); 366 free(signature);
369 signature = NULL; 367 signature = NULL;
370 EC_KEY_free(eckey); 368 EC_KEY_free(eckey);
371 eckey = NULL; 369 eckey = NULL;
@@ -373,7 +371,7 @@ int test_builtin(BIO *out)
373 wrong_eckey = NULL; 371 wrong_eckey = NULL;
374 ECDSA_SIG_free(ecdsa_sig); 372 ECDSA_SIG_free(ecdsa_sig);
375 ecdsa_sig = NULL; 373 ecdsa_sig = NULL;
376 OPENSSL_free(raw_buf); 374 free(raw_buf);
377 raw_buf = NULL; 375 raw_buf = NULL;
378 } 376 }
379 377
@@ -385,12 +383,9 @@ builtin_err:
385 EC_KEY_free(wrong_eckey); 383 EC_KEY_free(wrong_eckey);
386 if (ecdsa_sig) 384 if (ecdsa_sig)
387 ECDSA_SIG_free(ecdsa_sig); 385 ECDSA_SIG_free(ecdsa_sig);
388 if (signature) 386 free(signature);
389 OPENSSL_free(signature); 387 free(raw_buf);
390 if (raw_buf) 388 free(curves);
391 OPENSSL_free(raw_buf);
392 if (curves)
393 OPENSSL_free(curves);
394 389
395 return ret; 390 return ret;
396 } 391 }
@@ -401,20 +396,6 @@ int main(void)
401 BIO *out; 396 BIO *out;
402 397
403 out = BIO_new_fp(stdout, BIO_NOCLOSE); 398 out = BIO_new_fp(stdout, BIO_NOCLOSE);
404
405 /* enable memory leak checking unless explicitly disabled */
406 if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) &&
407 (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
408 {
409 CRYPTO_malloc_debug_init();
410 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
411 }
412 else
413 {
414 /* OPENSSL_DEBUG_MEMORY=off */
415 CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
416 }
417 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
418 399
419 ERR_load_crypto_strings(); 400 ERR_load_crypto_strings();
420 401
diff --git a/src/regress/lib/libcrypto/engine/enginetest.c b/src/regress/lib/libcrypto/engine/enginetest.c
index f4d70e7e0a..5032dc47e7 100644
--- a/src/regress/lib/libcrypto/engine/enginetest.c
+++ b/src/regress/lib/libcrypto/engine/enginetest.c
@@ -105,18 +105,6 @@ int main(int argc, char *argv[])
105 ENGINE *new_h3 = NULL; 105 ENGINE *new_h3 = NULL;
106 ENGINE *new_h4 = NULL; 106 ENGINE *new_h4 = NULL;
107 107
108 /* enable memory leak checking unless explicitly disabled */
109 if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) && (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
110 {
111 CRYPTO_malloc_debug_init();
112 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
113 }
114 else
115 {
116 /* OPENSSL_DEBUG_MEMORY=off */
117 CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
118 }
119 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
120 ERR_load_crypto_strings(); 108 ERR_load_crypto_strings();
121 109
122 memset(block, 0, 512 * sizeof(ENGINE *)); 110 memset(block, 0, 512 * sizeof(ENGINE *));
@@ -258,8 +246,8 @@ cleanup_loop:
258 } 246 }
259 for(loop = 0; loop < 512; loop++) 247 for(loop = 0; loop < 512; loop++)
260 { 248 {
261 OPENSSL_free((void *)ENGINE_get_id(block[loop])); 249 free((void *)ENGINE_get_id(block[loop]));
262 OPENSSL_free((void *)ENGINE_get_name(block[loop])); 250 free((void *)ENGINE_get_name(block[loop]));
263 } 251 }
264 printf("\nTests completed happily\n"); 252 printf("\nTests completed happily\n");
265 to_return = 0; 253 to_return = 0;
diff --git a/src/regress/lib/libcrypto/evp/evptest.c b/src/regress/lib/libcrypto/evp/evptest.c
index c88bf130cd..f107ad5fb4 100644
--- a/src/regress/lib/libcrypto/evp/evptest.c
+++ b/src/regress/lib/libcrypto/evp/evptest.c
@@ -306,9 +306,6 @@ main(int argc, char **argv)
306 fprintf(stderr, "%s <test file>\n",argv[0]); 306 fprintf(stderr, "%s <test file>\n",argv[0]);
307 exit(1); 307 exit(1);
308 } 308 }
309 CRYPTO_malloc_debug_init();
310 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
311 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
312 309
313 szTestFile = argv[1]; 310 szTestFile = argv[1];
314 311