int i,alen,blen,aout,bout,ret=1;
BIO *out;
- CRYPTO_malloc_debug_init();
- CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
-
out=BIO_new(BIO_s_file());
if (out == NULL) exit(1);
BIO_set_fp(out,stdout,BIO_NOCLOSE);
BIO_puts(out,"\n");
alen=DH_size(a);
- abuf=(unsigned char *)OPENSSL_malloc(alen);
+ abuf=malloc(alen);
aout=DH_compute_key(abuf,b->pub_key,a);
BIO_puts(out,"key1 =");
BIO_puts(out,"\n");
blen=DH_size(b);
- bbuf=(unsigned char *)OPENSSL_malloc(blen);
+ bbuf=malloc(blen);
bout=DH_compute_key(bbuf,a->pub_key,b);
BIO_puts(out,"key2 =");
err:
ERR_print_errors_fp(stderr);
- if (abuf != NULL) OPENSSL_free(abuf);
- if (bbuf != NULL) OPENSSL_free(bbuf);
+ free(abuf);
+ free(bbuf);
if(b != NULL) DH_free(b);
if(a != NULL) DH_free(a);
BIO_free(out);
crv_len = EC_get_builtin_curves(NULL, 0);
- curves = OPENSSL_malloc(sizeof(EC_builtin_curve) * crv_len);
+ curves = reallocarray(NULL, sizeof(EC_builtin_curve), crv_len);
if (curves == NULL)
return;
if (!EC_get_builtin_curves(curves, crv_len))
{
- OPENSSL_free(curves);
+ free(curves);
return;
}
fprintf(stdout, " failed\n\n");
ABORT;
}
- OPENSSL_free(curves);
+ free(curves);
return;
}
#endif
int main(int argc, char *argv[])
- {
-
- /* enable memory leak checking unless explicitly disabled */
- if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) && (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
- {
- CRYPTO_malloc_debug_init();
- CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
- }
- else
- {
- /* OPENSSL_DEBUG_MEMORY=off */
- CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
- }
- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
+ {
ERR_load_crypto_strings();
prime_field_tests();
(void)BIO_flush(out);
alen=KDF1_SHA1_len;
- abuf=(unsigned char *)OPENSSL_malloc(alen);
+ abuf=malloc(alen);
aout=ECDH_compute_key(abuf,alen,EC_KEY_get0_public_key(b),a,KDF1_SHA1);
BIO_printf(out,".");
(void)BIO_flush(out);
blen=KDF1_SHA1_len;
- bbuf=(unsigned char *)OPENSSL_malloc(blen);
+ bbuf=malloc(blen);
bout=ECDH_compute_key(bbuf,blen,EC_KEY_get0_public_key(a),b,KDF1_SHA1);
BIO_printf(out,".");
err:
ERR_print_errors_fp(stderr);
- if (abuf != NULL) OPENSSL_free(abuf);
- if (bbuf != NULL) OPENSSL_free(bbuf);
+ free(abuf);
+ free(bbuf);
if (x_a) BN_free(x_a);
if (y_a) BN_free(y_a);
if (x_b) BN_free(x_b);
int ret=1;
BIO *out;
- CRYPTO_malloc_debug_init();
- CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
-
out=BIO_new(BIO_s_file());
if (out == NULL) exit(1);
BIO_set_fp(out,stdout,BIO_NOCLOSE);
/* get a list of all internal curves */
crv_len = EC_get_builtin_curves(NULL, 0);
- curves = OPENSSL_malloc(sizeof(EC_builtin_curve) * crv_len);
+ curves = reallocarray(NULL, sizeof(EC_builtin_curve), crv_len);
if (curves == NULL)
{
(void)BIO_flush(out);
/* create signature */
sig_len = ECDSA_size(eckey);
- if ((signature = OPENSSL_malloc(sig_len)) == NULL)
+ if ((signature = malloc(sig_len)) == NULL)
goto builtin_err;
if (!ECDSA_sign(0, digest, 20, signature, &sig_len, eckey))
{
goto builtin_err;
}
buf_len = 2 * bn_len;
- if ((raw_buf = OPENSSL_malloc(buf_len)) == NULL)
+ if ((raw_buf = calloc(1, buf_len)) == NULL)
goto builtin_err;
- /* Pad the bignums with leading zeroes. */
- memset(raw_buf, 0, buf_len);
BN_bn2bin(ecdsa_sig->r, raw_buf + bn_len - r_len);
BN_bn2bin(ecdsa_sig->s, raw_buf + buf_len - s_len);
/* cleanup */
/* clean bogus errors */
ERR_clear_error();
- OPENSSL_free(signature);
+ free(signature);
signature = NULL;
EC_KEY_free(eckey);
eckey = NULL;
wrong_eckey = NULL;
ECDSA_SIG_free(ecdsa_sig);
ecdsa_sig = NULL;
- OPENSSL_free(raw_buf);
+ free(raw_buf);
raw_buf = NULL;
}
EC_KEY_free(wrong_eckey);
if (ecdsa_sig)
ECDSA_SIG_free(ecdsa_sig);
- if (signature)
- OPENSSL_free(signature);
- if (raw_buf)
- OPENSSL_free(raw_buf);
- if (curves)
- OPENSSL_free(curves);
+ free(signature);
+ free(raw_buf);
+ free(curves);
return ret;
}
BIO *out;
out = BIO_new_fp(stdout, BIO_NOCLOSE);
-
- /* enable memory leak checking unless explicitly disabled */
- if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) &&
- (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
- {
- CRYPTO_malloc_debug_init();
- CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
- }
- else
- {
- /* OPENSSL_DEBUG_MEMORY=off */
- CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
- }
- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
ERR_load_crypto_strings();
ENGINE *new_h3 = NULL;
ENGINE *new_h4 = NULL;
- /* enable memory leak checking unless explicitly disabled */
- if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) && (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
- {
- CRYPTO_malloc_debug_init();
- CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
- }
- else
- {
- /* OPENSSL_DEBUG_MEMORY=off */
- CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
- }
- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
ERR_load_crypto_strings();
memset(block, 0, 512 * sizeof(ENGINE *));
}
for(loop = 0; loop < 512; loop++)
{
- OPENSSL_free((void *)ENGINE_get_id(block[loop]));
- OPENSSL_free((void *)ENGINE_get_name(block[loop]));
+ free((void *)ENGINE_get_id(block[loop]));
+ free((void *)ENGINE_get_name(block[loop]));
}
printf("\nTests completed happily\n");
to_return = 0;
fprintf(stderr, "%s <test file>\n",argv[0]);
exit(1);
}
- CRYPTO_malloc_debug_init();
- CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
szTestFile = argv[1];