summaryrefslogtreecommitdiffstats
path: root/crypto/openssl/crypto/dsa/dsatest.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/openssl/crypto/dsa/dsatest.c')
-rw-r--r--crypto/openssl/crypto/dsa/dsatest.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/crypto/openssl/crypto/dsa/dsatest.c b/crypto/openssl/crypto/dsa/dsatest.c
index fc25c9a..309a7cd 100644
--- a/crypto/openssl/crypto/dsa/dsatest.c
+++ b/crypto/openssl/crypto/dsa/dsatest.c
@@ -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,15 +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)
@@ -193,13 +200,18 @@ end:
if (!ret)
ERR_print_errors(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);
+ 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;
@@ -208,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);
- (void)BIO_flush((BIO *)arg);
+ BIO_write(arg,&c,1);
+ (void)BIO_flush(arg);
if (!ok && (p == 0) && (num > 1))
{
OpenPOWER on IntegriCloud