Remove redundant OPENSSL_NO_DEPRECATED suppression
[openssl.git] / apps / req.c
index 303bbf9d1721787af8221f2287512d7e90d121ef..a69915f2f4b4a3041ac969e5700303ed8747a096 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 <time.h>
@@ -644,6 +638,11 @@ bad:
                if (inrand)
                        app_RAND_load_files(inrand);
 
+               if (!NCONF_get_number(req_conf,SECTION,BITS, &newkey))
+                       {
+                       newkey=DEFAULT_KEY_LENGTH;
+                       }
+
                if (keyalg)
                        {
                        genctx = set_keygen_ctx(bio_err, keyalg, &pkey_type, &newkey,
@@ -652,12 +651,6 @@ bad:
                                goto end;
                        }
        
-               if (newkey <= 0)
-                       {
-                       if (!NCONF_get_number(req_conf,SECTION,BITS, &newkey))
-                               newkey=DEFAULT_KEY_LENGTH;
-                       }
-
                if (newkey < MIN_KEY_LENGTH && (pkey_type == EVP_PKEY_RSA || pkey_type == EVP_PKEY_DSA))
                        {
                        BIO_printf(bio_err,"private key length is too short,\n");
@@ -1487,7 +1480,13 @@ start:
 #ifdef CHARSET_EBCDIC
        ebcdic2ascii(buf, buf, i);
 #endif
-       if(!req_check_len(i, n_min, n_max)) goto start;
+       if(!req_check_len(i, n_min, n_max))
+               {
+               if (batch || value)
+                       return 0;
+               goto start;
+               }
+
        if (!X509_NAME_add_entry_by_NID(n,nid, chtype,
                                (unsigned char *) buf, -1,-1,mval)) goto err;
        ret=1;
@@ -1546,7 +1545,12 @@ start:
 #ifdef CHARSET_EBCDIC
        ebcdic2ascii(buf, buf, i);
 #endif
-       if(!req_check_len(i, n_min, n_max)) goto start;
+       if(!req_check_len(i, n_min, n_max))
+               {
+               if (batch || value)
+                       return 0;
+               goto start;
+               }
 
        if(!X509_REQ_add1_attr_by_NID(req, nid, chtype,
                                        (unsigned char *)buf, -1)) {
@@ -1646,6 +1650,8 @@ static EVP_PKEY_CTX *set_keygen_ctx(BIO *err, const char *gstr, int *pkey_type,
                                keylen = atol(p + 1);
                                *pkeylen = keylen;
                                }
+                       else
+                               keylen = *pkeylen;
                        }
                else if (p)
                        paramfile = p + 1;
@@ -1761,9 +1767,6 @@ static int genpkey_cb(EVP_PKEY_CTX *ctx)
        if (p == 3) c='\n';
        BIO_write(b,&c,1);
        (void)BIO_flush(b);
-#ifdef LINT
-       p=n;
-#endif
        return 1;
        }