Fix c_rehash script, add -fingerprint option to crl.
[openssl.git] / crypto / dsa / dsatest.c
index 363eab62178c87b0fbb40918266f36cce322d0ed..309a7cda899230af018dc67944d533aa0fc107d4 100644 (file)
@@ -84,7 +84,10 @@ int main(int argc, char *argv[])
 #define MS_CALLBACK
 #endif
 
-static void MS_CALLBACK dsa_cb(int p, int n, char *arg);
+static void MS_CALLBACK dsa_cb(int p, int n, void *arg);
+
+/* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to
+ * FIPS PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1 */
 static unsigned char seed[20]={
        0xd5,0x01,0x4e,0x4b,0x60,0xef,0x2b,0xa8,0xb6,0x21,0x1b,0x40,
        0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3,
@@ -120,6 +123,8 @@ static unsigned char out_g[]={
 
 static const unsigned char str1[]="12345678901234567890";
 
+static const char rnd_seed[] = "string to make the random number generator think it has entropy";
+
 static BIO *bio_err=NULL;
 
 int main(int argc, char **argv)
@@ -131,13 +136,17 @@ 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);
 
+       CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
+
        BIO_printf(bio_err,"test generation of DSA parameters\n");
-       BIO_printf(bio_err,"expect '.*' followed by 5 lines of '.'s and '+'s\n");
-       dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,
-               (char *)bio_err);
+
+       dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,bio_err);
 
        BIO_printf(bio_err,"seed\n");
        for (i=0; i<20; i+=4)
@@ -190,13 +199,19 @@ int main(int argc, char **argv)
 end:
        if (!ret)
                ERR_print_errors(bio_err);
-       if (bio_err != NULL) BIO_free(bio_err);
        if (dsa != NULL) DSA_free(dsa);
+       ERR_remove_state(0);
+       CRYPTO_mem_leaks(bio_err);
+       if (bio_err != NULL)
+               {
+               BIO_free(bio_err);
+               bio_err = NULL;
+               }
        exit(!ret);
        return(0);
        }
 
-static void MS_CALLBACK dsa_cb(int p, int n, char *arg)
+static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
        {
        char c='*';
        static int ok=0,num=0;
@@ -205,8 +220,8 @@ static void MS_CALLBACK dsa_cb(int p, int n, char *arg)
        if (p == 1) c='+';
        if (p == 2) { c='*'; ok++; }
        if (p == 3) c='\n';
-       BIO_write((BIO *)arg,&c,1);
-       BIO_flush((BIO *)arg);
+       BIO_write(arg,&c,1);
+       (void)BIO_flush(arg);
 
        if (!ok && (p == 0) && (num > 1))
                {