- }
-
- if(generate)
- {
- char *s;
-
- if(!bits)
- {
- BIO_printf(bio_err,"Specifiy the number of bits.\n");
- return 1;
- }
- bn=BN_new();
- BN_generate_prime_ex(bn,bits,safe,NULL,NULL,NULL);
- s=hex ? BN_bn2hex(bn) : BN_bn2dec(bn);
- BIO_printf(bio_out,"%s\n",s);
- OPENSSL_free(s);
- }
- else
- {
- if(hex)
- BN_hex2bn(&bn,argv[0]);
- else
- BN_dec2bn(&bn,argv[0]);
-
- BN_print(bio_out,bn);
- BIO_printf(bio_out," is %sprime\n",
- BN_is_prime_ex(bn,checks,NULL,NULL) ? "" : "not ");
- }
+ }
+
+ if (generate) {
+ char *s;
+
+ if (!bits) {
+ BIO_printf(bio_err, "Specifiy the number of bits.\n");
+ return 1;
+ }
+ bn = BN_new();
+ BN_generate_prime_ex(bn, bits, safe, NULL, NULL, NULL);
+ s = hex ? BN_bn2hex(bn) : BN_bn2dec(bn);
+ BIO_printf(bio_out, "%s\n", s);
+ OPENSSL_free(s);
+ } else {
+ int r;
+
+ if (hex)
+ r = BN_hex2bn(&bn, argv[0]);
+ else
+ r = BN_dec2bn(&bn, argv[0]);
+
+ if(!r) {
+ BIO_printf(bio_err, "Failed to process value (%s)\n", argv[0]);
+ goto end;
+ }
+
+ BN_print(bio_out, bn);
+ BIO_printf(bio_out, " is %sprime\n",
+ BN_is_prime_ex(bn, checks, NULL, NULL) ? "" : "not ");
+ }