Correct a lot of printing calls. Remove extra arguments...
[openssl.git] / crypto / dsa / dsatest.c
index 5f24b59554636045f536d1d3ab96b467e6065bc2..53c73c5cc252c65aae0f738dd6b51aea2e2ed591 100644 (file)
  * [including the GNU Public Licence.]
  */
 
+/* Until the key-gen callbacks are modified to use newer prototypes, we allow
+ * deprecated functions for openssl-internal code */
+#ifdef OPENSSL_NO_DEPRECATED
+#undef OPENSSL_NO_DEPRECATED
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+
+#include "../e_os.h"
+
 #include <openssl/crypto.h>
 #include <openssl/rand.h>
 #include <openssl/bio.h>
 #include <openssl/err.h>
-#ifdef OPENSSL_SYS_WINDOWS
-#include "../bio/bss_file.c"
+#ifndef OPENSSL_NO_ENGINE
+#include <openssl/engine.h>
+#include <openssl/e_os2.h>
 #endif
 
 #ifdef OPENSSL_NO_DSA
@@ -136,9 +146,6 @@ int main(int argc, char **argv)
        unsigned char sig[256];
        unsigned int siglen;
 
-       ERR_load_crypto_strings();
-       RAND_seed(rnd_seed, sizeof rnd_seed);
-
        if (bio_err == NULL)
                bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
 
@@ -146,6 +153,9 @@ int main(int argc, char **argv)
        CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
 
+       ERR_load_crypto_strings();
+       RAND_seed(rnd_seed, sizeof rnd_seed);
+
        BIO_printf(bio_err,"test generation of DSA parameters\n");
 
        dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,bio_err);
@@ -156,7 +166,7 @@ int main(int argc, char **argv)
                BIO_printf(bio_err,"%02X%02X%02X%02X ",
                        seed[i],seed[i+1],seed[i+2],seed[i+3]);
                }
-       BIO_printf(bio_err,"\ncounter=%d h=%d\n",counter,h);
+       BIO_printf(bio_err,"\ncounter=%d h=%ld\n",counter,h);
                
        if (dsa == NULL) goto end;
        DSA_print(bio_err,dsa,0);
@@ -204,16 +214,23 @@ end:
        if (dsa != NULL) DSA_free(dsa);
        CRYPTO_cleanup_all_ex_data();
        ERR_remove_state(0);
+       ERR_free_strings();
        CRYPTO_mem_leaks(bio_err);
        if (bio_err != NULL)
                {
                BIO_free(bio_err);
                bio_err = NULL;
                }
-       exit(!ret);
+       EXIT(!ret);
        return(0);
        }
 
+static int cb_exit(int ec)
+       {
+       EXIT(ec);
+       return(0);              /* To keep some compilers quiet */
+       }
+
 static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
        {
        char c='*';
@@ -229,7 +246,7 @@ static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
        if (!ok && (p == 0) && (num > 1))
                {
                BIO_printf((BIO *)arg,"error in dsatest\n");
-               exit(1);
+               cb_exit(1);
                }
        }
 #endif