Fix warnings.
[openssl.git] / crypto / ec / ectest.c
index 82df606a34d705ba32364aed4d12cae53fa3adf6..6da5d4b2473a462183a2e497f56850e1cd00fa0e 100644 (file)
@@ -55,6 +55,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <time.h>
 
 
@@ -148,7 +149,14 @@ int main(int argc, char *argv[])
        BIGNUM *x, *y, *z;
        unsigned char buf[100];
        size_t i, len;
+       int k;
        
+       /* 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_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
+               }
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
        ERR_load_crypto_strings();
 
@@ -224,8 +232,11 @@ int main(int argc, char *argv[])
                }
 
        fprintf(stdout, "A cyclic subgroup:\n");
+       k = 100;
        do
                {
+               if (k-- == 0) ABORT;
+
                if (EC_POINT_is_at_infinity(group, P))
                        fprintf(stdout, "     point at infinity\n");
                else
@@ -324,7 +335,7 @@ int main(int argc, char *argv[])
        if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
        fprintf(stdout, ".");
        fflush(stdout);
-       if (!EC_GROUP_precompute(group, ctx)) ABORT;
+       if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
        if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
        if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
        fprintf(stdout, " ok\n");
@@ -364,7 +375,7 @@ int main(int argc, char *argv[])
        if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
        fprintf(stdout, ".");
        fflush(stdout);
-       if (!EC_GROUP_precompute(group, ctx)) ABORT;
+       if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
        if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
        if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
        fprintf(stdout, " ok\n");
@@ -405,7 +416,7 @@ int main(int argc, char *argv[])
        if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
        fprintf(stdout, ".");
        fflush(stdout);
-       if (!EC_GROUP_precompute(group, ctx)) ABORT;
+       if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
        if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
        if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
        fprintf(stdout, " ok\n");
@@ -451,7 +462,7 @@ int main(int argc, char *argv[])
        if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
        fprintf(stdout, ".");
        fflush(stdout);
-       if (!EC_GROUP_precompute(group, ctx)) ABORT;
+       if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
        if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
        if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
        fprintf(stdout, " ok\n");
@@ -503,7 +514,7 @@ int main(int argc, char *argv[])
        if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
        fprintf(stdout, ".");
        fflush(stdout);
-       if (!EC_GROUP_precompute(group, ctx)) ABORT;
+       if (!EC_GROUP_precompute_mult(group, ctx)) ABORT;
        if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT;
        if (!EC_POINT_is_at_infinity(group, Q)) ABORT;
        fprintf(stdout, " ok\n");