int dsaparam_main(int argc, char **argv)
{
ENGINE *e = NULL;
- BIO *in = NULL, *out = NULL;
+ BIO *out = NULL;
EVP_PKEY *params = NULL, *pkey = NULL;
EVP_PKEY_CTX *ctx = NULL;
int numbits = -1, num = 0, genkey = 0;
}
private = genkey ? 1 : 0;
- in = bio_open_default(infile, 'r', informat);
- if (in == NULL)
- goto end;
out = bio_open_owner(outfile, outformat, private);
if (out == NULL)
goto end;
BIO_printf(bio_err, "Error, DSA key generation failed\n");
goto end;
}
- } else if (informat == FORMAT_ASN1) {
- params = d2i_KeyParams_bio(EVP_PKEY_DSA, NULL, in);
} else {
- params = PEM_read_bio_Parameters(in, NULL);
+ params = load_keyparams(infile, 1, "DSA parameters");
+ if (!EVP_PKEY_is_a(params, "DSA")) {
+ EVP_PKEY_free(params);
+ params = NULL;
+ }
}
if (params == NULL) {
BIO_printf(bio_err, "Error, unable to load DSA parameters\n");
end:
if (ret != 0)
ERR_print_errors(bio_err);
- BIO_free(in);
BIO_free_all(out);
EVP_PKEY_CTX_free(ctx);
EVP_PKEY_free(pkey);
const char *pass, ENGINE *e, const char *desc);
EVP_PKEY *load_pubkey(const char *uri, int format, int maybe_stdin,
const char *pass, ENGINE *e, const char *desc);
+EVP_PKEY *load_keyparams(const char *uri, int maybe_stdin, const char *desc);
int load_certs(const char *uri, STACK_OF(X509) **certs,
const char *pass, const char *desc);
int load_crls(const char *uri, STACK_OF(X509_CRL) **crls,
int load_key_certs_crls(const char *uri, int maybe_stdin,
const char *pass, const char *desc,
EVP_PKEY **ppkey, EVP_PKEY **ppubkey,
+ EVP_PKEY **pparams,
X509 **pcert, STACK_OF(X509) **pcerts,
X509_CRL **pcrl, STACK_OF(X509_CRL) **pcrls);
int load_key_cert_crl(const char *uri, int maybe_stdin,
if (desc == NULL)
desc = "certificate";
(void)load_key_certs_crls(uri, maybe_stdin, pass, desc,
- NULL, NULL, &cert, NULL, NULL, NULL);
+ NULL, NULL, NULL, &cert, NULL, NULL, NULL);
if (cert == NULL) {
BIO_printf(bio_err, "Unable to load %s\n", desc);
ERR_print_errors(bio_err);
if (desc == NULL)
desc = "CRL";
(void)load_key_certs_crls(uri, 0, NULL, desc,
- NULL, NULL, NULL, NULL, &crl, NULL);
+ NULL, NULL, NULL, NULL, NULL, &crl, NULL);
if (crl == NULL) {
BIO_printf(bio_err, "Unable to load %s\n", desc);
ERR_print_errors(bio_err);
}
} else {
(void)load_key_certs_crls(uri, may_stdin, pass, desc,
- &pkey, NULL, NULL, NULL, NULL, NULL);
+ &pkey, NULL, NULL, NULL, NULL, NULL, NULL);
}
if (pkey == NULL) {
}
} else {
(void)load_key_certs_crls(uri, maybe_stdin, pass, desc,
- NULL, &pkey, NULL, NULL, NULL, NULL);
+ NULL, &pkey, NULL, NULL, NULL, NULL, NULL);
}
if (pkey == NULL) {
BIO_printf(bio_err, "Unable to load %s\n", desc);
return pkey;
}
+EVP_PKEY *load_keyparams(const char *uri, int maybe_stdin, const char *desc)
+{
+ EVP_PKEY *params = NULL;
+
+ if (desc == NULL)
+ desc = "key parameters";
+
+ (void)load_key_certs_crls(uri, maybe_stdin, NULL, desc,
+ NULL, NULL, ¶ms, NULL, NULL, NULL, NULL);
+ if (params == NULL) {
+ BIO_printf(bio_err, "Unable to load %s\n", desc);
+ ERR_print_errors(bio_err);
+ }
+ return params;
+}
+
void app_bail_out(char *fmt, ...)
{
va_list args;
const char *pass, const char *desc)
{
int was_NULL = *certs == NULL;
- int ret = load_key_certs_crls(uri, 0, pass, desc, NULL, NULL,
+ int ret = load_key_certs_crls(uri, 0, pass, desc, NULL, NULL, NULL,
NULL, certs, NULL, NULL);
if (!ret && was_NULL) {
const char *pass, const char *desc)
{
int was_NULL = *crls == NULL;
- int ret = load_key_certs_crls(uri, 0, pass, desc, NULL, NULL,
+ int ret = load_key_certs_crls(uri, 0, pass, desc, NULL, NULL, NULL,
NULL, NULL, NULL, crls);
if (!ret && was_NULL) {
int load_key_certs_crls(const char *uri, int maybe_stdin,
const char *pass, const char *desc,
EVP_PKEY **ppkey, EVP_PKEY **ppubkey,
+ EVP_PKEY **pparams,
X509 **pcert, STACK_OF(X509) **pcerts,
X509_CRL **pcrl, STACK_OF(X509_CRL) **pcrls)
{
if (ppubkey != NULL && *ppubkey == NULL)
ok = ((*ppubkey = OSSL_STORE_INFO_get1_PUBKEY(info)) != NULL);
break;
+ case OSSL_STORE_INFO_PARAMS:
+ if (pparams != NULL && *pparams == NULL)
+ ok = ((*pparams = OSSL_STORE_INFO_get1_PARAMS(info)) != NULL);
+ break;
case OSSL_STORE_INFO_CERT:
if (pcert != NULL && *pcert == NULL)
ok = (*pcert = OSSL_STORE_INFO_get1_CERT(info)) != NULL;
if (failed == NULL) {
int any = 0;
- if (ppkey != NULL && *ppkey == NULL) {
+ if ((ppkey != NULL && *ppkey == NULL)
+ || (ppubkey != NULL && *ppubkey == NULL)) {
failed = "key";
+ } else if (pparams != NULL && *pparams == NULL) {
+ failed = "params";
} else if ((pcert != NULL || pcerts != NULL) && ncerts == 0) {
if (pcert == NULL)
any = 1;