Remove apps cache for gethostbyname
[openssl.git] / apps / rsa.c
index 7f7069c899623bf7c0613bb4e732e480ed475ba5..858699bc18cd5c542d6180cb0d128d9d29c007c7 100644 (file)
@@ -136,8 +136,8 @@ OPTIONS rsa_options[] = {
     {"pubout", OPT_PUBOUT, '-', "Output a public key"},
     {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
     {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
-    {"RSAPublicKey_in", OPT_RSAPUBKEY_IN, '-', "Input is an RSAPublicKye"},
-    {"RSAPublicKey_out", OPT_RSAPUBKEY_OUT, '-', "Output is an RSAPublicKye"},
+    {"RSAPublicKey_in", OPT_RSAPUBKEY_IN, '-', "Input is an RSAPublicKey"},
+    {"RSAPublicKey_out", OPT_RSAPUBKEY_OUT, '-', "Output is an RSAPublicKey"},
     {"pvk-strong", OPT_PVK_STRONG, '-'},
     {"pvk-weak", OPT_PVK_WEAK, '-'},
     {"pvk-none", OPT_PVK_NONE, '-'},
@@ -158,7 +158,7 @@ int rsa_main(int argc, char **argv)
     BIO *out = NULL;
     RSA *rsa = NULL;
     const EVP_CIPHER *enc = NULL;
-    char *engine = NULL, *infile = NULL, *outfile = NULL, *prog;
+    char *infile = NULL, *outfile = NULL, *prog;
     char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL;
     int i;
     int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, check = 0;
@@ -203,7 +203,7 @@ int rsa_main(int argc, char **argv)
             passoutarg = opt_arg();
             break;
         case OPT_ENGINE:
-            engine = opt_arg();
+            e = setup_engine(opt_arg(), 0);
             break;
         case OPT_PUBIN:
             pubin = 1;
@@ -249,10 +249,6 @@ int rsa_main(int argc, char **argv)
     argc = opt_num_rest();
     argv = opt_rest();
 
-# ifndef OPENSSL_NO_ENGINE
-    e = setup_engine(engine, 0);
-# endif
-
     if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
         BIO_printf(bio_err, "Error getting passwords\n");
         goto end;
@@ -325,8 +321,8 @@ int rsa_main(int argc, char **argv)
             }
         }
 
-        if (r == -1 || ERR_peek_error() != 0) { /* should happen only if r ==
-                                                 * -1 */
+        /* should happen only if r == -1 */
+        if (r == -1 || ERR_peek_error() != 0) {
             ERR_print_errors(bio_err);
             goto end;
         }
@@ -348,19 +344,14 @@ int rsa_main(int argc, char **argv)
     }
 # ifndef OPENSSL_NO_RC4
     else if (outformat == FORMAT_NETSCAPE) {
-        unsigned char *p, *pp;
-        int size;
+        unsigned char *p, *save;
+        int size = i2d_RSA_NET(rsa, NULL, NULL, 0);
 
-        i = 1;
-        size = i2d_RSA_NET(rsa, NULL, NULL, 0);
-        if ((p = (unsigned char *)OPENSSL_malloc(size)) == NULL) {
-            BIO_printf(bio_err, "Memory allocation failure\n");
-            goto end;
-        }
-        pp = p;
+        save = p = app_malloc(size, "RSA i2d buffer");
         i2d_RSA_NET(rsa, &p, NULL, 0);
-        BIO_write(out, (char *)pp, size);
-        OPENSSL_free(pp);
+        BIO_write(out, (char *)save, size);
+        OPENSSL_free(save);
+        i = 1;
     }
 # endif
     else if (outformat == FORMAT_PEM) {
@@ -397,10 +388,8 @@ int rsa_main(int argc, char **argv)
  end:
     BIO_free_all(out);
     RSA_free(rsa);
-    if (passin)
-        OPENSSL_free(passin);
-    if (passout)
-        OPENSSL_free(passout);
+    OPENSSL_free(passin);
+    OPENSSL_free(passout);
     return (ret);
 }
 #else                           /* !OPENSSL_NO_RSA */