summaryrefslogtreecommitdiff
path: root/src/usr.bin/openssl/apps.c
diff options
context:
space:
mode:
authorbcook <>2015-09-11 14:30:23 +0000
committerbcook <>2015-09-11 14:30:23 +0000
commite2fad4e6bdd4e404b3f4c186de52078738af2271 (patch)
treecc1109842924cab95a77b6863b32de51b6d4f960 /src/usr.bin/openssl/apps.c
parent7cea1ef22b79637be449efa70b99c6deaf74ef10 (diff)
downloadopenbsd-e2fad4e6bdd4e404b3f4c186de52078738af2271.tar.gz
openbsd-e2fad4e6bdd4e404b3f4c186de52078738af2271.tar.bz2
openbsd-e2fad4e6bdd4e404b3f4c186de52078738af2271.zip
Remove engine command and parameters from openssl(1).
We do not have any builtin or dynamic engines, meaning openssl(1) has no way to use the engine command or parameters at all. ok jsing@
Diffstat (limited to '')
-rw-r--r--src/usr.bin/openssl/apps.c103
1 files changed, 11 insertions, 92 deletions
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c
index acd95abc7f..f8cad1a703 100644
--- a/src/usr.bin/openssl/apps.c
+++ b/src/usr.bin/openssl/apps.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: apps.c,v 1.34 2015/09/10 16:01:06 jsing Exp $ */ 1/* $OpenBSD: apps.c,v 1.35 2015/09/11 14:30:23 bcook Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -146,10 +146,6 @@
146#include <openssl/x509.h> 146#include <openssl/x509.h>
147#include <openssl/x509v3.h> 147#include <openssl/x509v3.h>
148 148
149#ifndef OPENSSL_NO_ENGINE
150#include <openssl/engine.h>
151#endif
152
153#include <openssl/rsa.h> 149#include <openssl/rsa.h>
154 150
155typedef struct { 151typedef struct {
@@ -190,8 +186,6 @@ str2fmt(char *s)
190 (strcmp(s, "PKCS12") == 0) || (strcmp(s, "pkcs12") == 0) || 186 (strcmp(s, "PKCS12") == 0) || (strcmp(s, "pkcs12") == 0) ||
191 (strcmp(s, "P12") == 0) || (strcmp(s, "p12") == 0)) 187 (strcmp(s, "P12") == 0) || (strcmp(s, "p12") == 0))
192 return (FORMAT_PKCS12); 188 return (FORMAT_PKCS12);
193 else if ((*s == 'E') || (*s == 'e'))
194 return (FORMAT_ENGINE);
195 else if ((*s == 'P') || (*s == 'p')) { 189 else if ((*s == 'P') || (*s == 'p')) {
196 if (s[1] == 'V' || s[1] == 'v') 190 if (s[1] == 'V' || s[1] == 'v')
197 return FORMAT_PVK; 191 return FORMAT_PVK;
@@ -626,7 +620,7 @@ die:
626} 620}
627 621
628X509 * 622X509 *
629load_cert(BIO *err, const char *file, int format, const char *pass, ENGINE *e, 623load_cert(BIO *err, const char *file, int format, const char *pass,
630 const char *cert_descrip) 624 const char *cert_descrip)
631{ 625{
632 X509 *x = NULL; 626 X509 *x = NULL;
@@ -690,7 +684,7 @@ end:
690 684
691EVP_PKEY * 685EVP_PKEY *
692load_key(BIO *err, const char *file, int format, int maybe_stdin, 686load_key(BIO *err, const char *file, int format, int maybe_stdin,
693 const char *pass, ENGINE *e, const char *key_descrip) 687 const char *pass, const char *key_descrip)
694{ 688{
695 BIO *key = NULL; 689 BIO *key = NULL;
696 EVP_PKEY *pkey = NULL; 690 EVP_PKEY *pkey = NULL;
@@ -699,26 +693,10 @@ load_key(BIO *err, const char *file, int format, int maybe_stdin,
699 cb_data.password = pass; 693 cb_data.password = pass;
700 cb_data.prompt_info = file; 694 cb_data.prompt_info = file;
701 695
702 if (file == NULL && (!maybe_stdin || format == FORMAT_ENGINE)) { 696 if (file == NULL && (!maybe_stdin)) {
703 BIO_printf(err, "no keyfile specified\n"); 697 BIO_printf(err, "no keyfile specified\n");
704 goto end; 698 goto end;
705 } 699 }
706#ifndef OPENSSL_NO_ENGINE
707 if (format == FORMAT_ENGINE) {
708 if (!e)
709 BIO_printf(err, "no engine specified\n");
710 else {
711 pkey = ENGINE_load_private_key(e, file,
712 ui_method, &cb_data);
713 if (!pkey) {
714 BIO_printf(err, "cannot load %s from engine\n",
715 key_descrip);
716 ERR_print_errors(err);
717 }
718 }
719 goto end;
720 }
721#endif
722 key = BIO_new(BIO_s_file()); 700 key = BIO_new(BIO_s_file());
723 if (key == NULL) { 701 if (key == NULL) {
724 ERR_print_errors(err); 702 ERR_print_errors(err);
@@ -769,7 +747,7 @@ end:
769 747
770EVP_PKEY * 748EVP_PKEY *
771load_pubkey(BIO *err, const char *file, int format, int maybe_stdin, 749load_pubkey(BIO *err, const char *file, int format, int maybe_stdin,
772 const char *pass, ENGINE *e, const char *key_descrip) 750 const char *pass, const char *key_descrip)
773{ 751{
774 BIO *key = NULL; 752 BIO *key = NULL;
775 EVP_PKEY *pkey = NULL; 753 EVP_PKEY *pkey = NULL;
@@ -778,20 +756,10 @@ load_pubkey(BIO *err, const char *file, int format, int maybe_stdin,
778 cb_data.password = pass; 756 cb_data.password = pass;
779 cb_data.prompt_info = file; 757 cb_data.prompt_info = file;
780 758
781 if (file == NULL && (!maybe_stdin || format == FORMAT_ENGINE)) { 759 if (file == NULL && !maybe_stdin) {
782 BIO_printf(err, "no keyfile specified\n"); 760 BIO_printf(err, "no keyfile specified\n");
783 goto end; 761 goto end;
784 } 762 }
785#ifndef OPENSSL_NO_ENGINE
786 if (format == FORMAT_ENGINE) {
787 if (!e)
788 BIO_printf(bio_err, "no engine specified\n");
789 else
790 pkey = ENGINE_load_public_key(e, file,
791 ui_method, &cb_data);
792 goto end;
793 }
794#endif
795 key = BIO_new(BIO_s_file()); 763 key = BIO_new(BIO_s_file());
796 if (key == NULL) { 764 if (key == NULL) {
797 ERR_print_errors(err); 765 ERR_print_errors(err);
@@ -899,7 +867,7 @@ error:
899 867
900static int 868static int
901load_certs_crls(BIO *err, const char *file, int format, const char *pass, 869load_certs_crls(BIO *err, const char *file, int format, const char *pass,
902 ENGINE *e, const char *desc, STACK_OF(X509) **pcerts, 870 const char *desc, STACK_OF(X509) **pcerts,
903 STACK_OF(X509_CRL) **pcrls) 871 STACK_OF(X509_CRL) **pcrls)
904{ 872{
905 int i; 873 int i;
@@ -983,22 +951,22 @@ end:
983 951
984STACK_OF(X509) * 952STACK_OF(X509) *
985load_certs(BIO *err, const char *file, int format, const char *pass, 953load_certs(BIO *err, const char *file, int format, const char *pass,
986 ENGINE *e, const char *desc) 954 const char *desc)
987{ 955{
988 STACK_OF(X509) *certs; 956 STACK_OF(X509) *certs;
989 957
990 if (!load_certs_crls(err, file, format, pass, e, desc, &certs, NULL)) 958 if (!load_certs_crls(err, file, format, pass, desc, &certs, NULL))
991 return NULL; 959 return NULL;
992 return certs; 960 return certs;
993} 961}
994 962
995STACK_OF(X509_CRL) * 963STACK_OF(X509_CRL) *
996load_crls(BIO *err, const char *file, int format, const char *pass, ENGINE *e, 964load_crls(BIO *err, const char *file, int format, const char *pass,
997 const char *desc) 965 const char *desc)
998{ 966{
999 STACK_OF(X509_CRL) *crls; 967 STACK_OF(X509_CRL) *crls;
1000 968
1001 if (!load_certs_crls(err, file, format, pass, e, desc, NULL, &crls)) 969 if (!load_certs_crls(err, file, format, pass, desc, NULL, &crls))
1002 return NULL; 970 return NULL;
1003 return crls; 971 return crls;
1004} 972}
@@ -1248,55 +1216,6 @@ end:
1248 return NULL; 1216 return NULL;
1249} 1217}
1250 1218
1251#ifndef OPENSSL_NO_ENGINE
1252
1253ENGINE *
1254setup_engine(BIO *err, const char *engine, int debug)
1255{
1256 ENGINE *e = NULL;
1257
1258 if (engine) {
1259 if (strcmp(engine, "auto") == 0) {
1260 BIO_printf(err, "enabling auto ENGINE support\n");
1261 ENGINE_register_all_complete();
1262 return NULL;
1263 }
1264 if ((e = ENGINE_by_id(engine)) == NULL) {
1265 BIO_printf(err, "invalid engine \"%s\"\n", engine);
1266 ERR_print_errors(err);
1267 return NULL;
1268 }
1269 if (debug) {
1270 if (ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM,
1271 0, err, 0) <= 0) {
1272 BIO_printf(err, "Cannot set logstream for "
1273 "engine \"%s\"\n", engine);
1274 ERR_print_errors(err);
1275 ENGINE_free(e);
1276 return NULL;
1277 }
1278 }
1279 if (!ENGINE_ctrl_cmd(e, "SET_USER_INTERFACE", 0, ui_method, 0, 1)) {
1280 BIO_printf(err, "can't set user interface\n");
1281 ERR_print_errors(err);
1282 ENGINE_free(e);
1283 return NULL;
1284 }
1285 if (!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
1286 BIO_printf(err, "can't use that engine\n");
1287 ERR_print_errors(err);
1288 ENGINE_free(e);
1289 return NULL;
1290 }
1291 BIO_printf(err, "engine \"%s\" set.\n", ENGINE_get_id(e));
1292
1293 /* Free our "structural" reference. */
1294 ENGINE_free(e);
1295 }
1296 return e;
1297}
1298#endif
1299
1300int 1219int
1301load_config(BIO *err, CONF *cnf) 1220load_config(BIO *err, CONF *cnf)
1302{ 1221{