projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
If memory debugging enabled return error on leaks.
[openssl.git]
/
test
/
ecdhtest.c
diff --git
a/test/ecdhtest.c
b/test/ecdhtest.c
index a89177e4353c519daed7604a99d5b9b5e66076aa..16d8cedac1d6f0701be7a95a45eb89e00e4333fa 100644
(file)
--- a/
test/ecdhtest.c
+++ b/
test/ecdhtest.c
@@
-1,4
+1,3
@@
-/* crypto/ecdh/ecdhtest.c */
/* ====================================================================
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
*
/* ====================================================================
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
*
@@
-90,7
+89,6
@@
int main(int argc, char *argv[])
}
#else
# include <openssl/ec.h>
}
#else
# include <openssl/ec.h>
-# include <openssl/ecdh.h>
static const char rnd_seed[] =
"string to make the random number generator think it has entropy";
static const char rnd_seed[] =
"string to make the random number generator think it has entropy";
@@
-201,7
+199,7
@@
static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out)
# endif
alen = KDF1_SHA1_len;
# endif
alen = KDF1_SHA1_len;
- abuf =
(unsigned char *)
OPENSSL_malloc(alen);
+ abuf = OPENSSL_malloc(alen);
aout =
ECDH_compute_key(abuf, alen, EC_KEY_get0_public_key(b), a, KDF1_SHA1);
aout =
ECDH_compute_key(abuf, alen, EC_KEY_get0_public_key(b), a, KDF1_SHA1);
@@
-218,7
+216,7
@@
static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out)
# endif
blen = KDF1_SHA1_len;
# endif
blen = KDF1_SHA1_len;
- bbuf =
(unsigned char *)
OPENSSL_malloc(blen);
+ bbuf = OPENSSL_malloc(blen);
bout =
ECDH_compute_key(bbuf, blen, EC_KEY_get0_public_key(a), b, KDF1_SHA1);
bout =
ECDH_compute_key(bbuf, blen, EC_KEY_get0_public_key(a), b, KDF1_SHA1);
@@
-278,18
+276,12
@@
static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out)
err:
ERR_print_errors_fp(stderr);
err:
ERR_print_errors_fp(stderr);
- if (abuf != NULL)
- OPENSSL_free(abuf);
- if (bbuf != NULL)
- OPENSSL_free(bbuf);
- if (x_a)
- BN_free(x_a);
- if (y_a)
- BN_free(y_a);
- if (x_b)
- BN_free(x_b);
- if (y_b)
- BN_free(y_b);
+ OPENSSL_free(abuf);
+ OPENSSL_free(bbuf);
+ BN_free(x_a);
+ BN_free(y_a);
+ BN_free(x_b);
+ BN_free(y_b);
EC_KEY_free(b);
EC_KEY_free(a);
return (ret);
EC_KEY_free(b);
EC_KEY_free(a);
return (ret);
@@
-390,8
+382,7
@@
static EC_KEY *mk_eckey(int nid, const unsigned char *p, size_t plen)
goto err;
ok = 1;
err:
goto err;
ok = 1;
err:
- if (priv)
- BN_clear_free(priv);
+ BN_clear_free(priv);
EC_POINT_free(pub);
if (ok)
return k;
EC_POINT_free(pub);
if (ok)
return k;
@@
-438,8
+429,7
@@
static int ecdh_kat(BIO *out, const char *cname, int nid,
err:
EC_KEY_free(key1);
EC_KEY_free(key2);
err:
EC_KEY_free(key1);
EC_KEY_free(key2);
- if (Ztmp)
- OPENSSL_free(Ztmp);
+ OPENSSL_free(Ztmp);
if (rv)
BIO_puts(out, " ok\n");
else {
if (rv)
BIO_puts(out, " ok\n");
else {
@@
-461,20
+451,15
@@
int main(int argc, char *argv[])
int ret = 1;
BIO *out;
int ret = 1;
BIO *out;
- CRYPTO_malloc_debug_init();
- CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
+ CRYPTO_set_mem_debug(1);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
-# ifdef OPENSSL_SYS_WIN32
- CRYPTO_malloc_init();
-# endif
-
RAND_seed(rnd_seed, sizeof rnd_seed);
out = BIO_new(BIO_s_file());
if (out == NULL)
EXIT(1);
RAND_seed(rnd_seed, sizeof rnd_seed);
out = BIO_new(BIO_s_file());
if (out == NULL)
EXIT(1);
- BIO_set_fp(out, stdout, BIO_NOCLOSE);
+ BIO_set_fp(out, stdout, BIO_NOCLOSE
| BIO_FP_TEXT
);
if ((ctx = BN_CTX_new()) == NULL)
goto err;
if ((ctx = BN_CTX_new()) == NULL)
goto err;
@@
-526,12
+511,14
@@
int main(int argc, char *argv[])
err:
ERR_print_errors_fp(stderr);
err:
ERR_print_errors_fp(stderr);
- if (ctx)
- BN_CTX_free(ctx);
+ BN_CTX_free(ctx);
BIO_free(out);
CRYPTO_cleanup_all_ex_data();
ERR_remove_thread_state(NULL);
BIO_free(out);
CRYPTO_cleanup_all_ex_data();
ERR_remove_thread_state(NULL);
- CRYPTO_mem_leaks_fp(stderr);
+#ifndef OPENSSL_NO_CRYPTO_MDEBUG
+ if (CRYPTO_mem_leaks_fp(stderr) <= 0)
+ ret = 1;
+#endif
EXIT(ret);
}
#endif
EXIT(ret);
}
#endif