Fix typo in message (RT 3107)
[openssl.git] / apps / pkcs8.c
index 43ff86d4f7221e50101669b01c7b9b4584f836d6..73873d2c9dc02bd49d60efeb03e6ae9bc9121b71 100644 (file)
@@ -56,6 +56,7 @@
  *
  */
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include "apps.h"
 #include <openssl/pem.h>
@@ -135,6 +136,22 @@ int MAIN(int argc, char **argv)
                        else
                                badarg = 1;
                        }
+               else if (!strcmp(*args,"-v2prf"))
+                       {
+                       if (args[1])
+                               {
+                               args++;
+                               pbe_nid=OBJ_txt2nid(*args);
+                               if (!EVP_PBE_find(EVP_PBE_TYPE_PRF, pbe_nid, NULL, NULL, 0))
+                                       {
+                                       BIO_printf(bio_err,
+                                                "Unknown PRF algorithm %s\n", *args);
+                                       badarg = 1;
+                                       }
+                               }
+                       else
+                               badarg = 1;
+                       }
                else if (!strcmp(*args,"-inform"))
                        {
                        if (args[1])
@@ -157,6 +174,15 @@ int MAIN(int argc, char **argv)
                        topk8 = 1;
                else if (!strcmp (*args, "-noiter"))
                        iter = 1;
+               else if (!strcmp (*args, "-iter"))
+                       {
+                       if (args[1])
+                               {
+                               iter = atoi(*(++args));
+                               if (iter <= 0) badarg = 1;
+                               }
+                       else badarg = 1;
+                       }
                else if (!strcmp (*args, "-nocrypt"))
                        nocrypt = 1;
                else if (!strcmp (*args, "-nooct"))
@@ -167,19 +193,22 @@ int MAIN(int argc, char **argv)
                        p8_broken = PKCS8_EMBEDDED_PARAM;
                else if (!strcmp(*args,"-passin"))
                        {
-                       if (!args[1]) goto bad;
-                       passargin= *(++args);
+                       if (args[1])
+                               passargin= *(++args);
+                       else badarg = 1;
                        }
                else if (!strcmp(*args,"-passout"))
                        {
-                       if (!args[1]) goto bad;
-                       passargout= *(++args);
+                       if (args[1])
+                               passargout= *(++args);
+                       else badarg = 1;
                        }
 #ifndef OPENSSL_NO_ENGINE
                else if (strcmp(*args,"-engine") == 0)
                        {
-                       if (!args[1]) goto bad;
-                       engine= *(++args);
+                       if (args[1])
+                               engine= *(++args);
+                       else badarg = 1;
                        }
 #endif
                else if (!strcmp (*args, "-in"))
@@ -206,7 +235,6 @@ int MAIN(int argc, char **argv)
 
        if (badarg)
                {
-               bad:
                BIO_printf(bio_err, "Usage pkcs8 [options]\n");
                BIO_printf(bio_err, "where options are\n");
                BIO_printf(bio_err, "-in file        input file\n");
@@ -219,6 +247,7 @@ int MAIN(int argc, char **argv)
                BIO_printf(bio_err, "-nooct          use (nonstandard) no octet format\n");
                BIO_printf(bio_err, "-embed          use (nonstandard) embedded DSA parameters format\n");
                BIO_printf(bio_err, "-nsdb           use (nonstandard) DSA Netscape DB format\n");
+               BIO_printf(bio_err, "-iter count     use count as iteration count\n");
                BIO_printf(bio_err, "-noiter         use 1 as iteration count\n");
                BIO_printf(bio_err, "-nocrypt        use or expect unencrypted private key\n");
                BIO_printf(bio_err, "-v2 alg         use PKCS#5 v2.0 and cipher \"alg\"\n");
@@ -275,7 +304,6 @@ int MAIN(int argc, char **argv)
                }
        if (topk8)
                {
-               BIO_free(in); /* Not needed in this section */
                pkey = load_key(bio_err, infile, informat, 1,
                        passin, e, "key");
                if (!pkey)
@@ -404,6 +432,10 @@ int MAIN(int argc, char **argv)
                        BIO_printf(bio_err, "DSA public key include in PrivateKey\n");
                        break;
 
+                       case PKCS8_NEG_PRIVKEY:
+                       BIO_printf(bio_err, "DSA private key value is negative\n");
+                       break;
+
                        default:
                        BIO_printf(bio_err, "Unknown broken type\n");
                        break;