- if(keyfile) {
- BIO *keybio;
- keybio = BIO_new_file(keyfile, "r");
- if(!keybio) {
- BIO_printf(bio_err, "Error opening key file %s\n",
- keyfile);
- ERR_print_errors(bio_err);
+ if(keyfile)
+ {
+ if (keyform == FORMAT_PEM)
+ {
+ BIO *keybio;
+ keybio = BIO_new_file(keyfile, "r");
+ if(!keybio)
+ {
+ BIO_printf(bio_err,
+ "Error opening key file %s\n",
+ keyfile);
+ ERR_print_errors(bio_err);
+ goto end;
+ }
+ if(want_pub)
+ sigkey = PEM_read_bio_PUBKEY(keybio,
+ NULL, NULL, NULL);
+ else
+ sigkey = PEM_read_bio_PrivateKey(keybio,
+ NULL, NULL, NULL);
+ BIO_free(keybio);
+ }
+ else if (keyform == FORMAT_ENGINE)
+ {
+ if (!e)
+ {
+ BIO_printf(bio_err,"no engine specified\n");
+ goto end;
+ }
+ if (want_pub)
+ sigkey = ENGINE_load_public_key(e, keyfile, NULL);
+ else
+ sigkey = ENGINE_load_private_key(e, keyfile, NULL);
+ }
+ else
+ {
+ BIO_printf(bio_err,
+ "bad input format specified for key file\n");