aboutsummaryrefslogtreecommitdiff
path: root/crypto/openssl/apps/prime.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/openssl/apps/prime.c')
-rw-r--r--crypto/openssl/apps/prime.c50
1 files changed, 31 insertions, 19 deletions
diff --git a/crypto/openssl/apps/prime.c b/crypto/openssl/apps/prime.c
index 5c731a7e015c..af2fed15af69 100644
--- a/crypto/openssl/apps/prime.c
+++ b/crypto/openssl/apps/prime.c
@@ -56,12 +56,14 @@
#undef PROG
#define PROG prime_main
+int MAIN(int, char **);
+
int MAIN(int argc, char **argv)
{
int hex=0;
int checks=20;
BIGNUM *bn=NULL;
- BIO *bio_out=NULL;
+ BIO *bio_out;
apps_startup();
@@ -69,18 +71,6 @@ int MAIN(int argc, char **argv)
if ((bio_err=BIO_new(BIO_s_file())) != NULL)
BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
- if (bio_out == NULL)
- if ((bio_out=BIO_new(BIO_s_file())) != NULL)
- {
- BIO_set_fp(bio_out,stdout,BIO_NOCLOSE);
-#ifdef OPENSSL_SYS_VMS
- {
- BIO *tmpbio = BIO_new(BIO_f_linebuffer());
- bio_out = BIO_push(tmpbio, bio_out);
- }
-#endif
- }
-
--argc;
++argv;
while (argc >= 1 && **argv == '-')
@@ -95,16 +85,29 @@ int MAIN(int argc, char **argv)
else
{
BIO_printf(bio_err,"Unknown option '%s'\n",*argv);
- bad:
- BIO_printf(bio_err,"options are\n");
- BIO_printf(bio_err,"%-14s hex\n","-hex");
- BIO_printf(bio_err,"%-14s number of checks\n","-checks <n>");
- exit(1);
+ goto bad;
}
--argc;
++argv;
}
+ if (argv[0] == NULL)
+ {
+ BIO_printf(bio_err,"No prime specified\n");
+ goto bad;
+ }
+
+ if ((bio_out=BIO_new(BIO_s_file())) != NULL)
+ {
+ BIO_set_fp(bio_out,stdout,BIO_NOCLOSE);
+#ifdef OPENSSL_SYS_VMS
+ {
+ BIO *tmpbio = BIO_new(BIO_f_linebuffer());
+ bio_out = BIO_push(tmpbio, bio_out);
+ }
+#endif
+ }
+
if(hex)
BN_hex2bn(&bn,argv[0]);
else
@@ -112,7 +115,16 @@ int MAIN(int argc, char **argv)
BN_print(bio_out,bn);
BIO_printf(bio_out," is %sprime\n",
- BN_is_prime(bn,checks,NULL,NULL,NULL) ? "" : "not ");
+ BN_is_prime_ex(bn,checks,NULL,NULL) ? "" : "not ");
+
+ BN_free(bn);
+ BIO_free_all(bio_out);
return 0;
+
+ bad:
+ BIO_printf(bio_err,"options are\n");
+ BIO_printf(bio_err,"%-14s hex\n","-hex");
+ BIO_printf(bio_err,"%-14s number of checks\n","-checks <n>");
+ return 1;
}