if (!noout) {
if (outformat == FORMAT_PEM) {
if (pubout) {
- PEM_write_bio_PUBKEY(out, pkey);
+ if (!PEM_write_bio_PUBKEY(out, pkey))
+ goto end;
} else {
assert(private);
- if (traditional)
- PEM_write_bio_PrivateKey_traditional(out, pkey, cipher,
- NULL, 0, NULL,
- passout);
- else
- PEM_write_bio_PrivateKey(out, pkey, cipher,
- NULL, 0, NULL, passout);
+ if (traditional) {
+ if (!PEM_write_bio_PrivateKey_traditional(out, pkey, cipher,
+ NULL, 0, NULL,
+ passout))
+ goto end;
+ } else {
+ if (!PEM_write_bio_PrivateKey(out, pkey, cipher,
+ NULL, 0, NULL, passout))
+ goto end;
+ }
}
} else if (outformat == FORMAT_ASN1) {
if (pubout) {
- i2d_PUBKEY_bio(out, pkey);
+ if (!i2d_PUBKEY_bio(out, pkey))
+ goto end;
} else {
assert(private);
- i2d_PrivateKey_bio(out, pkey);
+ if (!i2d_PrivateKey_bio(out, pkey))
+ goto end;
}
} else {
BIO_printf(bio_err, "Bad format specified for key\n");
if (text) {
if (pubtext) {
- EVP_PKEY_print_public(out, pkey, 0, NULL);
+ if (EVP_PKEY_print_public(out, pkey, 0, NULL) <= 0)
+ goto end;
} else {
assert(private);
- EVP_PKEY_print_private(out, pkey, 0, NULL);
+ if (EVP_PKEY_print_private(out, pkey, 0, NULL) <= 0)
+ goto end;
}
}