- if (bio_err == NULL) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE);
-
- if (!load_config(bio_err, NULL))
- goto end;
-
- informat=FORMAT_PEM;
- outformat=FORMAT_PEM;
-
- ERR_load_crypto_strings();
- OpenSSL_add_all_algorithms();
- args = argv + 1;
- while (!badarg && *args && *args[0] == '-')
- {
- if (!strcmp(*args,"-v2"))
- {
- if (args[1])
- {
- args++;
- cipher=EVP_get_cipherbyname(*args);
- if (!cipher)
- {
- BIO_printf(bio_err,
- "Unknown cipher %s\n", *args);
- badarg = 1;
- }
- }
- else
- badarg = 1;
- }
- else if (!strcmp(*args,"-v1"))
- {
- if (args[1])
- {
- args++;
- pbe_nid=OBJ_txt2nid(*args);
- if (pbe_nid == NID_undef)
- {
- BIO_printf(bio_err,
- "Unknown PBE algorithm %s\n", *args);
- badarg = 1;
- }
- }
- 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])
- {
- args++;
- informat=str2fmt(*args);
- }
- else badarg = 1;
- }
- else if (!strcmp(*args,"-outform"))
- {
- if (args[1])
- {
- args++;
- outformat=str2fmt(*args);
- }
- else badarg = 1;
- }
- else if (!strcmp (*args, "-topk8"))
- topk8 = 1;
- else if (!strcmp (*args, "-noiter"))
- iter = 1;
- else if (!strcmp (*args, "-iter"))
- {
- if (!args[1]) goto bad;
- iter = atoi(*(++args));
- if (iter <= 0) goto bad;
- }
- else if (!strcmp (*args, "-nocrypt"))
- nocrypt = 1;
- else if (!strcmp (*args, "-nooct"))
- p8_broken = PKCS8_NO_OCTET;
- else if (!strcmp (*args, "-nsdb"))
- p8_broken = PKCS8_NS_DB;
- else if (!strcmp (*args, "-embed"))
- p8_broken = PKCS8_EMBEDDED_PARAM;
- else if (!strcmp(*args,"-passin"))
- {
- if (!args[1]) goto bad;
- passargin= *(++args);
- }
- else if (!strcmp(*args,"-passout"))
- {
- if (!args[1]) goto bad;
- passargout= *(++args);
- }
+OPTIONS pkcs8_options[] = {
+ {"help", OPT_HELP, '-', "Display this summary"},
+ {"inform", OPT_INFORM, 'F', "Input format (DER or PEM)"},
+ {"outform", OPT_OUTFORM, 'F', "Output format (DER or PEM)"},
+ {"in", OPT_IN, '<', "Input file"},
+ {"out", OPT_OUT, '>', "Output file"},
+ {"topk8", OPT_TOPK8, '-', "Output PKCS8 file"},
+ {"noiter", OPT_NOITER, '-', "Use 1 as iteration count"},
+ {"nocrypt", OPT_NOCRYPT, '-', "Use or expect unencrypted private key"},
+ {"nooct", OPT_NOOCT, '-', "Use (nonstandard) no octet format"},
+ {"nsdb", OPT_NSDB, '-', "Use (nonstandard) DSA Netscape DB format"},
+ {"embed", OPT_EMBED, '-',
+ "Use (nonstandard) embedded DSA parameters format"},
+ {"v2", OPT_V2, 's', "Use PKCS#5 v2.0 and cipher"},
+ {"v1", OPT_V1, 's', "Use PKCS#5 v1.5 and cipher"},
+ {"v2prf", OPT_V2PRF, 's'},
+ {"iter", OPT_ITER, 'p', "Specify the iteration count"},
+ {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
+ {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},