Import OpenSSL 1.1.0f
This commit is contained in:
@@ -1,435 +0,0 @@
|
||||
#
|
||||
# OpenSSL/crypto/engine/Makefile
|
||||
#
|
||||
|
||||
DIR= engine
|
||||
TOP= ../..
|
||||
CC= cc
|
||||
INCLUDES= -I.. -I$(TOP) -I../../include
|
||||
CFLAG=-g
|
||||
MAKEFILE= Makefile
|
||||
AR= ar r
|
||||
|
||||
CFLAGS= $(INCLUDES) $(CFLAG)
|
||||
|
||||
GENERAL=Makefile
|
||||
TEST= enginetest.c
|
||||
APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC= eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c \
|
||||
eng_table.c eng_pkey.c eng_fat.c eng_all.c \
|
||||
tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_ecdh.c tb_rand.c tb_store.c \
|
||||
tb_cipher.c tb_digest.c tb_pkmeth.c tb_asnmth.c \
|
||||
eng_openssl.c eng_cnf.c eng_dyn.c eng_cryptodev.c \
|
||||
eng_rdrand.c
|
||||
LIBOBJ= eng_err.o eng_lib.o eng_list.o eng_init.o eng_ctrl.o \
|
||||
eng_table.o eng_pkey.o eng_fat.o eng_all.o \
|
||||
tb_rsa.o tb_dsa.o tb_ecdsa.o tb_dh.o tb_ecdh.o tb_rand.o tb_store.o \
|
||||
tb_cipher.o tb_digest.o tb_pkmeth.o tb_asnmth.o \
|
||||
eng_openssl.o eng_cnf.o eng_dyn.o eng_cryptodev.o \
|
||||
eng_rdrand.o
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= engine.h
|
||||
HEADER= $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
|
||||
top:
|
||||
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
|
||||
|
||||
all: lib
|
||||
|
||||
lib: $(LIBOBJ)
|
||||
$(AR) $(LIB) $(LIBOBJ)
|
||||
$(RANLIB) $(LIB) || echo Never mind.
|
||||
@touch lib
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
|
||||
|
||||
links:
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
|
||||
|
||||
install:
|
||||
@[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
|
||||
@headerlist="$(EXHEADER)"; for i in $$headerlist ; \
|
||||
do \
|
||||
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
|
||||
done;
|
||||
|
||||
tags:
|
||||
ctags $(SRC)
|
||||
|
||||
tests:
|
||||
|
||||
lint:
|
||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
||||
|
||||
update: depend
|
||||
|
||||
depend:
|
||||
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
|
||||
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
|
||||
|
||||
dclean:
|
||||
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
|
||||
mv -f Makefile.new $(MAKEFILE)
|
||||
|
||||
clean:
|
||||
rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
eng_all.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
eng_all.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
eng_all.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
eng_all.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
eng_all.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
eng_all.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
eng_all.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
eng_all.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
eng_all.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
eng_all.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
eng_all.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
eng_all.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
eng_all.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_all.c eng_int.h
|
||||
eng_cnf.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
eng_cnf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
eng_cnf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
|
||||
eng_cnf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
eng_cnf.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
eng_cnf.o: ../../include/openssl/engine.h ../../include/openssl/err.h
|
||||
eng_cnf.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
|
||||
eng_cnf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
eng_cnf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
eng_cnf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
|
||||
eng_cnf.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
eng_cnf.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
eng_cnf.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
eng_cnf.o: ../cryptlib.h eng_cnf.c eng_int.h
|
||||
eng_cryptodev.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
eng_cryptodev.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
|
||||
eng_cryptodev.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
eng_cryptodev.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
eng_cryptodev.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
eng_cryptodev.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
|
||||
eng_cryptodev.o: ../../include/openssl/obj_mac.h
|
||||
eng_cryptodev.o: ../../include/openssl/objects.h
|
||||
eng_cryptodev.o: ../../include/openssl/opensslconf.h
|
||||
eng_cryptodev.o: ../../include/openssl/opensslv.h
|
||||
eng_cryptodev.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
|
||||
eng_cryptodev.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
eng_cryptodev.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
eng_cryptodev.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
eng_cryptodev.o: eng_cryptodev.c
|
||||
eng_ctrl.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
eng_ctrl.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
eng_ctrl.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
eng_ctrl.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
eng_ctrl.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
eng_ctrl.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
eng_ctrl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
eng_ctrl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
eng_ctrl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
eng_ctrl.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
eng_ctrl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
eng_ctrl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
eng_ctrl.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_ctrl.c eng_int.h
|
||||
eng_dyn.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
eng_dyn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
eng_dyn.o: ../../include/openssl/crypto.h ../../include/openssl/dso.h
|
||||
eng_dyn.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
eng_dyn.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
eng_dyn.o: ../../include/openssl/engine.h ../../include/openssl/err.h
|
||||
eng_dyn.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
|
||||
eng_dyn.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
eng_dyn.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
eng_dyn.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
|
||||
eng_dyn.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
eng_dyn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
eng_dyn.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
eng_dyn.o: ../cryptlib.h eng_dyn.c eng_int.h
|
||||
eng_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
eng_err.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
eng_err.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
eng_err.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
eng_err.o: ../../include/openssl/engine.h ../../include/openssl/err.h
|
||||
eng_err.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
|
||||
eng_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
eng_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
eng_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
|
||||
eng_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
eng_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
eng_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
eng_err.o: eng_err.c
|
||||
eng_fat.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
eng_fat.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
eng_fat.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
|
||||
eng_fat.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
eng_fat.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
eng_fat.o: ../../include/openssl/engine.h ../../include/openssl/err.h
|
||||
eng_fat.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
|
||||
eng_fat.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
eng_fat.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
eng_fat.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
|
||||
eng_fat.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
eng_fat.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
eng_fat.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
eng_fat.o: ../cryptlib.h eng_fat.c eng_int.h
|
||||
eng_init.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
eng_init.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
eng_init.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
eng_init.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
eng_init.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
eng_init.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
eng_init.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
eng_init.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
eng_init.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
eng_init.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
eng_init.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
eng_init.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
eng_init.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_init.c eng_int.h
|
||||
eng_lib.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
eng_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
eng_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
eng_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
eng_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
eng_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
eng_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
eng_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
eng_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
eng_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
|
||||
eng_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
eng_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
eng_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
eng_lib.o: ../cryptlib.h eng_int.h eng_lib.c
|
||||
eng_list.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
eng_list.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
eng_list.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
eng_list.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
eng_list.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
eng_list.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
eng_list.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
eng_list.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
eng_list.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
eng_list.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
eng_list.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
eng_list.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
eng_list.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h eng_list.c
|
||||
eng_openssl.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
eng_openssl.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
eng_openssl.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
|
||||
eng_openssl.o: ../../include/openssl/dsa.h ../../include/openssl/dso.h
|
||||
eng_openssl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
eng_openssl.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
eng_openssl.o: ../../include/openssl/engine.h ../../include/openssl/err.h
|
||||
eng_openssl.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
|
||||
eng_openssl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
eng_openssl.o: ../../include/openssl/opensslconf.h
|
||||
eng_openssl.o: ../../include/openssl/opensslv.h
|
||||
eng_openssl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
|
||||
eng_openssl.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
|
||||
eng_openssl.o: ../../include/openssl/rand.h ../../include/openssl/rc4.h
|
||||
eng_openssl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
|
||||
eng_openssl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
eng_openssl.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
eng_openssl.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_openssl.c
|
||||
eng_pkey.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
eng_pkey.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
eng_pkey.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
eng_pkey.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
eng_pkey.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
eng_pkey.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
eng_pkey.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
eng_pkey.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
eng_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
eng_pkey.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
eng_pkey.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
eng_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
eng_pkey.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h eng_pkey.c
|
||||
eng_rdrand.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
eng_rdrand.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
eng_rdrand.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
eng_rdrand.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
eng_rdrand.o: ../../include/openssl/engine.h ../../include/openssl/err.h
|
||||
eng_rdrand.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
|
||||
eng_rdrand.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
eng_rdrand.o: ../../include/openssl/opensslconf.h
|
||||
eng_rdrand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
eng_rdrand.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
|
||||
eng_rdrand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
eng_rdrand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
eng_rdrand.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
eng_rdrand.o: eng_rdrand.c
|
||||
eng_table.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
eng_table.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
eng_table.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
eng_table.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
eng_table.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
eng_table.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
eng_table.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
eng_table.o: ../../include/openssl/objects.h
|
||||
eng_table.o: ../../include/openssl/opensslconf.h
|
||||
eng_table.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
eng_table.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
eng_table.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
eng_table.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
eng_table.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h
|
||||
eng_table.o: eng_table.c
|
||||
tb_asnmth.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
tb_asnmth.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
tb_asnmth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
tb_asnmth.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
tb_asnmth.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
tb_asnmth.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
tb_asnmth.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
tb_asnmth.o: ../../include/openssl/objects.h
|
||||
tb_asnmth.o: ../../include/openssl/opensslconf.h
|
||||
tb_asnmth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
tb_asnmth.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
tb_asnmth.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
tb_asnmth.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
tb_asnmth.o: ../../include/openssl/x509_vfy.h ../asn1/asn1_locl.h ../cryptlib.h
|
||||
tb_asnmth.o: eng_int.h tb_asnmth.c
|
||||
tb_cipher.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
tb_cipher.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
tb_cipher.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
tb_cipher.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
tb_cipher.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
tb_cipher.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
tb_cipher.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
tb_cipher.o: ../../include/openssl/objects.h
|
||||
tb_cipher.o: ../../include/openssl/opensslconf.h
|
||||
tb_cipher.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
tb_cipher.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
tb_cipher.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
tb_cipher.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
tb_cipher.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h
|
||||
tb_cipher.o: tb_cipher.c
|
||||
tb_dh.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
tb_dh.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
tb_dh.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
tb_dh.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
tb_dh.o: ../../include/openssl/engine.h ../../include/openssl/err.h
|
||||
tb_dh.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
|
||||
tb_dh.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
tb_dh.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
tb_dh.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
|
||||
tb_dh.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
tb_dh.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
tb_dh.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
tb_dh.o: ../cryptlib.h eng_int.h tb_dh.c
|
||||
tb_digest.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
tb_digest.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
tb_digest.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
tb_digest.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
tb_digest.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
tb_digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
tb_digest.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
tb_digest.o: ../../include/openssl/objects.h
|
||||
tb_digest.o: ../../include/openssl/opensslconf.h
|
||||
tb_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
tb_digest.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
tb_digest.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
tb_digest.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
tb_digest.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h
|
||||
tb_digest.o: tb_digest.c
|
||||
tb_dsa.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
tb_dsa.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
tb_dsa.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
tb_dsa.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
tb_dsa.o: ../../include/openssl/engine.h ../../include/openssl/err.h
|
||||
tb_dsa.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
|
||||
tb_dsa.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
tb_dsa.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
tb_dsa.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
|
||||
tb_dsa.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
tb_dsa.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
tb_dsa.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
tb_dsa.o: ../cryptlib.h eng_int.h tb_dsa.c
|
||||
tb_ecdh.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
tb_ecdh.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
tb_ecdh.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
tb_ecdh.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
tb_ecdh.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
tb_ecdh.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
tb_ecdh.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
tb_ecdh.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
tb_ecdh.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
tb_ecdh.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
tb_ecdh.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
tb_ecdh.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
tb_ecdh.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_ecdh.c
|
||||
tb_ecdsa.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
tb_ecdsa.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
tb_ecdsa.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
tb_ecdsa.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
tb_ecdsa.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
tb_ecdsa.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
tb_ecdsa.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
tb_ecdsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
tb_ecdsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
tb_ecdsa.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
tb_ecdsa.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
tb_ecdsa.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
tb_ecdsa.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_ecdsa.c
|
||||
tb_pkmeth.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
tb_pkmeth.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
tb_pkmeth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
tb_pkmeth.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
tb_pkmeth.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
tb_pkmeth.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
tb_pkmeth.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
tb_pkmeth.o: ../../include/openssl/objects.h
|
||||
tb_pkmeth.o: ../../include/openssl/opensslconf.h
|
||||
tb_pkmeth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
tb_pkmeth.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
tb_pkmeth.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
tb_pkmeth.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
tb_pkmeth.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h
|
||||
tb_pkmeth.o: tb_pkmeth.c
|
||||
tb_rand.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
tb_rand.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
tb_rand.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
tb_rand.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
tb_rand.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
tb_rand.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
tb_rand.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
tb_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
tb_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
tb_rand.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
tb_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
tb_rand.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
tb_rand.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_rand.c
|
||||
tb_rsa.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
tb_rsa.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
tb_rsa.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
|
||||
tb_rsa.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
|
||||
tb_rsa.o: ../../include/openssl/engine.h ../../include/openssl/err.h
|
||||
tb_rsa.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
|
||||
tb_rsa.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
|
||||
tb_rsa.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
|
||||
tb_rsa.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
|
||||
tb_rsa.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
tb_rsa.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
tb_rsa.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
tb_rsa.o: ../cryptlib.h eng_int.h tb_rsa.c
|
||||
tb_store.o: ../../e_os.h ../../include/openssl/asn1.h
|
||||
tb_store.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
|
||||
tb_store.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
tb_store.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
|
||||
tb_store.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
|
||||
tb_store.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
tb_store.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
|
||||
tb_store.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
|
||||
tb_store.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
tb_store.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
|
||||
tb_store.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
|
||||
tb_store.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
|
||||
tb_store.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h tb_store.c
|
||||
@@ -122,7 +122,7 @@ use by EVP_MD code. Ditto for tb_rsa.c, tb_dsa.c, etc. These instantiations of
|
||||
ENGINE_TABLE essentially provide linker-separation of the classes so that even
|
||||
if ENGINEs implement *all* possible algorithms, an application using only
|
||||
EVP_CIPHER code will link at most code relating to EVP_CIPHER, tb_cipher.c, core
|
||||
ENGINE code that is independant of class, and of course the ENGINE
|
||||
ENGINE code that is independent of class, and of course the ENGINE
|
||||
implementation that the application loaded. It will *not* however link any
|
||||
class-specific ENGINE code for digests, RSA, etc nor will it bleed over into
|
||||
other APIs, such as the RSA/DSA/etc library code.
|
||||
|
||||
8
crypto/engine/build.info
Normal file
8
crypto/engine/build.info
Normal file
@@ -0,0 +1,8 @@
|
||||
LIBS=../../libcrypto
|
||||
SOURCE[../../libcrypto]=\
|
||||
eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c \
|
||||
eng_table.c eng_pkey.c eng_fat.c eng_all.c \
|
||||
tb_rsa.c tb_dsa.c tb_dh.c tb_rand.c \
|
||||
tb_cipher.c tb_digest.c tb_pkmeth.c tb_asnmth.c tb_eckey.c \
|
||||
eng_openssl.c eng_cnf.c eng_dyn.c eng_cryptodev.c \
|
||||
eng_rdrand.c
|
||||
@@ -1,134 +1,29 @@
|
||||
/* crypto/engine/eng_all.c */
|
||||
/*
|
||||
* Written by Richard Levitte <richard@levitte.org> for the OpenSSL project
|
||||
* 2000.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2000-2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "cryptlib.h"
|
||||
#include "internal/cryptlib.h"
|
||||
#include "eng_int.h"
|
||||
|
||||
void ENGINE_load_builtin_engines(void)
|
||||
{
|
||||
/* Some ENGINEs need this */
|
||||
OPENSSL_cpuid_setup();
|
||||
#if 0
|
||||
/*
|
||||
* There's no longer any need for an "openssl" ENGINE unless, one day, it
|
||||
* is the *only* way for standard builtin implementations to be be
|
||||
* accessed (ie. it would be possible to statically link binaries with
|
||||
* *no* builtin implementations).
|
||||
*/
|
||||
ENGINE_load_openssl();
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_HW) && (defined(__OpenBSD__) || defined(__FreeBSD__) || defined(HAVE_CRYPTODEV))
|
||||
ENGINE_load_cryptodev();
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RDRAND
|
||||
ENGINE_load_rdrand();
|
||||
#endif
|
||||
ENGINE_load_dynamic();
|
||||
#ifndef OPENSSL_NO_STATIC_ENGINE
|
||||
# ifndef OPENSSL_NO_HW
|
||||
# ifndef OPENSSL_NO_HW_4758_CCA
|
||||
ENGINE_load_4758cca();
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_HW_AEP
|
||||
ENGINE_load_aep();
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_HW_ATALLA
|
||||
ENGINE_load_atalla();
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_HW_CSWIFT
|
||||
ENGINE_load_cswift();
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_HW_NCIPHER
|
||||
ENGINE_load_chil();
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_HW_NURON
|
||||
ENGINE_load_nuron();
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_HW_SUREWARE
|
||||
ENGINE_load_sureware();
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_HW_UBSEC
|
||||
ENGINE_load_ubsec();
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_HW_PADLOCK
|
||||
ENGINE_load_padlock();
|
||||
# endif
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_GOST
|
||||
ENGINE_load_gost();
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_GMP
|
||||
ENGINE_load_gmp();
|
||||
# endif
|
||||
# if defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_NO_CAPIENG)
|
||||
ENGINE_load_capi();
|
||||
# endif
|
||||
#endif
|
||||
ENGINE_register_all_complete();
|
||||
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL);
|
||||
}
|
||||
|
||||
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(HAVE_CRYPTODEV)
|
||||
#if (defined(__OpenBSD__) || defined(__FreeBSD__) || defined(HAVE_CRYPTODEV)) && !defined(OPENSSL_NO_DEPRECATED)
|
||||
void ENGINE_setup_bsd_cryptodev(void)
|
||||
{
|
||||
static int bsd_cryptodev_default_loaded = 0;
|
||||
if (!bsd_cryptodev_default_loaded) {
|
||||
ENGINE_load_cryptodev();
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CRYPTODEV, NULL);
|
||||
ENGINE_register_all_complete();
|
||||
}
|
||||
bsd_cryptodev_default_loaded = 1;
|
||||
|
||||
@@ -1,60 +1,10 @@
|
||||
/* eng_cnf.c */
|
||||
/*
|
||||
* Written by Stephen Henson (steve@openssl.org) for the OpenSSL project
|
||||
* 2001.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
@@ -64,11 +14,11 @@
|
||||
|
||||
/* ENGINE config module */
|
||||
|
||||
static char *skip_dot(char *name)
|
||||
static const char *skip_dot(const char *name)
|
||||
{
|
||||
char *p;
|
||||
p = strchr(name, '.');
|
||||
if (p)
|
||||
const char *p = strchr(name, '.');
|
||||
|
||||
if (p != NULL)
|
||||
return p + 1;
|
||||
return name;
|
||||
}
|
||||
@@ -88,14 +38,14 @@ static int int_engine_init(ENGINE *e)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int int_engine_configure(char *name, char *value, const CONF *cnf)
|
||||
static int int_engine_configure(const char *name, const char *value, const CONF *cnf)
|
||||
{
|
||||
int i;
|
||||
int ret = 0;
|
||||
long do_init = -1;
|
||||
STACK_OF(CONF_VALUE) *ecmds;
|
||||
CONF_VALUE *ecmd = NULL;
|
||||
char *ctrlname, *ctrlvalue;
|
||||
const char *ctrlname, *ctrlvalue;
|
||||
ENGINE *e = NULL;
|
||||
int soft = 0;
|
||||
|
||||
@@ -124,12 +74,12 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
|
||||
/* First handle some special pseudo ctrls */
|
||||
|
||||
/* Override engine name to use */
|
||||
if (!strcmp(ctrlname, "engine_id"))
|
||||
if (strcmp(ctrlname, "engine_id") == 0)
|
||||
name = ctrlvalue;
|
||||
else if (!strcmp(ctrlname, "soft_load"))
|
||||
else if (strcmp(ctrlname, "soft_load") == 0)
|
||||
soft = 1;
|
||||
/* Load a dynamic ENGINE */
|
||||
else if (!strcmp(ctrlname, "dynamic_path")) {
|
||||
else if (strcmp(ctrlname, "dynamic_path") == 0) {
|
||||
e = ENGINE_by_id("dynamic");
|
||||
if (!e)
|
||||
goto err;
|
||||
@@ -159,9 +109,9 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
|
||||
* Allow "EMPTY" to mean no value: this allows a valid "value" to
|
||||
* be passed to ctrls of type NO_INPUT
|
||||
*/
|
||||
if (!strcmp(ctrlvalue, "EMPTY"))
|
||||
if (strcmp(ctrlvalue, "EMPTY") == 0)
|
||||
ctrlvalue = NULL;
|
||||
if (!strcmp(ctrlname, "init")) {
|
||||
if (strcmp(ctrlname, "init") == 0) {
|
||||
if (!NCONF_get_number_e(cnf, value, "init", &do_init))
|
||||
goto err;
|
||||
if (do_init == 1) {
|
||||
@@ -172,7 +122,7 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
|
||||
ENGINE_R_INVALID_INIT_VALUE);
|
||||
goto err;
|
||||
}
|
||||
} else if (!strcmp(ctrlname, "default_algorithms")) {
|
||||
} else if (strcmp(ctrlname, "default_algorithms") == 0) {
|
||||
if (!ENGINE_set_default_string(e, ctrlvalue))
|
||||
goto err;
|
||||
} else if (!ENGINE_ctrl_cmd_string(e, ctrlname, ctrlvalue, 0))
|
||||
@@ -194,8 +144,7 @@ static int int_engine_configure(char *name, char *value, const CONF *cnf)
|
||||
", name=", ecmd->name,
|
||||
", value=", ecmd->value);
|
||||
}
|
||||
if (e)
|
||||
ENGINE_free(e);
|
||||
ENGINE_free(e);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -229,6 +178,7 @@ static int int_engine_module_init(CONF_IMODULE *md, const CONF *cnf)
|
||||
static void int_engine_module_finish(CONF_IMODULE *md)
|
||||
{
|
||||
ENGINE *e;
|
||||
|
||||
while ((e = sk_ENGINE_pop(initialized_engines)))
|
||||
ENGINE_finish(e);
|
||||
sk_ENGINE_free(initialized_engines);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,56 +1,10 @@
|
||||
/* crypto/engine/eng_ctrl.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
@@ -134,7 +88,7 @@ static int int_ctrl_helper(ENGINE *e, int cmd, long i, void *p,
|
||||
return e->cmd_defns[idx].cmd_num;
|
||||
}
|
||||
/*
|
||||
* For the rest of the commands, the 'long' argument must specify a valie
|
||||
* For the rest of the commands, the 'long' argument must specify a valid
|
||||
* command number - so we need to conduct a search.
|
||||
*/
|
||||
if ((e->cmd_defns == NULL) || ((idx = int_ctrl_cmd_by_num(e->cmd_defns,
|
||||
@@ -183,9 +137,9 @@ int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
|
||||
ENGINEerr(ENGINE_F_ENGINE_CTRL, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
ref_exists = ((e->struct_ref > 0) ? 1 : 0);
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
ctrl_exists = ((e->ctrl == NULL) ? 0 : 1);
|
||||
if (!ref_exists) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_CTRL, ENGINE_R_NO_REFERENCE);
|
||||
@@ -249,14 +203,13 @@ int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
|
||||
{
|
||||
int num;
|
||||
|
||||
if ((e == NULL) || (cmd_name == NULL)) {
|
||||
if (e == NULL || cmd_name == NULL) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
if ((e->ctrl == NULL) || ((num = ENGINE_ctrl(e,
|
||||
ENGINE_CTRL_GET_CMD_FROM_NAME,
|
||||
0, (void *)cmd_name,
|
||||
NULL)) <= 0)) {
|
||||
if (e->ctrl == NULL
|
||||
|| (num = ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FROM_NAME,
|
||||
0, (void *)cmd_name, NULL)) <= 0) {
|
||||
/*
|
||||
* If the command didn't *have* to be supported, we fake success.
|
||||
* This allows certain settings to be specified for multiple ENGINEs
|
||||
@@ -287,15 +240,14 @@ int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
|
||||
int num, flags;
|
||||
long l;
|
||||
char *ptr;
|
||||
if ((e == NULL) || (cmd_name == NULL)) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING,
|
||||
ERR_R_PASSED_NULL_PARAMETER);
|
||||
|
||||
if (e == NULL || cmd_name == NULL) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_CTRL_CMD_STRING, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
if ((e->ctrl == NULL) || ((num = ENGINE_ctrl(e,
|
||||
ENGINE_CTRL_GET_CMD_FROM_NAME,
|
||||
0, (void *)cmd_name,
|
||||
NULL)) <= 0)) {
|
||||
if (e->ctrl == NULL
|
||||
|| (num = ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FROM_NAME,
|
||||
0, (void *)cmd_name, NULL)) <= 0) {
|
||||
/*
|
||||
* If the command didn't *have* to be supported, we fake success.
|
||||
* This allows certain settings to be specified for multiple ENGINEs
|
||||
@@ -316,8 +268,9 @@ int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
|
||||
ENGINE_R_CMD_NOT_EXECUTABLE);
|
||||
return 0;
|
||||
}
|
||||
if ((flags =
|
||||
ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FLAGS, num, NULL, NULL)) < 0) {
|
||||
|
||||
flags = ENGINE_ctrl(e, ENGINE_CTRL_GET_CMD_FLAGS, num, NULL, NULL);
|
||||
if (flags < 0) {
|
||||
/*
|
||||
* Shouldn't happen, given that ENGINE_cmd_is_executable() returned
|
||||
* success.
|
||||
|
||||
@@ -1,64 +1,15 @@
|
||||
/* crypto/engine/eng_dyn.c */
|
||||
/*
|
||||
* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
|
||||
* 2001.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
#include <openssl/dso.h>
|
||||
#include "internal/dso.h"
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
/*
|
||||
* Shared libraries implementing ENGINEs for use by the "dynamic" ENGINE
|
||||
@@ -136,11 +87,11 @@ struct st_dynamic_data_ctx {
|
||||
*/
|
||||
dynamic_bind_engine bind_engine;
|
||||
/* The default name/path for loading the shared library */
|
||||
const char *DYNAMIC_LIBNAME;
|
||||
char *DYNAMIC_LIBNAME;
|
||||
/* Whether to continue loading on a version check failure */
|
||||
int no_vcheck;
|
||||
/* If non-NULL, stipulates the 'id' of the ENGINE to be loaded */
|
||||
const char *engine_id;
|
||||
char *engine_id;
|
||||
/*
|
||||
* If non-zero, a successfully loaded ENGINE should be added to the
|
||||
* internal ENGINE list. If 2, the add must succeed or the entire load
|
||||
@@ -186,14 +137,10 @@ static void dynamic_data_ctx_free_func(void *parent, void *ptr,
|
||||
{
|
||||
if (ptr) {
|
||||
dynamic_data_ctx *ctx = (dynamic_data_ctx *)ptr;
|
||||
if (ctx->dynamic_dso)
|
||||
DSO_free(ctx->dynamic_dso);
|
||||
if (ctx->DYNAMIC_LIBNAME)
|
||||
OPENSSL_free((void *)ctx->DYNAMIC_LIBNAME);
|
||||
if (ctx->engine_id)
|
||||
OPENSSL_free((void *)ctx->engine_id);
|
||||
if (ctx->dirs)
|
||||
sk_OPENSSL_STRING_pop_free(ctx->dirs, int_free_str);
|
||||
DSO_free(ctx->dynamic_dso);
|
||||
OPENSSL_free(ctx->DYNAMIC_LIBNAME);
|
||||
OPENSSL_free(ctx->engine_id);
|
||||
sk_OPENSSL_STRING_pop_free(ctx->dirs, int_free_str);
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
}
|
||||
@@ -206,48 +153,42 @@ static void dynamic_data_ctx_free_func(void *parent, void *ptr,
|
||||
*/
|
||||
static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx)
|
||||
{
|
||||
dynamic_data_ctx *c;
|
||||
c = OPENSSL_malloc(sizeof(dynamic_data_ctx));
|
||||
if (!c) {
|
||||
dynamic_data_ctx *c = OPENSSL_zalloc(sizeof(*c));
|
||||
int ret = 1;
|
||||
|
||||
if (c == NULL) {
|
||||
ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
memset(c, 0, sizeof(dynamic_data_ctx));
|
||||
c->dynamic_dso = NULL;
|
||||
c->v_check = NULL;
|
||||
c->bind_engine = NULL;
|
||||
c->DYNAMIC_LIBNAME = NULL;
|
||||
c->no_vcheck = 0;
|
||||
c->engine_id = NULL;
|
||||
c->list_add_value = 0;
|
||||
c->DYNAMIC_F1 = "v_check";
|
||||
c->DYNAMIC_F2 = "bind_engine";
|
||||
c->dir_load = 1;
|
||||
c->dirs = sk_OPENSSL_STRING_new_null();
|
||||
if (!c->dirs) {
|
||||
if (c->dirs == NULL) {
|
||||
ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX, ERR_R_MALLOC_FAILURE);
|
||||
OPENSSL_free(c);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
c->DYNAMIC_F1 = "v_check";
|
||||
c->DYNAMIC_F2 = "bind_engine";
|
||||
c->dir_load = 1;
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
if ((*ctx = (dynamic_data_ctx *)ENGINE_get_ex_data(e,
|
||||
dynamic_ex_data_idx))
|
||||
== NULL) {
|
||||
/* Good, we're the first */
|
||||
ENGINE_set_ex_data(e, dynamic_ex_data_idx, c);
|
||||
*ctx = c;
|
||||
c = NULL;
|
||||
ret = ENGINE_set_ex_data(e, dynamic_ex_data_idx, c);
|
||||
if (ret) {
|
||||
*ctx = c;
|
||||
c = NULL;
|
||||
}
|
||||
}
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
/*
|
||||
* If we lost the race to set the context, c is non-NULL and *ctx is the
|
||||
* context of the thread that won.
|
||||
*/
|
||||
if (c) {
|
||||
if (c)
|
||||
sk_OPENSSL_STRING_free(c->dirs);
|
||||
OPENSSL_free(c);
|
||||
}
|
||||
return 1;
|
||||
OPENSSL_free(c);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -269,14 +210,14 @@ static dynamic_data_ctx *dynamic_get_data_ctx(ENGINE *e)
|
||||
ENGINEerr(ENGINE_F_DYNAMIC_GET_DATA_CTX, ENGINE_R_NO_INDEX);
|
||||
return NULL;
|
||||
}
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
/* Avoid a race by checking again inside this lock */
|
||||
if (dynamic_ex_data_idx < 0) {
|
||||
/* Good, someone didn't beat us to it */
|
||||
dynamic_ex_data_idx = new_idx;
|
||||
new_idx = -1;
|
||||
}
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
/*
|
||||
* In theory we could "give back" the index here if (new_idx>-1), but
|
||||
* it's not possible and wouldn't gain us much if it were.
|
||||
@@ -293,7 +234,7 @@ static dynamic_data_ctx *dynamic_get_data_ctx(ENGINE *e)
|
||||
static ENGINE *engine_dynamic(void)
|
||||
{
|
||||
ENGINE *ret = ENGINE_new();
|
||||
if (!ret)
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
if (!ENGINE_set_id(ret, engine_dynamic_id) ||
|
||||
!ENGINE_set_name(ret, engine_dynamic_name) ||
|
||||
@@ -308,7 +249,7 @@ static ENGINE *engine_dynamic(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ENGINE_load_dynamic(void)
|
||||
void engine_load_dynamic_int(void)
|
||||
{
|
||||
ENGINE *toadd = engine_dynamic();
|
||||
if (!toadd)
|
||||
@@ -330,7 +271,7 @@ void ENGINE_load_dynamic(void)
|
||||
static int dynamic_init(ENGINE *e)
|
||||
{
|
||||
/*
|
||||
* We always return failure - the "dyanamic" engine itself can't be used
|
||||
* We always return failure - the "dynamic" engine itself can't be used
|
||||
* for anything.
|
||||
*/
|
||||
return 0;
|
||||
@@ -365,10 +306,9 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
|
||||
/* a NULL 'p' or a string of zero-length is the same thing */
|
||||
if (p && (strlen((const char *)p) < 1))
|
||||
p = NULL;
|
||||
if (ctx->DYNAMIC_LIBNAME)
|
||||
OPENSSL_free((void *)ctx->DYNAMIC_LIBNAME);
|
||||
OPENSSL_free(ctx->DYNAMIC_LIBNAME);
|
||||
if (p)
|
||||
ctx->DYNAMIC_LIBNAME = BUF_strdup(p);
|
||||
ctx->DYNAMIC_LIBNAME = OPENSSL_strdup(p);
|
||||
else
|
||||
ctx->DYNAMIC_LIBNAME = NULL;
|
||||
return (ctx->DYNAMIC_LIBNAME ? 1 : 0);
|
||||
@@ -379,10 +319,9 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
|
||||
/* a NULL 'p' or a string of zero-length is the same thing */
|
||||
if (p && (strlen((const char *)p) < 1))
|
||||
p = NULL;
|
||||
if (ctx->engine_id)
|
||||
OPENSSL_free((void *)ctx->engine_id);
|
||||
OPENSSL_free(ctx->engine_id);
|
||||
if (p)
|
||||
ctx->engine_id = BUF_strdup(p);
|
||||
ctx->engine_id = OPENSSL_strdup(p);
|
||||
else
|
||||
ctx->engine_id = NULL;
|
||||
return (ctx->engine_id ? 1 : 0);
|
||||
@@ -409,12 +348,16 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
char *tmp_str = BUF_strdup(p);
|
||||
if (!tmp_str) {
|
||||
char *tmp_str = OPENSSL_strdup(p);
|
||||
if (tmp_str == NULL) {
|
||||
ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
if (!sk_OPENSSL_STRING_push(ctx->dirs, tmp_str)) {
|
||||
OPENSSL_free(tmp_str);
|
||||
ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
sk_OPENSSL_STRING_insert(ctx->dirs, tmp_str, -1);
|
||||
}
|
||||
return 1;
|
||||
default:
|
||||
@@ -455,11 +398,15 @@ static int dynamic_load(ENGINE *e, dynamic_data_ctx *ctx)
|
||||
ENGINE cpy;
|
||||
dynamic_fns fns;
|
||||
|
||||
if (!ctx->dynamic_dso)
|
||||
if (ctx->dynamic_dso == NULL)
|
||||
ctx->dynamic_dso = DSO_new();
|
||||
if (ctx->dynamic_dso == NULL)
|
||||
return 0;
|
||||
if (!ctx->DYNAMIC_LIBNAME) {
|
||||
if (!ctx->engine_id)
|
||||
return 0;
|
||||
DSO_ctrl(ctx->dynamic_dso, DSO_CTRL_SET_FLAGS,
|
||||
DSO_FLAG_NAME_TRANSLATION_EXT_ONLY, NULL);
|
||||
ctx->DYNAMIC_LIBNAME =
|
||||
DSO_convert_filename(ctx->dynamic_dso, ctx->engine_id);
|
||||
}
|
||||
@@ -521,15 +468,8 @@ static int dynamic_load(ENGINE *e, dynamic_data_ctx *ctx)
|
||||
* would also increase opaqueness.
|
||||
*/
|
||||
fns.static_state = ENGINE_get_static_state();
|
||||
fns.err_fns = ERR_get_implementation();
|
||||
fns.ex_data_fns = CRYPTO_get_ex_data_implementation();
|
||||
CRYPTO_get_mem_functions(&fns.mem_fns.malloc_cb,
|
||||
&fns.mem_fns.realloc_cb, &fns.mem_fns.free_cb);
|
||||
fns.lock_fns.lock_locking_cb = CRYPTO_get_locking_callback();
|
||||
fns.lock_fns.lock_add_lock_cb = CRYPTO_get_add_lock_callback();
|
||||
fns.lock_fns.dynlock_create_cb = CRYPTO_get_dynlock_create_callback();
|
||||
fns.lock_fns.dynlock_lock_cb = CRYPTO_get_dynlock_lock_callback();
|
||||
fns.lock_fns.dynlock_destroy_cb = CRYPTO_get_dynlock_destroy_callback();
|
||||
CRYPTO_get_mem_functions(&fns.mem_fns.malloc_fn, &fns.mem_fns.realloc_fn,
|
||||
&fns.mem_fns.free_fn);
|
||||
/*
|
||||
* Now that we've loaded the dynamic engine, make sure no "dynamic"
|
||||
* ENGINE elements will show through.
|
||||
|
||||
@@ -1,62 +1,11 @@
|
||||
/* crypto/engine/eng_err.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2010 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE: this file was auto generated by the mkerr.pl script: any changes
|
||||
* made to it will be overwritten when the script next updates this file,
|
||||
* only reason strings will be preserved.
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -70,10 +19,10 @@
|
||||
# define ERR_REASON(reason) ERR_PACK(ERR_LIB_ENGINE,0,reason)
|
||||
|
||||
static ERR_STRING_DATA ENGINE_str_functs[] = {
|
||||
{ERR_FUNC(ENGINE_F_DYNAMIC_CTRL), "DYNAMIC_CTRL"},
|
||||
{ERR_FUNC(ENGINE_F_DYNAMIC_GET_DATA_CTX), "DYNAMIC_GET_DATA_CTX"},
|
||||
{ERR_FUNC(ENGINE_F_DYNAMIC_LOAD), "DYNAMIC_LOAD"},
|
||||
{ERR_FUNC(ENGINE_F_DYNAMIC_SET_DATA_CTX), "DYNAMIC_SET_DATA_CTX"},
|
||||
{ERR_FUNC(ENGINE_F_DYNAMIC_CTRL), "dynamic_ctrl"},
|
||||
{ERR_FUNC(ENGINE_F_DYNAMIC_GET_DATA_CTX), "dynamic_get_data_ctx"},
|
||||
{ERR_FUNC(ENGINE_F_DYNAMIC_LOAD), "dynamic_load"},
|
||||
{ERR_FUNC(ENGINE_F_DYNAMIC_SET_DATA_CTX), "dynamic_set_data_ctx"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_ADD), "ENGINE_add"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_BY_ID), "ENGINE_by_id"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_CMD_IS_EXECUTABLE), "ENGINE_cmd_is_executable"},
|
||||
@@ -81,37 +30,36 @@ static ERR_STRING_DATA ENGINE_str_functs[] = {
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_CTRL_CMD), "ENGINE_ctrl_cmd"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_CTRL_CMD_STRING), "ENGINE_ctrl_cmd_string"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_FINISH), "ENGINE_finish"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_FREE_UTIL), "ENGINE_FREE_UTIL"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_GET_CIPHER), "ENGINE_get_cipher"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_GET_DEFAULT_TYPE), "ENGINE_GET_DEFAULT_TYPE"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_GET_DIGEST), "ENGINE_get_digest"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_GET_FIRST), "ENGINE_get_first"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_GET_LAST), "ENGINE_get_last"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_GET_NEXT), "ENGINE_get_next"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_GET_PKEY_ASN1_METH),
|
||||
"ENGINE_get_pkey_asn1_meth"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_GET_PKEY_METH), "ENGINE_get_pkey_meth"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_GET_PREV), "ENGINE_get_prev"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_INIT), "ENGINE_init"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_LIST_ADD), "ENGINE_LIST_ADD"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_LIST_REMOVE), "ENGINE_LIST_REMOVE"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_LIST_ADD), "engine_list_add"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_LIST_REMOVE), "engine_list_remove"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY), "ENGINE_load_private_key"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY), "ENGINE_load_public_key"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT),
|
||||
"ENGINE_load_ssl_client_cert"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_NEW), "ENGINE_new"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_PKEY_ASN1_FIND_STR),
|
||||
"ENGINE_pkey_asn1_find_str"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_REMOVE), "ENGINE_remove"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_SET_DEFAULT_STRING),
|
||||
"ENGINE_set_default_string"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_SET_DEFAULT_TYPE), "ENGINE_SET_DEFAULT_TYPE"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_SET_ID), "ENGINE_set_id"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_SET_NAME), "ENGINE_set_name"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_TABLE_REGISTER), "ENGINE_TABLE_REGISTER"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_UNLOAD_KEY), "ENGINE_UNLOAD_KEY"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_UNLOCKED_FINISH), "ENGINE_UNLOCKED_FINISH"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_TABLE_REGISTER), "engine_table_register"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_UNLOCKED_FINISH), "engine_unlocked_finish"},
|
||||
{ERR_FUNC(ENGINE_F_ENGINE_UP_REF), "ENGINE_up_ref"},
|
||||
{ERR_FUNC(ENGINE_F_INT_CTRL_HELPER), "INT_CTRL_HELPER"},
|
||||
{ERR_FUNC(ENGINE_F_INT_ENGINE_CONFIGURE), "INT_ENGINE_CONFIGURE"},
|
||||
{ERR_FUNC(ENGINE_F_INT_ENGINE_MODULE_INIT), "INT_ENGINE_MODULE_INIT"},
|
||||
{ERR_FUNC(ENGINE_F_LOG_MESSAGE), "LOG_MESSAGE"},
|
||||
{ERR_FUNC(ENGINE_F_INT_CTRL_HELPER), "int_ctrl_helper"},
|
||||
{ERR_FUNC(ENGINE_F_INT_ENGINE_CONFIGURE), "int_engine_configure"},
|
||||
{ERR_FUNC(ENGINE_F_INT_ENGINE_MODULE_INIT), "int_engine_module_init"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
@@ -125,8 +73,6 @@ static ERR_STRING_DATA ENGINE_str_reasons[] = {
|
||||
{ERR_REASON(ENGINE_R_CONFLICTING_ENGINE_ID), "conflicting engine id"},
|
||||
{ERR_REASON(ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED),
|
||||
"ctrl command not implemented"},
|
||||
{ERR_REASON(ENGINE_R_DH_NOT_IMPLEMENTED), "dh not implemented"},
|
||||
{ERR_REASON(ENGINE_R_DSA_NOT_IMPLEMENTED), "dsa not implemented"},
|
||||
{ERR_REASON(ENGINE_R_DSO_FAILURE), "DSO failure"},
|
||||
{ERR_REASON(ENGINE_R_DSO_NOT_FOUND), "dso not found"},
|
||||
{ERR_REASON(ENGINE_R_ENGINES_SECTION_ERROR), "engines section error"},
|
||||
@@ -139,8 +85,6 @@ static ERR_STRING_DATA ENGINE_str_reasons[] = {
|
||||
{ERR_REASON(ENGINE_R_FAILED_LOADING_PUBLIC_KEY),
|
||||
"failed loading public key"},
|
||||
{ERR_REASON(ENGINE_R_FINISH_FAILED), "finish failed"},
|
||||
{ERR_REASON(ENGINE_R_GET_HANDLE_FAILED),
|
||||
"could not obtain hardware handle"},
|
||||
{ERR_REASON(ENGINE_R_ID_OR_NAME_MISSING), "'id' or 'name' missing"},
|
||||
{ERR_REASON(ENGINE_R_INIT_FAILED), "init failed"},
|
||||
{ERR_REASON(ENGINE_R_INTERNAL_LIST_ERROR), "internal list error"},
|
||||
@@ -156,9 +100,6 @@ static ERR_STRING_DATA ENGINE_str_reasons[] = {
|
||||
{ERR_REASON(ENGINE_R_NO_LOAD_FUNCTION), "no load function"},
|
||||
{ERR_REASON(ENGINE_R_NO_REFERENCE), "no reference"},
|
||||
{ERR_REASON(ENGINE_R_NO_SUCH_ENGINE), "no such engine"},
|
||||
{ERR_REASON(ENGINE_R_NO_UNLOAD_FUNCTION), "no unload function"},
|
||||
{ERR_REASON(ENGINE_R_PROVIDE_PARAMETERS), "provide parameters"},
|
||||
{ERR_REASON(ENGINE_R_RSA_NOT_IMPLEMENTED), "rsa not implemented"},
|
||||
{ERR_REASON(ENGINE_R_UNIMPLEMENTED_CIPHER), "unimplemented cipher"},
|
||||
{ERR_REASON(ENGINE_R_UNIMPLEMENTED_DIGEST), "unimplemented digest"},
|
||||
{ERR_REASON(ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD),
|
||||
@@ -169,7 +110,7 @@ static ERR_STRING_DATA ENGINE_str_reasons[] = {
|
||||
|
||||
#endif
|
||||
|
||||
void ERR_load_ENGINE_strings(void)
|
||||
int ERR_load_ENGINE_strings(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
@@ -178,4 +119,5 @@ void ERR_load_ENGINE_strings(void)
|
||||
ERR_load_strings(0, ENGINE_str_reasons);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,57 +1,12 @@
|
||||
/* crypto/engine/eng_fat.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
* ECDH support in OpenSSL originally developed by
|
||||
@@ -79,12 +34,8 @@ int ENGINE_set_default(ENGINE *e, unsigned int flags)
|
||||
if ((flags & ENGINE_METHOD_DH) && !ENGINE_set_default_DH(e))
|
||||
return 0;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ECDH
|
||||
if ((flags & ENGINE_METHOD_ECDH) && !ENGINE_set_default_ECDH(e))
|
||||
return 0;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ECDSA
|
||||
if ((flags & ENGINE_METHOD_ECDSA) && !ENGINE_set_default_ECDSA(e))
|
||||
#ifndef OPENSSL_NO_EC
|
||||
if ((flags & ENGINE_METHOD_EC) && !ENGINE_set_default_EC(e))
|
||||
return 0;
|
||||
#endif
|
||||
if ((flags & ENGINE_METHOD_RAND) && !ENGINE_set_default_RAND(e))
|
||||
@@ -105,29 +56,27 @@ static int int_def_cb(const char *alg, int len, void *arg)
|
||||
unsigned int *pflags = arg;
|
||||
if (alg == NULL)
|
||||
return 0;
|
||||
if (!strncmp(alg, "ALL", len))
|
||||
if (strncmp(alg, "ALL", len) == 0)
|
||||
*pflags |= ENGINE_METHOD_ALL;
|
||||
else if (!strncmp(alg, "RSA", len))
|
||||
else if (strncmp(alg, "RSA", len) == 0)
|
||||
*pflags |= ENGINE_METHOD_RSA;
|
||||
else if (!strncmp(alg, "DSA", len))
|
||||
else if (strncmp(alg, "DSA", len) == 0)
|
||||
*pflags |= ENGINE_METHOD_DSA;
|
||||
else if (!strncmp(alg, "ECDH", len))
|
||||
*pflags |= ENGINE_METHOD_ECDH;
|
||||
else if (!strncmp(alg, "ECDSA", len))
|
||||
*pflags |= ENGINE_METHOD_ECDSA;
|
||||
else if (!strncmp(alg, "DH", len))
|
||||
else if (strncmp(alg, "DH", len) == 0)
|
||||
*pflags |= ENGINE_METHOD_DH;
|
||||
else if (!strncmp(alg, "RAND", len))
|
||||
else if (strncmp(alg, "EC", len) == 0)
|
||||
*pflags |= ENGINE_METHOD_EC;
|
||||
else if (strncmp(alg, "RAND", len) == 0)
|
||||
*pflags |= ENGINE_METHOD_RAND;
|
||||
else if (!strncmp(alg, "CIPHERS", len))
|
||||
else if (strncmp(alg, "CIPHERS", len) == 0)
|
||||
*pflags |= ENGINE_METHOD_CIPHERS;
|
||||
else if (!strncmp(alg, "DIGESTS", len))
|
||||
else if (strncmp(alg, "DIGESTS", len) == 0)
|
||||
*pflags |= ENGINE_METHOD_DIGESTS;
|
||||
else if (!strncmp(alg, "PKEY", len))
|
||||
else if (strncmp(alg, "PKEY", len) == 0)
|
||||
*pflags |= ENGINE_METHOD_PKEY_METHS | ENGINE_METHOD_PKEY_ASN1_METHS;
|
||||
else if (!strncmp(alg, "PKEY_CRYPTO", len))
|
||||
else if (strncmp(alg, "PKEY_CRYPTO", len) == 0)
|
||||
*pflags |= ENGINE_METHOD_PKEY_METHS;
|
||||
else if (!strncmp(alg, "PKEY_ASN1", len))
|
||||
else if (strncmp(alg, "PKEY_ASN1", len) == 0)
|
||||
*pflags |= ENGINE_METHOD_PKEY_ASN1_METHS;
|
||||
else
|
||||
return 0;
|
||||
@@ -159,11 +108,8 @@ int ENGINE_register_complete(ENGINE *e)
|
||||
#ifndef OPENSSL_NO_DH
|
||||
ENGINE_register_DH(e);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ECDH
|
||||
ENGINE_register_ECDH(e);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ECDSA
|
||||
ENGINE_register_ECDSA(e);
|
||||
#ifndef OPENSSL_NO_EC
|
||||
ENGINE_register_EC(e);
|
||||
#endif
|
||||
ENGINE_register_RAND(e);
|
||||
ENGINE_register_pkey_meths(e);
|
||||
|
||||
@@ -1,56 +1,10 @@
|
||||
/* crypto/engine/eng_init.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
@@ -76,8 +30,8 @@ int engine_unlocked_init(ENGINE *e)
|
||||
*/
|
||||
e->struct_ref++;
|
||||
e->funct_ref++;
|
||||
engine_ref_debug(e, 0, 1)
|
||||
engine_ref_debug(e, 1, 1)
|
||||
engine_ref_debug(e, 0, 1);
|
||||
engine_ref_debug(e, 1, 1);
|
||||
}
|
||||
return to_return;
|
||||
}
|
||||
@@ -102,19 +56,14 @@ int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers)
|
||||
engine_ref_debug(e, 1, -1);
|
||||
if ((e->funct_ref == 0) && e->finish) {
|
||||
if (unlock_for_handlers)
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
to_return = e->finish(e);
|
||||
if (unlock_for_handlers)
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
if (!to_return)
|
||||
return 0;
|
||||
}
|
||||
#ifdef REF_CHECK
|
||||
if (e->funct_ref < 0) {
|
||||
fprintf(stderr, "ENGINE_finish, bad functional reference count\n");
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
REF_ASSERT_ISNT(e->funct_ref < 0);
|
||||
/* Release the structural reference too */
|
||||
if (!engine_free_util(e, 0)) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_UNLOCKED_FINISH, ENGINE_R_FINISH_FAILED);
|
||||
@@ -131,9 +80,13 @@ int ENGINE_init(ENGINE *e)
|
||||
ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
ret = engine_unlocked_init(e);
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -142,13 +95,11 @@ int ENGINE_finish(ENGINE *e)
|
||||
{
|
||||
int to_return = 1;
|
||||
|
||||
if (e == NULL) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_FINISH, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
if (e == NULL)
|
||||
return 1;
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
to_return = engine_unlocked_finish(e, 1);
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
if (!to_return) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_FINISH, ENGINE_R_FINISH_FAILED);
|
||||
return 0;
|
||||
|
||||
@@ -1,61 +1,12 @@
|
||||
/* crypto/engine/eng_int.h */
|
||||
/*
|
||||
* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
|
||||
* 2000.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
* ECDH support in OpenSSL originally developed by
|
||||
@@ -65,14 +16,16 @@
|
||||
#ifndef HEADER_ENGINE_INT_H
|
||||
# define HEADER_ENGINE_INT_H
|
||||
|
||||
# include "cryptlib.h"
|
||||
/* Take public definitions from engine.h */
|
||||
# include <openssl/engine.h>
|
||||
# include "internal/cryptlib.h"
|
||||
# include <internal/engine.h>
|
||||
# include <internal/thread_once.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern CRYPTO_RWLOCK *global_engine_lock;
|
||||
|
||||
/*
|
||||
* If we compile with this symbol defined, then both reference counts in the
|
||||
* ENGINE structure will be monitored with a line of output on stderr for
|
||||
@@ -88,7 +41,7 @@ extern "C" {
|
||||
(unsigned int)(e), (isfunct ? "funct" : "struct"), \
|
||||
((isfunct) ? ((e)->funct_ref - (diff)) : ((e)->struct_ref - (diff))), \
|
||||
((isfunct) ? (e)->funct_ref : (e)->struct_ref), \
|
||||
(__FILE__), (__LINE__));
|
||||
(OPENSSL_FILE), (OPENSSL_LINE))
|
||||
|
||||
# else
|
||||
|
||||
@@ -98,20 +51,20 @@ extern "C" {
|
||||
|
||||
/*
|
||||
* Any code that will need cleanup operations should use these functions to
|
||||
* register callbacks. ENGINE_cleanup() will call all registered callbacks in
|
||||
* order. NB: both the "add" functions assume CRYPTO_LOCK_ENGINE to already be
|
||||
* held (in "write" mode).
|
||||
* register callbacks. engine_cleanup_int() will call all registered
|
||||
* callbacks in order. NB: both the "add" functions assume the engine lock to
|
||||
* already be held (in "write" mode).
|
||||
*/
|
||||
typedef void (ENGINE_CLEANUP_CB) (void);
|
||||
typedef struct st_engine_cleanup_item {
|
||||
ENGINE_CLEANUP_CB *cb;
|
||||
} ENGINE_CLEANUP_ITEM;
|
||||
DECLARE_STACK_OF(ENGINE_CLEANUP_ITEM)
|
||||
DEFINE_STACK_OF(ENGINE_CLEANUP_ITEM)
|
||||
void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb);
|
||||
void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb);
|
||||
|
||||
/* We need stacks of ENGINEs for use in eng_table.c */
|
||||
DECLARE_STACK_OF(ENGINE)
|
||||
DEFINE_STACK_OF(ENGINE)
|
||||
|
||||
/*
|
||||
* If this symbol is defined then engine_table_select(), the function that is
|
||||
@@ -136,7 +89,7 @@ ENGINE *engine_table_select(ENGINE_TABLE **table, int nid);
|
||||
# else
|
||||
ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
|
||||
int l);
|
||||
# define engine_table_select(t,n) engine_table_select_tmp(t,n,__FILE__,__LINE__)
|
||||
# define engine_table_select(t,n) engine_table_select_tmp(t,n,OPENSSL_FILE,OPENSSL_LINE)
|
||||
# endif
|
||||
typedef void (engine_table_doall_cb) (int nid, STACK_OF(ENGINE) *sk,
|
||||
ENGINE *def, void *arg);
|
||||
@@ -146,7 +99,7 @@ void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb,
|
||||
/*
|
||||
* Internal versions of API functions that have control over locking. These
|
||||
* are used between C files when functionality needs to be shared but the
|
||||
* caller may already be controlling of the CRYPTO_LOCK_ENGINE lock.
|
||||
* caller may already be controlling of the engine lock.
|
||||
*/
|
||||
int engine_unlocked_init(ENGINE *e);
|
||||
int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers);
|
||||
@@ -169,6 +122,10 @@ void engine_set_all_null(ENGINE *e);
|
||||
void engine_pkey_meths_free(ENGINE *e);
|
||||
void engine_pkey_asn1_meths_free(ENGINE *e);
|
||||
|
||||
/* Once initialisation function */
|
||||
extern CRYPTO_ONCE engine_lock_init;
|
||||
DECLARE_RUN_ONCE(do_engine_lock_init)
|
||||
|
||||
/*
|
||||
* This is a structure for storing implementations of various crypto
|
||||
* algorithms and functions.
|
||||
@@ -179,10 +136,8 @@ struct engine_st {
|
||||
const RSA_METHOD *rsa_meth;
|
||||
const DSA_METHOD *dsa_meth;
|
||||
const DH_METHOD *dh_meth;
|
||||
const ECDH_METHOD *ecdh_meth;
|
||||
const ECDSA_METHOD *ecdsa_meth;
|
||||
const EC_KEY_METHOD *ec_meth;
|
||||
const RAND_METHOD *rand_meth;
|
||||
const STORE_METHOD *store_meth;
|
||||
/* Cipher handling is via this callback */
|
||||
ENGINE_CIPHERS_PTR ciphers;
|
||||
/* Digest handling is via this callback */
|
||||
@@ -204,7 +159,7 @@ struct engine_st {
|
||||
int struct_ref;
|
||||
/*
|
||||
* reference count on usability of the engine type. NB: This controls the
|
||||
* loading and initialisation of any functionlity required by this
|
||||
* loading and initialisation of any functionality required by this
|
||||
* engine, whereas the previous count is simply to cope with
|
||||
* (de)allocation of this structure. Hence, running_ref <= struct_ref at
|
||||
* all times.
|
||||
@@ -217,6 +172,10 @@ struct engine_st {
|
||||
struct engine_st *next;
|
||||
};
|
||||
|
||||
typedef struct st_engine_pile ENGINE_PILE;
|
||||
|
||||
DEFINE_LHASH_OF(ENGINE_PILE);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,80 +1,43 @@
|
||||
/* crypto/engine/eng_lib.c */
|
||||
/*
|
||||
* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
|
||||
* 2000.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
#include <openssl/rand.h>
|
||||
|
||||
CRYPTO_RWLOCK *global_engine_lock;
|
||||
|
||||
CRYPTO_ONCE engine_lock_init = CRYPTO_ONCE_STATIC_INIT;
|
||||
|
||||
/* The "new"/"free" stuff first */
|
||||
|
||||
DEFINE_RUN_ONCE(do_engine_lock_init)
|
||||
{
|
||||
OPENSSL_init_crypto(0, NULL);
|
||||
global_engine_lock = CRYPTO_THREAD_lock_new();
|
||||
return global_engine_lock != NULL;
|
||||
}
|
||||
|
||||
ENGINE *ENGINE_new(void)
|
||||
{
|
||||
ENGINE *ret;
|
||||
|
||||
ret = (ENGINE *)OPENSSL_malloc(sizeof(ENGINE));
|
||||
if (ret == NULL) {
|
||||
if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)
|
||||
|| (ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_NEW, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
memset(ret, 0, sizeof(ENGINE));
|
||||
ret->struct_ref = 1;
|
||||
engine_ref_debug(ret, 0, 1)
|
||||
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ENGINE, ret, &ret->ex_data);
|
||||
engine_ref_debug(ret, 0, 1);
|
||||
if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ENGINE, ret, &ret->ex_data)) {
|
||||
OPENSSL_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -91,7 +54,6 @@ void engine_set_all_null(ENGINE *e)
|
||||
e->dsa_meth = NULL;
|
||||
e->dh_meth = NULL;
|
||||
e->rand_meth = NULL;
|
||||
e->store_meth = NULL;
|
||||
e->ciphers = NULL;
|
||||
e->digests = NULL;
|
||||
e->destroy = NULL;
|
||||
@@ -108,23 +70,16 @@ int engine_free_util(ENGINE *e, int locked)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (e == NULL) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_FREE_UTIL, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
if (e == NULL)
|
||||
return 1;
|
||||
if (locked)
|
||||
i = CRYPTO_add(&e->struct_ref, -1, CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_atomic_add(&e->struct_ref, -1, &i, global_engine_lock);
|
||||
else
|
||||
i = --e->struct_ref;
|
||||
engine_ref_debug(e, 0, -1)
|
||||
if (i > 0)
|
||||
if (i > 0)
|
||||
return 1;
|
||||
#ifdef REF_CHECK
|
||||
if (i < 0) {
|
||||
fprintf(stderr, "ENGINE_free, bad structural reference count\n");
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
REF_ASSERT_ISNT(i < 0);
|
||||
/* Free up any dynamically allocated public key methods */
|
||||
engine_pkey_meths_free(e);
|
||||
engine_pkey_asn1_meths_free(e);
|
||||
@@ -147,8 +102,8 @@ int ENGINE_free(ENGINE *e)
|
||||
/* Cleanup stuff */
|
||||
|
||||
/*
|
||||
* ENGINE_cleanup() is coded such that anything that does work that will need
|
||||
* cleanup can register a "cleanup" callback here. That way we don't get
|
||||
* engine_cleanup_int() is coded such that anything that does work that will
|
||||
* need cleanup can register a "cleanup" callback here. That way we don't get
|
||||
* linker bloat by referring to all *possible* cleanups, but any linker bloat
|
||||
* into code "X" will cause X's cleanup function to end up here.
|
||||
*/
|
||||
@@ -165,8 +120,8 @@ static int int_cleanup_check(int create)
|
||||
|
||||
static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb)
|
||||
{
|
||||
ENGINE_CLEANUP_ITEM *item = OPENSSL_malloc(sizeof(ENGINE_CLEANUP_ITEM));
|
||||
if (!item)
|
||||
ENGINE_CLEANUP_ITEM *item = OPENSSL_malloc(sizeof(*item));
|
||||
if (item == NULL)
|
||||
return NULL;
|
||||
item->cb = cb;
|
||||
return item;
|
||||
@@ -199,30 +154,18 @@ static void engine_cleanup_cb_free(ENGINE_CLEANUP_ITEM *item)
|
||||
OPENSSL_free(item);
|
||||
}
|
||||
|
||||
void ENGINE_cleanup(void)
|
||||
void engine_cleanup_int(void)
|
||||
{
|
||||
if (int_cleanup_check(0)) {
|
||||
sk_ENGINE_CLEANUP_ITEM_pop_free(cleanup_stack,
|
||||
engine_cleanup_cb_free);
|
||||
cleanup_stack = NULL;
|
||||
}
|
||||
/*
|
||||
* FIXME: This should be handled (somehow) through RAND, eg. by it
|
||||
* registering a cleanup callback.
|
||||
*/
|
||||
RAND_set_rand_method(NULL);
|
||||
CRYPTO_THREAD_lock_free(global_engine_lock);
|
||||
}
|
||||
|
||||
/* Now the "ex_data" support */
|
||||
|
||||
int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
|
||||
CRYPTO_EX_dup *dup_func,
|
||||
CRYPTO_EX_free *free_func)
|
||||
{
|
||||
return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, argl, argp,
|
||||
new_func, dup_func, free_func);
|
||||
}
|
||||
|
||||
int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg)
|
||||
{
|
||||
return (CRYPTO_set_ex_data(&e->ex_data, idx, arg));
|
||||
|
||||
@@ -1,61 +1,12 @@
|
||||
/* crypto/engine/eng_list.c */
|
||||
/*
|
||||
* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
|
||||
* 2000.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
* ECDH support in OpenSSL originally developed by
|
||||
@@ -80,7 +31,7 @@ static ENGINE *engine_list_tail = NULL;
|
||||
|
||||
/*
|
||||
* This cleanup function is only needed internally. If it should be called,
|
||||
* we register it with the "ENGINE_cleanup()" stack to be called during
|
||||
* we register it with the "engine_cleanup_int()" stack to be called during
|
||||
* cleanup.
|
||||
*/
|
||||
|
||||
@@ -97,7 +48,7 @@ static void engine_list_cleanup(void)
|
||||
|
||||
/*
|
||||
* These static functions starting with a lower case "engine_" always take
|
||||
* place when CRYPTO_LOCK_ENGINE has been locked up.
|
||||
* place when global_engine_lock has been locked up.
|
||||
*/
|
||||
static int engine_list_add(ENGINE *e)
|
||||
{
|
||||
@@ -142,9 +93,9 @@ static int engine_list_add(ENGINE *e)
|
||||
* Having the engine in the list assumes a structural reference.
|
||||
*/
|
||||
e->struct_ref++;
|
||||
engine_ref_debug(e, 0, 1)
|
||||
/* However it came to be, e is the last item in the list. */
|
||||
engine_list_tail = e;
|
||||
engine_ref_debug(e, 0, 1);
|
||||
/* However it came to be, e is the last item in the list. */
|
||||
engine_list_tail = e;
|
||||
e->next = NULL;
|
||||
return 1;
|
||||
}
|
||||
@@ -185,13 +136,18 @@ ENGINE *ENGINE_get_first(void)
|
||||
{
|
||||
ENGINE *ret;
|
||||
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_GET_FIRST, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
ret = engine_list_head;
|
||||
if (ret) {
|
||||
ret->struct_ref++;
|
||||
engine_ref_debug(ret, 0, 1)
|
||||
engine_ref_debug(ret, 0, 1);
|
||||
}
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -199,13 +155,18 @@ ENGINE *ENGINE_get_last(void)
|
||||
{
|
||||
ENGINE *ret;
|
||||
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_GET_LAST, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
ret = engine_list_tail;
|
||||
if (ret) {
|
||||
ret->struct_ref++;
|
||||
engine_ref_debug(ret, 0, 1)
|
||||
engine_ref_debug(ret, 0, 1);
|
||||
}
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -217,14 +178,14 @@ ENGINE *ENGINE_get_next(ENGINE *e)
|
||||
ENGINEerr(ENGINE_F_ENGINE_GET_NEXT, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
ret = e->next;
|
||||
if (ret) {
|
||||
/* Return a valid structural refernce to the next ENGINE */
|
||||
/* Return a valid structural reference to the next ENGINE */
|
||||
ret->struct_ref++;
|
||||
engine_ref_debug(ret, 0, 1)
|
||||
engine_ref_debug(ret, 0, 1);
|
||||
}
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
/* Release the structural reference to the previous ENGINE */
|
||||
ENGINE_free(e);
|
||||
return ret;
|
||||
@@ -237,14 +198,14 @@ ENGINE *ENGINE_get_prev(ENGINE *e)
|
||||
ENGINEerr(ENGINE_F_ENGINE_GET_PREV, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
ret = e->prev;
|
||||
if (ret) {
|
||||
/* Return a valid structural reference to the next ENGINE */
|
||||
ret->struct_ref++;
|
||||
engine_ref_debug(ret, 0, 1)
|
||||
engine_ref_debug(ret, 0, 1);
|
||||
}
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
/* Release the structural reference to the previous ENGINE */
|
||||
ENGINE_free(e);
|
||||
return ret;
|
||||
@@ -262,12 +223,12 @@ int ENGINE_add(ENGINE *e)
|
||||
ENGINEerr(ENGINE_F_ENGINE_ADD, ENGINE_R_ID_OR_NAME_MISSING);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
if (!engine_list_add(e)) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_ADD, ENGINE_R_INTERNAL_LIST_ERROR);
|
||||
to_return = 0;
|
||||
}
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
return to_return;
|
||||
}
|
||||
|
||||
@@ -279,12 +240,12 @@ int ENGINE_remove(ENGINE *e)
|
||||
ENGINEerr(ENGINE_F_ENGINE_REMOVE, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
if (!engine_list_remove(e)) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_REMOVE, ENGINE_R_INTERNAL_LIST_ERROR);
|
||||
to_return = 0;
|
||||
}
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
return to_return;
|
||||
}
|
||||
|
||||
@@ -301,14 +262,10 @@ static void engine_cpy(ENGINE *dest, const ENGINE *src)
|
||||
#ifndef OPENSSL_NO_DH
|
||||
dest->dh_meth = src->dh_meth;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ECDH
|
||||
dest->ecdh_meth = src->ecdh_meth;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ECDSA
|
||||
dest->ecdsa_meth = src->ecdsa_meth;
|
||||
#ifndef OPENSSL_NO_EC
|
||||
dest->ec_meth = src->ec_meth;
|
||||
#endif
|
||||
dest->rand_meth = src->rand_meth;
|
||||
dest->store_meth = src->store_meth;
|
||||
dest->ciphers = src->ciphers;
|
||||
dest->digests = src->digests;
|
||||
dest->pkey_meths = src->pkey_meths;
|
||||
@@ -330,11 +287,16 @@ ENGINE *ENGINE_by_id(const char *id)
|
||||
ENGINEerr(ENGINE_F_ENGINE_BY_ID, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_BY_ID, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
iterator = engine_list_head;
|
||||
while (iterator && (strcmp(id, iterator->id) != 0))
|
||||
iterator = iterator->next;
|
||||
if (iterator) {
|
||||
if (iterator != NULL) {
|
||||
/*
|
||||
* We need to return a structural reference. If this is an ENGINE
|
||||
* type that returns copies, make a duplicate - otherwise increment
|
||||
@@ -342,7 +304,7 @@ ENGINE *ENGINE_by_id(const char *id)
|
||||
*/
|
||||
if (iterator->flags & ENGINE_FLAGS_BY_ID_COPY) {
|
||||
ENGINE *cp = ENGINE_new();
|
||||
if (!cp)
|
||||
if (cp == NULL)
|
||||
iterator = NULL;
|
||||
else {
|
||||
engine_cpy(cp, iterator);
|
||||
@@ -350,31 +312,18 @@ ENGINE *ENGINE_by_id(const char *id)
|
||||
}
|
||||
} else {
|
||||
iterator->struct_ref++;
|
||||
engine_ref_debug(iterator, 0, 1)
|
||||
engine_ref_debug(iterator, 0, 1);
|
||||
}
|
||||
}
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
#if 0
|
||||
if (iterator == NULL) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_BY_ID, ENGINE_R_NO_SUCH_ENGINE);
|
||||
ERR_add_error_data(2, "id=", id);
|
||||
}
|
||||
return iterator;
|
||||
#else
|
||||
/* EEK! Experimental code starts */
|
||||
if (iterator)
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
if (iterator != NULL)
|
||||
return iterator;
|
||||
/*
|
||||
* Prevent infinite recusrion if we're looking for the dynamic engine.
|
||||
* Prevent infinite recursion if we're looking for the dynamic engine.
|
||||
*/
|
||||
if (strcmp(id, "dynamic")) {
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
if ((load_dir = getenv("OPENSSL_ENGINES")) == 0)
|
||||
load_dir = "SSLROOT:[ENGINES]";
|
||||
# else
|
||||
if ((load_dir = getenv("OPENSSL_ENGINES")) == 0)
|
||||
load_dir = ENGINESDIR;
|
||||
# endif
|
||||
iterator = ENGINE_by_id("dynamic");
|
||||
if (!iterator || !ENGINE_ctrl_cmd_string(iterator, "ID", id, 0) ||
|
||||
!ENGINE_ctrl_cmd_string(iterator, "DIR_LOAD", "2", 0) ||
|
||||
@@ -391,15 +340,15 @@ ENGINE *ENGINE_by_id(const char *id)
|
||||
ERR_add_error_data(2, "id=", id);
|
||||
return NULL;
|
||||
/* EEK! Experimental code ends */
|
||||
#endif
|
||||
}
|
||||
|
||||
int ENGINE_up_ref(ENGINE *e)
|
||||
{
|
||||
int i;
|
||||
if (e == NULL) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_UP_REF, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_add(&e->struct_ref, 1, CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_atomic_add(&e->struct_ref, 1, &i, global_engine_lock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,61 +1,12 @@
|
||||
/* crypto/engine/eng_openssl.c */
|
||||
/*
|
||||
* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
|
||||
* 2000.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
* ECDH support in OpenSSL originally developed by
|
||||
@@ -64,21 +15,17 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/engine.h>
|
||||
#include <openssl/dso.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include <internal/engine.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/rand.h>
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
# include <openssl/rsa.h>
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
# include <openssl/dsa.h>
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DH
|
||||
# include <openssl/dh.h>
|
||||
#endif
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/dsa.h>
|
||||
#include <openssl/dh.h>
|
||||
|
||||
#include <openssl/hmac.h>
|
||||
#include <openssl/x509v3.h>
|
||||
|
||||
/*
|
||||
* This testing gunk is implemented (and explained) lower down. It also
|
||||
@@ -86,7 +33,11 @@
|
||||
* this is no longer automatic in ENGINE_load_builtin_engines().
|
||||
*/
|
||||
#define TEST_ENG_OPENSSL_RC4
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
#define TEST_ENG_OPENSSL_PKEY
|
||||
#endif
|
||||
/* #define TEST_ENG_OPENSSL_HMAC */
|
||||
/* #define TEST_ENG_OPENSSL_HMAC_INIT */
|
||||
/* #define TEST_ENG_OPENSSL_RC4_OTHERS */
|
||||
#define TEST_ENG_OPENSSL_RC4_P_INIT
|
||||
/* #define TEST_ENG_OPENSSL_RC4_P_CIPHER */
|
||||
@@ -103,13 +54,8 @@
|
||||
# undef TEST_ENG_OPENSSL_RC4_P_INIT
|
||||
# undef TEST_ENG_OPENSSL_RC4_P_CIPHER
|
||||
#endif
|
||||
#if defined(OPENSSL_NO_SHA) || defined(OPENSSL_NO_SHA0) || defined(OPENSSL_NO_SHA1)
|
||||
# undef TEST_ENG_OPENSSL_SHA
|
||||
# undef TEST_ENG_OPENSSL_SHA_OTHERS
|
||||
# undef TEST_ENG_OPENSSL_SHA_P_INIT
|
||||
# undef TEST_ENG_OPENSSL_SHA_P_UPDATE
|
||||
# undef TEST_ENG_OPENSSL_SHA_P_FINAL
|
||||
#endif
|
||||
|
||||
static int openssl_destroy(ENGINE *e);
|
||||
|
||||
#ifdef TEST_ENG_OPENSSL_RC4
|
||||
static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
|
||||
@@ -126,6 +72,12 @@ static EVP_PKEY *openssl_load_privkey(ENGINE *eng, const char *key_id,
|
||||
void *callback_data);
|
||||
#endif
|
||||
|
||||
#ifdef TEST_ENG_OPENSSL_HMAC
|
||||
static int ossl_register_hmac_meth(void);
|
||||
static int ossl_pkey_meths(ENGINE *e, EVP_PKEY_METHOD **pmeth,
|
||||
const int **nids, int nid);
|
||||
#endif
|
||||
|
||||
/* The constants used when creating the ENGINE */
|
||||
static const char *engine_openssl_id = "openssl";
|
||||
static const char *engine_openssl_name = "Software engine support";
|
||||
@@ -138,6 +90,7 @@ static int bind_helper(ENGINE *e)
|
||||
{
|
||||
if (!ENGINE_set_id(e, engine_openssl_id)
|
||||
|| !ENGINE_set_name(e, engine_openssl_name)
|
||||
|| !ENGINE_set_destroy_function(e, openssl_destroy)
|
||||
#ifndef TEST_ENG_OPENSSL_NO_ALGORITHMS
|
||||
# ifndef OPENSSL_NO_RSA
|
||||
|| !ENGINE_set_RSA(e, RSA_get_default_method())
|
||||
@@ -145,16 +98,13 @@ static int bind_helper(ENGINE *e)
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
|| !ENGINE_set_DSA(e, DSA_get_default_method())
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_ECDH
|
||||
|| !ENGINE_set_ECDH(e, ECDH_OpenSSL())
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_ECDSA
|
||||
|| !ENGINE_set_ECDSA(e, ECDSA_OpenSSL())
|
||||
# ifndef OPENSSL_NO_EC
|
||||
|| !ENGINE_set_EC(e, EC_KEY_OpenSSL())
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_DH
|
||||
|| !ENGINE_set_DH(e, DH_get_default_method())
|
||||
# endif
|
||||
|| !ENGINE_set_RAND(e, RAND_SSLeay())
|
||||
|| !ENGINE_set_RAND(e, RAND_OpenSSL())
|
||||
# ifdef TEST_ENG_OPENSSL_RC4
|
||||
|| !ENGINE_set_ciphers(e, openssl_ciphers)
|
||||
# endif
|
||||
@@ -164,6 +114,10 @@ static int bind_helper(ENGINE *e)
|
||||
#endif
|
||||
#ifdef TEST_ENG_OPENSSL_PKEY
|
||||
|| !ENGINE_set_load_privkey_function(e, openssl_load_privkey)
|
||||
#endif
|
||||
#ifdef TEST_ENG_OPENSSL_HMAC
|
||||
|| !ossl_register_hmac_meth()
|
||||
|| !ENGINE_set_pkey_meths(e, ossl_pkey_meths)
|
||||
#endif
|
||||
)
|
||||
return 0;
|
||||
@@ -178,7 +132,7 @@ static int bind_helper(ENGINE *e)
|
||||
static ENGINE *engine_openssl(void)
|
||||
{
|
||||
ENGINE *ret = ENGINE_new();
|
||||
if (!ret)
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
if (!bind_helper(ret)) {
|
||||
ENGINE_free(ret);
|
||||
@@ -187,7 +141,7 @@ static ENGINE *engine_openssl(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ENGINE_load_openssl(void)
|
||||
void engine_load_openssl_int(void)
|
||||
{
|
||||
ENGINE *toadd = engine_openssl();
|
||||
if (!toadd)
|
||||
@@ -232,14 +186,11 @@ IMPLEMENT_DYNAMIC_CHECK_FN()
|
||||
*/
|
||||
# include <openssl/rc4.h>
|
||||
# define TEST_RC4_KEY_SIZE 16
|
||||
static int test_cipher_nids[] = { NID_rc4, NID_rc4_40 };
|
||||
|
||||
static int test_cipher_nids_number = 2;
|
||||
typedef struct {
|
||||
unsigned char key[TEST_RC4_KEY_SIZE];
|
||||
RC4_KEY ks;
|
||||
} TEST_RC4_KEY;
|
||||
# define test(ctx) ((TEST_RC4_KEY *)(ctx)->cipher_data)
|
||||
# define test(ctx) ((TEST_RC4_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))
|
||||
static int test_rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
const unsigned char *iv, int enc)
|
||||
{
|
||||
@@ -262,47 +213,86 @@ static int test_rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const EVP_CIPHER test_r4_cipher = {
|
||||
NID_rc4,
|
||||
1, TEST_RC4_KEY_SIZE, 0,
|
||||
EVP_CIPH_VARIABLE_LENGTH,
|
||||
test_rc4_init_key,
|
||||
test_rc4_cipher,
|
||||
NULL,
|
||||
sizeof(TEST_RC4_KEY),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
static EVP_CIPHER *r4_cipher = NULL;
|
||||
static const EVP_CIPHER *test_r4_cipher(void)
|
||||
{
|
||||
if (r4_cipher == NULL) {
|
||||
EVP_CIPHER *cipher;
|
||||
|
||||
static const EVP_CIPHER test_r4_40_cipher = {
|
||||
NID_rc4_40,
|
||||
1, 5 /* 40 bit */ , 0,
|
||||
EVP_CIPH_VARIABLE_LENGTH,
|
||||
test_rc4_init_key,
|
||||
test_rc4_cipher,
|
||||
NULL,
|
||||
sizeof(TEST_RC4_KEY),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
if ((cipher = EVP_CIPHER_meth_new(NID_rc4, 1, TEST_RC4_KEY_SIZE)) == NULL
|
||||
|| !EVP_CIPHER_meth_set_iv_length(cipher, 0)
|
||||
|| !EVP_CIPHER_meth_set_flags(cipher, EVP_CIPH_VARIABLE_LENGTH)
|
||||
|| !EVP_CIPHER_meth_set_init(cipher, test_rc4_init_key)
|
||||
|| !EVP_CIPHER_meth_set_do_cipher(cipher, test_rc4_cipher)
|
||||
|| !EVP_CIPHER_meth_set_impl_ctx_size(cipher, sizeof(TEST_RC4_KEY))) {
|
||||
EVP_CIPHER_meth_free(cipher);
|
||||
cipher = NULL;
|
||||
}
|
||||
r4_cipher = cipher;
|
||||
}
|
||||
return r4_cipher;
|
||||
}
|
||||
static void test_r4_cipher_destroy(void)
|
||||
{
|
||||
EVP_CIPHER_meth_free(r4_cipher);
|
||||
r4_cipher = NULL;
|
||||
}
|
||||
|
||||
static EVP_CIPHER *r4_40_cipher = NULL;
|
||||
static const EVP_CIPHER *test_r4_40_cipher(void)
|
||||
{
|
||||
if (r4_40_cipher == NULL) {
|
||||
EVP_CIPHER *cipher;
|
||||
|
||||
if ((cipher = EVP_CIPHER_meth_new(NID_rc4, 1, 5 /* 40 bits */)) == NULL
|
||||
|| !EVP_CIPHER_meth_set_iv_length(cipher, 0)
|
||||
|| !EVP_CIPHER_meth_set_flags(cipher, EVP_CIPH_VARIABLE_LENGTH)
|
||||
|| !EVP_CIPHER_meth_set_init(cipher, test_rc4_init_key)
|
||||
|| !EVP_CIPHER_meth_set_do_cipher(cipher, test_rc4_cipher)
|
||||
|| !EVP_CIPHER_meth_set_impl_ctx_size(cipher, sizeof(TEST_RC4_KEY))) {
|
||||
EVP_CIPHER_meth_free(cipher);
|
||||
cipher = NULL;
|
||||
}
|
||||
r4_40_cipher = cipher;
|
||||
}
|
||||
return r4_40_cipher;
|
||||
}
|
||||
static void test_r4_40_cipher_destroy(void)
|
||||
{
|
||||
EVP_CIPHER_meth_free(r4_40_cipher);
|
||||
r4_40_cipher = NULL;
|
||||
}
|
||||
static int test_cipher_nids(const int **nids)
|
||||
{
|
||||
static int cipher_nids[4] = { 0, 0, 0, 0 };
|
||||
static int pos = 0;
|
||||
static int init = 0;
|
||||
|
||||
if (!init) {
|
||||
const EVP_CIPHER *cipher;
|
||||
if ((cipher = test_r4_cipher()) != NULL)
|
||||
cipher_nids[pos++] = EVP_CIPHER_nid(cipher);
|
||||
if ((cipher = test_r4_40_cipher()) != NULL)
|
||||
cipher_nids[pos++] = EVP_CIPHER_nid(cipher);
|
||||
cipher_nids[pos] = 0;
|
||||
init = 1;
|
||||
}
|
||||
*nids = cipher_nids;
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
|
||||
const int **nids, int nid)
|
||||
{
|
||||
if (!cipher) {
|
||||
/* We are returning a list of supported nids */
|
||||
*nids = test_cipher_nids;
|
||||
return test_cipher_nids_number;
|
||||
return test_cipher_nids(nids);
|
||||
}
|
||||
/* We are being asked for a specific cipher */
|
||||
if (nid == NID_rc4)
|
||||
*cipher = &test_r4_cipher;
|
||||
*cipher = test_r4_cipher();
|
||||
else if (nid == NID_rc4_40)
|
||||
*cipher = &test_r4_40_cipher;
|
||||
*cipher = test_r4_40_cipher();
|
||||
else {
|
||||
# ifdef TEST_ENG_OPENSSL_RC4_OTHERS
|
||||
fprintf(stderr, "(TEST_ENG_OPENSSL_RC4) returning NULL for "
|
||||
@@ -318,15 +308,13 @@ static int openssl_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
|
||||
#ifdef TEST_ENG_OPENSSL_SHA
|
||||
/* Much the same sort of comment as for TEST_ENG_OPENSSL_RC4 */
|
||||
# include <openssl/sha.h>
|
||||
static int test_digest_nids[] = { NID_sha1 };
|
||||
|
||||
static int test_digest_nids_number = 1;
|
||||
static int test_sha1_init(EVP_MD_CTX *ctx)
|
||||
{
|
||||
# ifdef TEST_ENG_OPENSSL_SHA_P_INIT
|
||||
fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) test_sha1_init() called\n");
|
||||
# endif
|
||||
return SHA1_Init(ctx->md_data);
|
||||
return SHA1_Init(EVP_MD_CTX_md_data(ctx));
|
||||
}
|
||||
|
||||
static int test_sha1_update(EVP_MD_CTX *ctx, const void *data, size_t count)
|
||||
@@ -334,7 +322,7 @@ static int test_sha1_update(EVP_MD_CTX *ctx, const void *data, size_t count)
|
||||
# ifdef TEST_ENG_OPENSSL_SHA_P_UPDATE
|
||||
fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) test_sha1_update() called\n");
|
||||
# endif
|
||||
return SHA1_Update(ctx->md_data, data, count);
|
||||
return SHA1_Update(EVP_MD_CTX_md_data(ctx), data, count);
|
||||
}
|
||||
|
||||
static int test_sha1_final(EVP_MD_CTX *ctx, unsigned char *md)
|
||||
@@ -342,35 +330,63 @@ static int test_sha1_final(EVP_MD_CTX *ctx, unsigned char *md)
|
||||
# ifdef TEST_ENG_OPENSSL_SHA_P_FINAL
|
||||
fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) test_sha1_final() called\n");
|
||||
# endif
|
||||
return SHA1_Final(md, ctx->md_data);
|
||||
return SHA1_Final(md, EVP_MD_CTX_md_data(ctx));
|
||||
}
|
||||
|
||||
static const EVP_MD test_sha_md = {
|
||||
NID_sha1,
|
||||
NID_sha1WithRSAEncryption,
|
||||
SHA_DIGEST_LENGTH,
|
||||
0,
|
||||
test_sha1_init,
|
||||
test_sha1_update,
|
||||
test_sha1_final,
|
||||
NULL,
|
||||
NULL,
|
||||
EVP_PKEY_RSA_method,
|
||||
SHA_CBLOCK,
|
||||
sizeof(EVP_MD *) + sizeof(SHA_CTX),
|
||||
};
|
||||
static EVP_MD *sha1_md = NULL;
|
||||
static const EVP_MD *test_sha_md(void)
|
||||
{
|
||||
if (sha1_md == NULL) {
|
||||
EVP_MD *md;
|
||||
|
||||
if ((md = EVP_MD_meth_new(NID_sha1, NID_sha1WithRSAEncryption)) == NULL
|
||||
|| !EVP_MD_meth_set_result_size(md, SHA_DIGEST_LENGTH)
|
||||
|| !EVP_MD_meth_set_input_blocksize(md, SHA_CBLOCK)
|
||||
|| !EVP_MD_meth_set_app_datasize(md,
|
||||
sizeof(EVP_MD *) + sizeof(SHA_CTX))
|
||||
|| !EVP_MD_meth_set_flags(md, 0)
|
||||
|| !EVP_MD_meth_set_init(md, test_sha1_init)
|
||||
|| !EVP_MD_meth_set_update(md, test_sha1_update)
|
||||
|| !EVP_MD_meth_set_final(md, test_sha1_final)) {
|
||||
EVP_MD_meth_free(md);
|
||||
md = NULL;
|
||||
}
|
||||
sha1_md = md;
|
||||
}
|
||||
return sha1_md;
|
||||
}
|
||||
static void test_sha_md_destroy(void)
|
||||
{
|
||||
EVP_MD_meth_free(sha1_md);
|
||||
sha1_md = NULL;
|
||||
}
|
||||
static int test_digest_nids(const int **nids)
|
||||
{
|
||||
static int digest_nids[2] = { 0, 0 };
|
||||
static int pos = 0;
|
||||
static int init = 0;
|
||||
|
||||
if (!init) {
|
||||
const EVP_MD *md;
|
||||
if ((md = test_sha_md()) != NULL)
|
||||
digest_nids[pos++] = EVP_MD_type(md);
|
||||
digest_nids[pos] = 0;
|
||||
init = 1;
|
||||
}
|
||||
*nids = digest_nids;
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int openssl_digests(ENGINE *e, const EVP_MD **digest,
|
||||
const int **nids, int nid)
|
||||
{
|
||||
if (!digest) {
|
||||
/* We are returning a list of supported nids */
|
||||
*nids = test_digest_nids;
|
||||
return test_digest_nids_number;
|
||||
return test_digest_nids(nids);
|
||||
}
|
||||
/* We are being asked for a specific digest */
|
||||
if (nid == NID_sha1)
|
||||
*digest = &test_sha_md;
|
||||
*digest = test_sha_md();
|
||||
else {
|
||||
# ifdef TEST_ENG_OPENSSL_SHA_OTHERS
|
||||
fprintf(stderr, "(TEST_ENG_OPENSSL_SHA) returning NULL for "
|
||||
@@ -400,3 +416,237 @@ static EVP_PKEY *openssl_load_privkey(ENGINE *eng, const char *key_id,
|
||||
return key;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TEST_ENG_OPENSSL_HMAC
|
||||
|
||||
/*
|
||||
* Experimental HMAC redirection implementation: mainly copied from
|
||||
* hm_pmeth.c
|
||||
*/
|
||||
|
||||
/* HMAC pkey context structure */
|
||||
|
||||
typedef struct {
|
||||
const EVP_MD *md; /* MD for HMAC use */
|
||||
ASN1_OCTET_STRING ktmp; /* Temp storage for key */
|
||||
HMAC_CTX *ctx;
|
||||
} OSSL_HMAC_PKEY_CTX;
|
||||
|
||||
static int ossl_hmac_init(EVP_PKEY_CTX *ctx)
|
||||
{
|
||||
OSSL_HMAC_PKEY_CTX *hctx;
|
||||
|
||||
hctx = OPENSSL_zalloc(sizeof(*hctx));
|
||||
if (hctx == NULL)
|
||||
return 0;
|
||||
hctx->ktmp.type = V_ASN1_OCTET_STRING;
|
||||
hctx->ctx = HMAC_CTX_new();
|
||||
if (hctx->ctx == NULL) {
|
||||
OPENSSL_free(hctx);
|
||||
return 0;
|
||||
}
|
||||
EVP_PKEY_CTX_set_data(ctx, hctx);
|
||||
EVP_PKEY_CTX_set0_keygen_info(ctx, NULL, 0);
|
||||
# ifdef TEST_ENG_OPENSSL_HMAC_INIT
|
||||
fprintf(stderr, "(TEST_ENG_OPENSSL_HMAC) ossl_hmac_init() called\n");
|
||||
# endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void ossl_hmac_cleanup(EVP_PKEY_CTX *ctx);
|
||||
|
||||
static int ossl_hmac_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
|
||||
{
|
||||
OSSL_HMAC_PKEY_CTX *sctx, *dctx;
|
||||
|
||||
/* allocate memory for dst->data and a new HMAC_CTX in dst->data->ctx */
|
||||
if (!ossl_hmac_init(dst))
|
||||
return 0;
|
||||
sctx = EVP_PKEY_CTX_get_data(src);
|
||||
dctx = EVP_PKEY_CTX_get_data(dst);
|
||||
dctx->md = sctx->md;
|
||||
if (!HMAC_CTX_copy(dctx->ctx, sctx->ctx))
|
||||
goto err;
|
||||
if (sctx->ktmp.data) {
|
||||
if (!ASN1_OCTET_STRING_set(&dctx->ktmp,
|
||||
sctx->ktmp.data, sctx->ktmp.length))
|
||||
goto err;
|
||||
}
|
||||
return 1;
|
||||
err:
|
||||
/* release HMAC_CTX in dst->data->ctx and memory allocated for dst->data */
|
||||
ossl_hmac_cleanup(dst);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ossl_hmac_cleanup(EVP_PKEY_CTX *ctx)
|
||||
{
|
||||
OSSL_HMAC_PKEY_CTX *hctx = EVP_PKEY_CTX_get_data(ctx);
|
||||
|
||||
if (hctx) {
|
||||
HMAC_CTX_free(hctx->ctx);
|
||||
OPENSSL_clear_free(hctx->ktmp.data, hctx->ktmp.length);
|
||||
OPENSSL_free(hctx);
|
||||
EVP_PKEY_CTX_set_data(ctx, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static int ossl_hmac_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
{
|
||||
ASN1_OCTET_STRING *hkey = NULL;
|
||||
OSSL_HMAC_PKEY_CTX *hctx = EVP_PKEY_CTX_get_data(ctx);
|
||||
if (!hctx->ktmp.data)
|
||||
return 0;
|
||||
hkey = ASN1_OCTET_STRING_dup(&hctx->ktmp);
|
||||
if (!hkey)
|
||||
return 0;
|
||||
EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, hkey);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ossl_int_update(EVP_MD_CTX *ctx, const void *data, size_t count)
|
||||
{
|
||||
OSSL_HMAC_PKEY_CTX *hctx = EVP_PKEY_CTX_get_data(EVP_MD_CTX_pkey_ctx(ctx));
|
||||
if (!HMAC_Update(hctx->ctx, data, count))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ossl_hmac_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)
|
||||
{
|
||||
EVP_MD_CTX_set_flags(mctx, EVP_MD_CTX_FLAG_NO_INIT);
|
||||
EVP_MD_CTX_set_update_fn(mctx, ossl_int_update);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ossl_hmac_signctx(EVP_PKEY_CTX *ctx, unsigned char *sig,
|
||||
size_t *siglen, EVP_MD_CTX *mctx)
|
||||
{
|
||||
unsigned int hlen;
|
||||
OSSL_HMAC_PKEY_CTX *hctx = EVP_PKEY_CTX_get_data(ctx);
|
||||
int l = EVP_MD_CTX_size(mctx);
|
||||
|
||||
if (l < 0)
|
||||
return 0;
|
||||
*siglen = l;
|
||||
if (!sig)
|
||||
return 1;
|
||||
|
||||
if (!HMAC_Final(hctx->ctx, sig, &hlen))
|
||||
return 0;
|
||||
*siglen = (size_t)hlen;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ossl_hmac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
|
||||
{
|
||||
OSSL_HMAC_PKEY_CTX *hctx = EVP_PKEY_CTX_get_data(ctx);
|
||||
EVP_PKEY *pk;
|
||||
ASN1_OCTET_STRING *key;
|
||||
switch (type) {
|
||||
|
||||
case EVP_PKEY_CTRL_SET_MAC_KEY:
|
||||
if ((!p2 && p1 > 0) || (p1 < -1))
|
||||
return 0;
|
||||
if (!ASN1_OCTET_STRING_set(&hctx->ktmp, p2, p1))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case EVP_PKEY_CTRL_MD:
|
||||
hctx->md = p2;
|
||||
break;
|
||||
|
||||
case EVP_PKEY_CTRL_DIGESTINIT:
|
||||
pk = EVP_PKEY_CTX_get0_pkey(ctx);
|
||||
key = EVP_PKEY_get0(pk);
|
||||
if (!HMAC_Init_ex(hctx->ctx, key->data, key->length, hctx->md, NULL))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ossl_hmac_ctrl_str(EVP_PKEY_CTX *ctx,
|
||||
const char *type, const char *value)
|
||||
{
|
||||
if (!value) {
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(type, "key") == 0) {
|
||||
void *p = (void *)value;
|
||||
return ossl_hmac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, -1, p);
|
||||
}
|
||||
if (strcmp(type, "hexkey") == 0) {
|
||||
unsigned char *key;
|
||||
int r;
|
||||
long keylen;
|
||||
key = OPENSSL_hexstr2buf(value, &keylen);
|
||||
if (!key)
|
||||
return 0;
|
||||
r = ossl_hmac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, keylen, key);
|
||||
OPENSSL_free(key);
|
||||
return r;
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
||||
static EVP_PKEY_METHOD *ossl_hmac_meth;
|
||||
|
||||
static int ossl_register_hmac_meth(void)
|
||||
{
|
||||
EVP_PKEY_METHOD *meth;
|
||||
meth = EVP_PKEY_meth_new(EVP_PKEY_HMAC, 0);
|
||||
if (meth == NULL)
|
||||
return 0;
|
||||
EVP_PKEY_meth_set_init(meth, ossl_hmac_init);
|
||||
EVP_PKEY_meth_set_copy(meth, ossl_hmac_copy);
|
||||
EVP_PKEY_meth_set_cleanup(meth, ossl_hmac_cleanup);
|
||||
|
||||
EVP_PKEY_meth_set_keygen(meth, 0, ossl_hmac_keygen);
|
||||
|
||||
EVP_PKEY_meth_set_signctx(meth, ossl_hmac_signctx_init,
|
||||
ossl_hmac_signctx);
|
||||
|
||||
EVP_PKEY_meth_set_ctrl(meth, ossl_hmac_ctrl, ossl_hmac_ctrl_str);
|
||||
ossl_hmac_meth = meth;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int ossl_pkey_meths(ENGINE *e, EVP_PKEY_METHOD **pmeth,
|
||||
const int **nids, int nid)
|
||||
{
|
||||
static int ossl_pkey_nids[] = {
|
||||
EVP_PKEY_HMAC,
|
||||
0
|
||||
};
|
||||
if (!pmeth) {
|
||||
*nids = ossl_pkey_nids;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (nid == EVP_PKEY_HMAC) {
|
||||
*pmeth = ossl_hmac_meth;
|
||||
return 1;
|
||||
}
|
||||
|
||||
*pmeth = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int openssl_destroy(ENGINE *e)
|
||||
{
|
||||
test_sha_md_destroy();
|
||||
#ifdef TEST_ENG_OPENSSL_RC4
|
||||
test_r4_cipher_destroy();
|
||||
test_r4_40_cipher_destroy();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,56 +1,10 @@
|
||||
/* crypto/engine/eng_pkey.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
@@ -106,13 +60,13 @@ EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id,
|
||||
ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
if (e->funct_ref == 0) {
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY, ENGINE_R_NOT_INITIALISED);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
if (!e->load_privkey) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY,
|
||||
ENGINE_R_NO_LOAD_FUNCTION);
|
||||
@@ -137,13 +91,13 @@ EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id,
|
||||
ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
if (e->funct_ref == 0) {
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY, ENGINE_R_NOT_INITIALISED);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
if (!e->load_pubkey) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY, ENGINE_R_NO_LOAD_FUNCTION);
|
||||
return 0;
|
||||
@@ -168,14 +122,14 @@ int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s,
|
||||
ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
if (e->funct_ref == 0) {
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
ENGINEerr(ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT,
|
||||
ENGINE_R_NOT_INITIALISED);
|
||||
return 0;
|
||||
}
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
if (!e->load_ssl_client_cert) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT,
|
||||
ENGINE_R_NO_LOAD_FUNCTION);
|
||||
|
||||
@@ -1,59 +1,20 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2011 The OpenSSL Project. All rights reserved.
|
||||
/*
|
||||
* Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <openssl/engine.h>
|
||||
#include <internal/engine.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
#if (defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
|
||||
defined(__x86_64) || defined(__x86_64__) || \
|
||||
@@ -120,7 +81,7 @@ static int bind_helper(ENGINE *e)
|
||||
static ENGINE *ENGINE_rdrand(void)
|
||||
{
|
||||
ENGINE *ret = ENGINE_new();
|
||||
if (!ret)
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
if (!bind_helper(ret)) {
|
||||
ENGINE_free(ret);
|
||||
@@ -129,7 +90,7 @@ static ENGINE *ENGINE_rdrand(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ENGINE_load_rdrand(void)
|
||||
void engine_load_rdrand_int(void)
|
||||
{
|
||||
extern unsigned int OPENSSL_ia32cap_P[];
|
||||
|
||||
@@ -143,7 +104,7 @@ void ENGINE_load_rdrand(void)
|
||||
}
|
||||
}
|
||||
#else
|
||||
void ENGINE_load_rdrand(void)
|
||||
void engine_load_rdrand_int(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,64 +1,19 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "cryptlib.h"
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/lhash.h>
|
||||
#include "eng_int.h"
|
||||
|
||||
/* The type of the items in the table */
|
||||
typedef struct st_engine_pile {
|
||||
struct st_engine_pile {
|
||||
/* The 'nid' of this algorithm/mode */
|
||||
int nid;
|
||||
/* ENGINEs that implement this algorithm/mode. */
|
||||
@@ -69,9 +24,7 @@ typedef struct st_engine_pile {
|
||||
* Zero if 'sk' is newer than the cached 'funct', non-zero otherwise
|
||||
*/
|
||||
int uptodate;
|
||||
} ENGINE_PILE;
|
||||
|
||||
DECLARE_LHASH_OF(ENGINE_PILE);
|
||||
};
|
||||
|
||||
/* The type exposed in eng_int.h */
|
||||
struct st_engine_table {
|
||||
@@ -108,9 +61,6 @@ static int engine_pile_cmp(const ENGINE_PILE *a, const ENGINE_PILE *b)
|
||||
return a->nid - b->nid;
|
||||
}
|
||||
|
||||
static IMPLEMENT_LHASH_HASH_FN(engine_pile, ENGINE_PILE)
|
||||
static IMPLEMENT_LHASH_COMP_FN(engine_pile, ENGINE_PILE)
|
||||
|
||||
static int int_table_check(ENGINE_TABLE **t, int create)
|
||||
{
|
||||
LHASH_OF(ENGINE_PILE) *lh;
|
||||
@@ -119,7 +69,7 @@ static int int_table_check(ENGINE_TABLE **t, int create)
|
||||
return 1;
|
||||
if (!create)
|
||||
return 0;
|
||||
if ((lh = lh_ENGINE_PILE_new()) == NULL)
|
||||
if ((lh = lh_ENGINE_PILE_new(engine_pile_hash, engine_pile_cmp)) == NULL)
|
||||
return 0;
|
||||
*t = (ENGINE_TABLE *)lh;
|
||||
return 1;
|
||||
@@ -135,7 +85,7 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
|
||||
{
|
||||
int ret = 0, added = 0;
|
||||
ENGINE_PILE tmplate, *fnd;
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
if (!(*table))
|
||||
added = 1;
|
||||
if (!int_table_check(table, 1))
|
||||
@@ -147,8 +97,8 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
|
||||
tmplate.nid = *nids;
|
||||
fnd = lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate);
|
||||
if (!fnd) {
|
||||
fnd = OPENSSL_malloc(sizeof(ENGINE_PILE));
|
||||
if (!fnd)
|
||||
fnd = OPENSSL_malloc(sizeof(*fnd));
|
||||
if (fnd == NULL)
|
||||
goto end;
|
||||
fnd->uptodate = 1;
|
||||
fnd->nid = *nids;
|
||||
@@ -160,7 +110,7 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
|
||||
fnd->funct = NULL;
|
||||
(void)lh_ENGINE_PILE_insert(&(*table)->piles, fnd);
|
||||
}
|
||||
/* A registration shouldn't add duplciate entries */
|
||||
/* A registration shouldn't add duplicate entries */
|
||||
(void)sk_ENGINE_delete_ptr(fnd->sk, e);
|
||||
/*
|
||||
* if 'setdefault', this ENGINE goes to the head of the list
|
||||
@@ -184,14 +134,14 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
|
||||
}
|
||||
ret = 1;
|
||||
end:
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void int_unregister_cb_doall_arg(ENGINE_PILE *pile, ENGINE *e)
|
||||
static void int_unregister_cb(ENGINE_PILE *pile, ENGINE *e)
|
||||
{
|
||||
int n;
|
||||
/* Iterate the 'c->sk' stack removing any occurance of 'e' */
|
||||
/* Iterate the 'c->sk' stack removing any occurrence of 'e' */
|
||||
while ((n = sk_ENGINE_find(pile->sk, e)) >= 0) {
|
||||
(void)sk_ENGINE_delete(pile->sk, n);
|
||||
pile->uptodate = 0;
|
||||
@@ -202,38 +152,35 @@ static void int_unregister_cb_doall_arg(ENGINE_PILE *pile, ENGINE *e)
|
||||
}
|
||||
}
|
||||
|
||||
static IMPLEMENT_LHASH_DOALL_ARG_FN(int_unregister_cb, ENGINE_PILE, ENGINE)
|
||||
IMPLEMENT_LHASH_DOALL_ARG(ENGINE_PILE, ENGINE);
|
||||
|
||||
void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e)
|
||||
{
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
if (int_table_check(table, 0))
|
||||
lh_ENGINE_PILE_doall_arg(&(*table)->piles,
|
||||
LHASH_DOALL_ARG_FN(int_unregister_cb),
|
||||
ENGINE, e);
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
lh_ENGINE_PILE_doall_ENGINE(&(*table)->piles, int_unregister_cb, e);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
}
|
||||
|
||||
static void int_cleanup_cb_doall(ENGINE_PILE *p)
|
||||
{
|
||||
if (!p)
|
||||
return;
|
||||
sk_ENGINE_free(p->sk);
|
||||
if (p->funct)
|
||||
engine_unlocked_finish(p->funct, 0);
|
||||
OPENSSL_free(p);
|
||||
}
|
||||
|
||||
static IMPLEMENT_LHASH_DOALL_FN(int_cleanup_cb, ENGINE_PILE)
|
||||
|
||||
void engine_table_cleanup(ENGINE_TABLE **table)
|
||||
{
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
if (*table) {
|
||||
lh_ENGINE_PILE_doall(&(*table)->piles,
|
||||
LHASH_DOALL_FN(int_cleanup_cb));
|
||||
lh_ENGINE_PILE_doall(&(*table)->piles, int_cleanup_cb_doall);
|
||||
lh_ENGINE_PILE_free(&(*table)->piles);
|
||||
*table = NULL;
|
||||
}
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
}
|
||||
|
||||
/* return a functional reference for a given 'nid' */
|
||||
@@ -256,7 +203,7 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
|
||||
return NULL;
|
||||
}
|
||||
ERR_set_mark();
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
/*
|
||||
* Check again inside the lock otherwise we could race against cleanup
|
||||
* operations. But don't worry about a fprintf(stderr).
|
||||
@@ -327,7 +274,7 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
|
||||
fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, caching "
|
||||
"'no matching ENGINE'\n", f, l, nid);
|
||||
#endif
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
/*
|
||||
* Whatever happened, any failed init()s are not failures in this
|
||||
* context, so clear our error state.
|
||||
@@ -338,12 +285,12 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
|
||||
|
||||
/* Table enumeration */
|
||||
|
||||
static void int_cb_doall_arg(ENGINE_PILE *pile, ENGINE_PILE_DOALL *dall)
|
||||
static void int_dall(const ENGINE_PILE *pile, ENGINE_PILE_DOALL *dall)
|
||||
{
|
||||
dall->cb(pile->nid, pile->sk, pile->funct, dall->arg);
|
||||
}
|
||||
|
||||
static IMPLEMENT_LHASH_DOALL_ARG_FN(int_cb, ENGINE_PILE, ENGINE_PILE_DOALL)
|
||||
IMPLEMENT_LHASH_DOALL_ARG_CONST(ENGINE_PILE, ENGINE_PILE_DOALL);
|
||||
|
||||
void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb,
|
||||
void *arg)
|
||||
@@ -352,7 +299,5 @@ void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb,
|
||||
dall.cb = cb;
|
||||
dall.arg = arg;
|
||||
if (table)
|
||||
lh_ENGINE_PILE_doall_arg(&table->piles,
|
||||
LHASH_DOALL_ARG_FN(int_cb),
|
||||
ENGINE_PILE_DOALL, &dall);
|
||||
lh_ENGINE_PILE_doall_ENGINE_PILE_DOALL(&table->piles, int_dall, &dall);
|
||||
}
|
||||
|
||||
@@ -1,960 +0,0 @@
|
||||
/* openssl/engine.h */
|
||||
/*
|
||||
* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
|
||||
* 2000.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
* ECDH support in OpenSSL originally developed by
|
||||
* SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
|
||||
*/
|
||||
|
||||
#ifndef HEADER_ENGINE_H
|
||||
# define HEADER_ENGINE_H
|
||||
|
||||
# include <openssl/opensslconf.h>
|
||||
|
||||
# ifdef OPENSSL_NO_ENGINE
|
||||
# error ENGINE is disabled.
|
||||
# endif
|
||||
|
||||
# ifndef OPENSSL_NO_DEPRECATED
|
||||
# include <openssl/bn.h>
|
||||
# ifndef OPENSSL_NO_RSA
|
||||
# include <openssl/rsa.h>
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
# include <openssl/dsa.h>
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_DH
|
||||
# include <openssl/dh.h>
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_ECDH
|
||||
# include <openssl/ecdh.h>
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_ECDSA
|
||||
# include <openssl/ecdsa.h>
|
||||
# endif
|
||||
# include <openssl/rand.h>
|
||||
# include <openssl/ui.h>
|
||||
# include <openssl/err.h>
|
||||
# endif
|
||||
|
||||
# include <openssl/ossl_typ.h>
|
||||
# include <openssl/symhacks.h>
|
||||
|
||||
# include <openssl/x509.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* These flags are used to control combinations of algorithm (methods) by
|
||||
* bitwise "OR"ing.
|
||||
*/
|
||||
# define ENGINE_METHOD_RSA (unsigned int)0x0001
|
||||
# define ENGINE_METHOD_DSA (unsigned int)0x0002
|
||||
# define ENGINE_METHOD_DH (unsigned int)0x0004
|
||||
# define ENGINE_METHOD_RAND (unsigned int)0x0008
|
||||
# define ENGINE_METHOD_ECDH (unsigned int)0x0010
|
||||
# define ENGINE_METHOD_ECDSA (unsigned int)0x0020
|
||||
# define ENGINE_METHOD_CIPHERS (unsigned int)0x0040
|
||||
# define ENGINE_METHOD_DIGESTS (unsigned int)0x0080
|
||||
# define ENGINE_METHOD_STORE (unsigned int)0x0100
|
||||
# define ENGINE_METHOD_PKEY_METHS (unsigned int)0x0200
|
||||
# define ENGINE_METHOD_PKEY_ASN1_METHS (unsigned int)0x0400
|
||||
/* Obvious all-or-nothing cases. */
|
||||
# define ENGINE_METHOD_ALL (unsigned int)0xFFFF
|
||||
# define ENGINE_METHOD_NONE (unsigned int)0x0000
|
||||
|
||||
/*
|
||||
* This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used
|
||||
* internally to control registration of ENGINE implementations, and can be
|
||||
* set by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to
|
||||
* initialise registered ENGINEs if they are not already initialised.
|
||||
*/
|
||||
# define ENGINE_TABLE_FLAG_NOINIT (unsigned int)0x0001
|
||||
|
||||
/* ENGINE flags that can be set by ENGINE_set_flags(). */
|
||||
/* Not used */
|
||||
/* #define ENGINE_FLAGS_MALLOCED 0x0001 */
|
||||
|
||||
/*
|
||||
* This flag is for ENGINEs that wish to handle the various 'CMD'-related
|
||||
* control commands on their own. Without this flag, ENGINE_ctrl() handles
|
||||
* these control commands on behalf of the ENGINE using their "cmd_defns"
|
||||
* data.
|
||||
*/
|
||||
# define ENGINE_FLAGS_MANUAL_CMD_CTRL (int)0x0002
|
||||
|
||||
/*
|
||||
* This flag is for ENGINEs who return new duplicate structures when found
|
||||
* via "ENGINE_by_id()". When an ENGINE must store state (eg. if
|
||||
* ENGINE_ctrl() commands are called in sequence as part of some stateful
|
||||
* process like key-generation setup and execution), it can set this flag -
|
||||
* then each attempt to obtain the ENGINE will result in it being copied into
|
||||
* a new structure. Normally, ENGINEs don't declare this flag so
|
||||
* ENGINE_by_id() just increments the existing ENGINE's structural reference
|
||||
* count.
|
||||
*/
|
||||
# define ENGINE_FLAGS_BY_ID_COPY (int)0x0004
|
||||
|
||||
/*
|
||||
* This flag if for an ENGINE that does not want its methods registered as
|
||||
* part of ENGINE_register_all_complete() for example if the methods are not
|
||||
* usable as default methods.
|
||||
*/
|
||||
|
||||
# define ENGINE_FLAGS_NO_REGISTER_ALL (int)0x0008
|
||||
|
||||
/*
|
||||
* ENGINEs can support their own command types, and these flags are used in
|
||||
* ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input
|
||||
* each command expects. Currently only numeric and string input is
|
||||
* supported. If a control command supports none of the _NUMERIC, _STRING, or
|
||||
* _NO_INPUT options, then it is regarded as an "internal" control command -
|
||||
* and not for use in config setting situations. As such, they're not
|
||||
* available to the ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl()
|
||||
* access. Changes to this list of 'command types' should be reflected
|
||||
* carefully in ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string().
|
||||
*/
|
||||
|
||||
/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */
|
||||
# define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001
|
||||
/*
|
||||
* accepts string input (cast from 'void*' to 'const char *', 4th parameter
|
||||
* to ENGINE_ctrl)
|
||||
*/
|
||||
# define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002
|
||||
/*
|
||||
* Indicates that the control command takes *no* input. Ie. the control
|
||||
* command is unparameterised.
|
||||
*/
|
||||
# define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004
|
||||
/*
|
||||
* Indicates that the control command is internal. This control command won't
|
||||
* be shown in any output, and is only usable through the ENGINE_ctrl_cmd()
|
||||
* function.
|
||||
*/
|
||||
# define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008
|
||||
|
||||
/*
|
||||
* NB: These 3 control commands are deprecated and should not be used.
|
||||
* ENGINEs relying on these commands should compile conditional support for
|
||||
* compatibility (eg. if these symbols are defined) but should also migrate
|
||||
* the same functionality to their own ENGINE-specific control functions that
|
||||
* can be "discovered" by calling applications. The fact these control
|
||||
* commands wouldn't be "executable" (ie. usable by text-based config)
|
||||
* doesn't change the fact that application code can find and use them
|
||||
* without requiring per-ENGINE hacking.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These flags are used to tell the ctrl function what should be done. All
|
||||
* command numbers are shared between all engines, even if some don't make
|
||||
* sense to some engines. In such a case, they do nothing but return the
|
||||
* error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED.
|
||||
*/
|
||||
# define ENGINE_CTRL_SET_LOGSTREAM 1
|
||||
# define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2
|
||||
# define ENGINE_CTRL_HUP 3/* Close and reinitialise
|
||||
* any handles/connections
|
||||
* etc. */
|
||||
# define ENGINE_CTRL_SET_USER_INTERFACE 4/* Alternative to callback */
|
||||
# define ENGINE_CTRL_SET_CALLBACK_DATA 5/* User-specific data, used
|
||||
* when calling the password
|
||||
* callback and the user
|
||||
* interface */
|
||||
# define ENGINE_CTRL_LOAD_CONFIGURATION 6/* Load a configuration,
|
||||
* given a string that
|
||||
* represents a file name
|
||||
* or so */
|
||||
# define ENGINE_CTRL_LOAD_SECTION 7/* Load data from a given
|
||||
* section in the already
|
||||
* loaded configuration */
|
||||
|
||||
/*
|
||||
* These control commands allow an application to deal with an arbitrary
|
||||
* engine in a dynamic way. Warn: Negative return values indicate errors FOR
|
||||
* THESE COMMANDS because zero is used to indicate 'end-of-list'. Other
|
||||
* commands, including ENGINE-specific command types, return zero for an
|
||||
* error. An ENGINE can choose to implement these ctrl functions, and can
|
||||
* internally manage things however it chooses - it does so by setting the
|
||||
* ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise
|
||||
* the ENGINE_ctrl() code handles this on the ENGINE's behalf using the
|
||||
* cmd_defns data (set using ENGINE_set_cmd_defns()). This means an ENGINE's
|
||||
* ctrl() handler need only implement its own commands - the above "meta"
|
||||
* commands will be taken care of.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not",
|
||||
* then all the remaining control commands will return failure, so it is
|
||||
* worth checking this first if the caller is trying to "discover" the
|
||||
* engine's capabilities and doesn't want errors generated unnecessarily.
|
||||
*/
|
||||
# define ENGINE_CTRL_HAS_CTRL_FUNCTION 10
|
||||
/*
|
||||
* Returns a positive command number for the first command supported by the
|
||||
* engine. Returns zero if no ctrl commands are supported.
|
||||
*/
|
||||
# define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11
|
||||
/*
|
||||
* The 'long' argument specifies a command implemented by the engine, and the
|
||||
* return value is the next command supported, or zero if there are no more.
|
||||
*/
|
||||
# define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12
|
||||
/*
|
||||
* The 'void*' argument is a command name (cast from 'const char *'), and the
|
||||
* return value is the command that corresponds to it.
|
||||
*/
|
||||
# define ENGINE_CTRL_GET_CMD_FROM_NAME 13
|
||||
/*
|
||||
* The next two allow a command to be converted into its corresponding string
|
||||
* form. In each case, the 'long' argument supplies the command. In the
|
||||
* NAME_LEN case, the return value is the length of the command name (not
|
||||
* counting a trailing EOL). In the NAME case, the 'void*' argument must be a
|
||||
* string buffer large enough, and it will be populated with the name of the
|
||||
* command (WITH a trailing EOL).
|
||||
*/
|
||||
# define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14
|
||||
# define ENGINE_CTRL_GET_NAME_FROM_CMD 15
|
||||
/* The next two are similar but give a "short description" of a command. */
|
||||
# define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16
|
||||
# define ENGINE_CTRL_GET_DESC_FROM_CMD 17
|
||||
/*
|
||||
* With this command, the return value is the OR'd combination of
|
||||
* ENGINE_CMD_FLAG_*** values that indicate what kind of input a given
|
||||
* engine-specific ctrl command expects.
|
||||
*/
|
||||
# define ENGINE_CTRL_GET_CMD_FLAGS 18
|
||||
|
||||
/*
|
||||
* ENGINE implementations should start the numbering of their own control
|
||||
* commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc).
|
||||
*/
|
||||
# define ENGINE_CMD_BASE 200
|
||||
|
||||
/*
|
||||
* NB: These 2 nCipher "chil" control commands are deprecated, and their
|
||||
* functionality is now available through ENGINE-specific control commands
|
||||
* (exposed through the above-mentioned 'CMD'-handling). Code using these 2
|
||||
* commands should be migrated to the more general command handling before
|
||||
* these are removed.
|
||||
*/
|
||||
|
||||
/* Flags specific to the nCipher "chil" engine */
|
||||
# define ENGINE_CTRL_CHIL_SET_FORKCHECK 100
|
||||
/*
|
||||
* Depending on the value of the (long)i argument, this sets or
|
||||
* unsets the SimpleForkCheck flag in the CHIL API to enable or
|
||||
* disable checking and workarounds for applications that fork().
|
||||
*/
|
||||
# define ENGINE_CTRL_CHIL_NO_LOCKING 101
|
||||
/*
|
||||
* This prevents the initialisation function from providing mutex
|
||||
* callbacks to the nCipher library.
|
||||
*/
|
||||
|
||||
/*
|
||||
* If an ENGINE supports its own specific control commands and wishes the
|
||||
* framework to handle the above 'ENGINE_CMD_***'-manipulation commands on
|
||||
* its behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN
|
||||
* entries to ENGINE_set_cmd_defns(). It should also implement a ctrl()
|
||||
* handler that supports the stated commands (ie. the "cmd_num" entries as
|
||||
* described by the array). NB: The array must be ordered in increasing order
|
||||
* of cmd_num. "null-terminated" means that the last ENGINE_CMD_DEFN element
|
||||
* has cmd_num set to zero and/or cmd_name set to NULL.
|
||||
*/
|
||||
typedef struct ENGINE_CMD_DEFN_st {
|
||||
unsigned int cmd_num; /* The command number */
|
||||
const char *cmd_name; /* The command name itself */
|
||||
const char *cmd_desc; /* A short description of the command */
|
||||
unsigned int cmd_flags; /* The input the command expects */
|
||||
} ENGINE_CMD_DEFN;
|
||||
|
||||
/* Generic function pointer */
|
||||
typedef int (*ENGINE_GEN_FUNC_PTR) (void);
|
||||
/* Generic function pointer taking no arguments */
|
||||
typedef int (*ENGINE_GEN_INT_FUNC_PTR) (ENGINE *);
|
||||
/* Specific control function pointer */
|
||||
typedef int (*ENGINE_CTRL_FUNC_PTR) (ENGINE *, int, long, void *,
|
||||
void (*f) (void));
|
||||
/* Generic load_key function pointer */
|
||||
typedef EVP_PKEY *(*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *,
|
||||
UI_METHOD *ui_method,
|
||||
void *callback_data);
|
||||
typedef int (*ENGINE_SSL_CLIENT_CERT_PTR) (ENGINE *, SSL *ssl,
|
||||
STACK_OF(X509_NAME) *ca_dn,
|
||||
X509 **pcert, EVP_PKEY **pkey,
|
||||
STACK_OF(X509) **pother,
|
||||
UI_METHOD *ui_method,
|
||||
void *callback_data);
|
||||
/*-
|
||||
* These callback types are for an ENGINE's handler for cipher and digest logic.
|
||||
* These handlers have these prototypes;
|
||||
* int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid);
|
||||
* int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid);
|
||||
* Looking at how to implement these handlers in the case of cipher support, if
|
||||
* the framework wants the EVP_CIPHER for 'nid', it will call;
|
||||
* foo(e, &p_evp_cipher, NULL, nid); (return zero for failure)
|
||||
* If the framework wants a list of supported 'nid's, it will call;
|
||||
* foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error)
|
||||
*/
|
||||
/*
|
||||
* Returns to a pointer to the array of supported cipher 'nid's. If the
|
||||
* second parameter is non-NULL it is set to the size of the returned array.
|
||||
*/
|
||||
typedef int (*ENGINE_CIPHERS_PTR) (ENGINE *, const EVP_CIPHER **,
|
||||
const int **, int);
|
||||
typedef int (*ENGINE_DIGESTS_PTR) (ENGINE *, const EVP_MD **, const int **,
|
||||
int);
|
||||
typedef int (*ENGINE_PKEY_METHS_PTR) (ENGINE *, EVP_PKEY_METHOD **,
|
||||
const int **, int);
|
||||
typedef int (*ENGINE_PKEY_ASN1_METHS_PTR) (ENGINE *, EVP_PKEY_ASN1_METHOD **,
|
||||
const int **, int);
|
||||
/*
|
||||
* STRUCTURE functions ... all of these functions deal with pointers to
|
||||
* ENGINE structures where the pointers have a "structural reference". This
|
||||
* means that their reference is to allowed access to the structure but it
|
||||
* does not imply that the structure is functional. To simply increment or
|
||||
* decrement the structural reference count, use ENGINE_by_id and
|
||||
* ENGINE_free. NB: This is not required when iterating using ENGINE_get_next
|
||||
* as it will automatically decrement the structural reference count of the
|
||||
* "current" ENGINE and increment the structural reference count of the
|
||||
* ENGINE it returns (unless it is NULL).
|
||||
*/
|
||||
|
||||
/* Get the first/last "ENGINE" type available. */
|
||||
ENGINE *ENGINE_get_first(void);
|
||||
ENGINE *ENGINE_get_last(void);
|
||||
/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */
|
||||
ENGINE *ENGINE_get_next(ENGINE *e);
|
||||
ENGINE *ENGINE_get_prev(ENGINE *e);
|
||||
/* Add another "ENGINE" type into the array. */
|
||||
int ENGINE_add(ENGINE *e);
|
||||
/* Remove an existing "ENGINE" type from the array. */
|
||||
int ENGINE_remove(ENGINE *e);
|
||||
/* Retrieve an engine from the list by its unique "id" value. */
|
||||
ENGINE *ENGINE_by_id(const char *id);
|
||||
/* Add all the built-in engines. */
|
||||
void ENGINE_load_openssl(void);
|
||||
void ENGINE_load_dynamic(void);
|
||||
# ifndef OPENSSL_NO_STATIC_ENGINE
|
||||
void ENGINE_load_4758cca(void);
|
||||
void ENGINE_load_aep(void);
|
||||
void ENGINE_load_atalla(void);
|
||||
void ENGINE_load_chil(void);
|
||||
void ENGINE_load_cswift(void);
|
||||
void ENGINE_load_nuron(void);
|
||||
void ENGINE_load_sureware(void);
|
||||
void ENGINE_load_ubsec(void);
|
||||
void ENGINE_load_padlock(void);
|
||||
void ENGINE_load_capi(void);
|
||||
# ifndef OPENSSL_NO_GMP
|
||||
void ENGINE_load_gmp(void);
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_GOST
|
||||
void ENGINE_load_gost(void);
|
||||
# endif
|
||||
# endif
|
||||
void ENGINE_load_cryptodev(void);
|
||||
void ENGINE_load_rdrand(void);
|
||||
void ENGINE_load_builtin_engines(void);
|
||||
|
||||
/*
|
||||
* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
|
||||
* "registry" handling.
|
||||
*/
|
||||
unsigned int ENGINE_get_table_flags(void);
|
||||
void ENGINE_set_table_flags(unsigned int flags);
|
||||
|
||||
/*- Manage registration of ENGINEs per "table". For each type, there are 3
|
||||
* functions;
|
||||
* ENGINE_register_***(e) - registers the implementation from 'e' (if it has one)
|
||||
* ENGINE_unregister_***(e) - unregister the implementation from 'e'
|
||||
* ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list
|
||||
* Cleanup is automatically registered from each table when required, so
|
||||
* ENGINE_cleanup() will reverse any "register" operations.
|
||||
*/
|
||||
|
||||
int ENGINE_register_RSA(ENGINE *e);
|
||||
void ENGINE_unregister_RSA(ENGINE *e);
|
||||
void ENGINE_register_all_RSA(void);
|
||||
|
||||
int ENGINE_register_DSA(ENGINE *e);
|
||||
void ENGINE_unregister_DSA(ENGINE *e);
|
||||
void ENGINE_register_all_DSA(void);
|
||||
|
||||
int ENGINE_register_ECDH(ENGINE *e);
|
||||
void ENGINE_unregister_ECDH(ENGINE *e);
|
||||
void ENGINE_register_all_ECDH(void);
|
||||
|
||||
int ENGINE_register_ECDSA(ENGINE *e);
|
||||
void ENGINE_unregister_ECDSA(ENGINE *e);
|
||||
void ENGINE_register_all_ECDSA(void);
|
||||
|
||||
int ENGINE_register_DH(ENGINE *e);
|
||||
void ENGINE_unregister_DH(ENGINE *e);
|
||||
void ENGINE_register_all_DH(void);
|
||||
|
||||
int ENGINE_register_RAND(ENGINE *e);
|
||||
void ENGINE_unregister_RAND(ENGINE *e);
|
||||
void ENGINE_register_all_RAND(void);
|
||||
|
||||
int ENGINE_register_STORE(ENGINE *e);
|
||||
void ENGINE_unregister_STORE(ENGINE *e);
|
||||
void ENGINE_register_all_STORE(void);
|
||||
|
||||
int ENGINE_register_ciphers(ENGINE *e);
|
||||
void ENGINE_unregister_ciphers(ENGINE *e);
|
||||
void ENGINE_register_all_ciphers(void);
|
||||
|
||||
int ENGINE_register_digests(ENGINE *e);
|
||||
void ENGINE_unregister_digests(ENGINE *e);
|
||||
void ENGINE_register_all_digests(void);
|
||||
|
||||
int ENGINE_register_pkey_meths(ENGINE *e);
|
||||
void ENGINE_unregister_pkey_meths(ENGINE *e);
|
||||
void ENGINE_register_all_pkey_meths(void);
|
||||
|
||||
int ENGINE_register_pkey_asn1_meths(ENGINE *e);
|
||||
void ENGINE_unregister_pkey_asn1_meths(ENGINE *e);
|
||||
void ENGINE_register_all_pkey_asn1_meths(void);
|
||||
|
||||
/*
|
||||
* These functions register all support from the above categories. Note, use
|
||||
* of these functions can result in static linkage of code your application
|
||||
* may not need. If you only need a subset of functionality, consider using
|
||||
* more selective initialisation.
|
||||
*/
|
||||
int ENGINE_register_complete(ENGINE *e);
|
||||
int ENGINE_register_all_complete(void);
|
||||
|
||||
/*
|
||||
* Send parametrised control commands to the engine. The possibilities to
|
||||
* send down an integer, a pointer to data or a function pointer are
|
||||
* provided. Any of the parameters may or may not be NULL, depending on the
|
||||
* command number. In actuality, this function only requires a structural
|
||||
* (rather than functional) reference to an engine, but many control commands
|
||||
* may require the engine be functional. The caller should be aware of trying
|
||||
* commands that require an operational ENGINE, and only use functional
|
||||
* references in such situations.
|
||||
*/
|
||||
int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void));
|
||||
|
||||
/*
|
||||
* This function tests if an ENGINE-specific command is usable as a
|
||||
* "setting". Eg. in an application's config file that gets processed through
|
||||
* ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to
|
||||
* ENGINE_ctrl_cmd_string(), only ENGINE_ctrl().
|
||||
*/
|
||||
int ENGINE_cmd_is_executable(ENGINE *e, int cmd);
|
||||
|
||||
/*
|
||||
* This function works like ENGINE_ctrl() with the exception of taking a
|
||||
* command name instead of a command number, and can handle optional
|
||||
* commands. See the comment on ENGINE_ctrl_cmd_string() for an explanation
|
||||
* on how to use the cmd_name and cmd_optional.
|
||||
*/
|
||||
int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,
|
||||
long i, void *p, void (*f) (void), int cmd_optional);
|
||||
|
||||
/*
|
||||
* This function passes a command-name and argument to an ENGINE. The
|
||||
* cmd_name is converted to a command number and the control command is
|
||||
* called using 'arg' as an argument (unless the ENGINE doesn't support such
|
||||
* a command, in which case no control command is called). The command is
|
||||
* checked for input flags, and if necessary the argument will be converted
|
||||
* to a numeric value. If cmd_optional is non-zero, then if the ENGINE
|
||||
* doesn't support the given cmd_name the return value will be success
|
||||
* anyway. This function is intended for applications to use so that users
|
||||
* (or config files) can supply engine-specific config data to the ENGINE at
|
||||
* run-time to control behaviour of specific engines. As such, it shouldn't
|
||||
* be used for calling ENGINE_ctrl() functions that return data, deal with
|
||||
* binary data, or that are otherwise supposed to be used directly through
|
||||
* ENGINE_ctrl() in application code. Any "return" data from an ENGINE_ctrl()
|
||||
* operation in this function will be lost - the return value is interpreted
|
||||
* as failure if the return value is zero, success otherwise, and this
|
||||
* function returns a boolean value as a result. In other words, vendors of
|
||||
* 'ENGINE'-enabled devices should write ENGINE implementations with
|
||||
* parameterisations that work in this scheme, so that compliant ENGINE-based
|
||||
* applications can work consistently with the same configuration for the
|
||||
* same ENGINE-enabled devices, across applications.
|
||||
*/
|
||||
int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
|
||||
int cmd_optional);
|
||||
|
||||
/*
|
||||
* These functions are useful for manufacturing new ENGINE structures. They
|
||||
* don't address reference counting at all - one uses them to populate an
|
||||
* ENGINE structure with personalised implementations of things prior to
|
||||
* using it directly or adding it to the builtin ENGINE list in OpenSSL.
|
||||
* These are also here so that the ENGINE structure doesn't have to be
|
||||
* exposed and break binary compatibility!
|
||||
*/
|
||||
ENGINE *ENGINE_new(void);
|
||||
int ENGINE_free(ENGINE *e);
|
||||
int ENGINE_up_ref(ENGINE *e);
|
||||
int ENGINE_set_id(ENGINE *e, const char *id);
|
||||
int ENGINE_set_name(ENGINE *e, const char *name);
|
||||
int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
|
||||
int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth);
|
||||
int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth);
|
||||
int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth);
|
||||
int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth);
|
||||
int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);
|
||||
int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth);
|
||||
int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f);
|
||||
int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f);
|
||||
int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f);
|
||||
int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f);
|
||||
int ENGINE_set_load_privkey_function(ENGINE *e,
|
||||
ENGINE_LOAD_KEY_PTR loadpriv_f);
|
||||
int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f);
|
||||
int ENGINE_set_load_ssl_client_cert_function(ENGINE *e,
|
||||
ENGINE_SSL_CLIENT_CERT_PTR
|
||||
loadssl_f);
|
||||
int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f);
|
||||
int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f);
|
||||
int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f);
|
||||
int ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f);
|
||||
int ENGINE_set_flags(ENGINE *e, int flags);
|
||||
int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns);
|
||||
/* These functions allow control over any per-structure ENGINE data. */
|
||||
int ENGINE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
|
||||
CRYPTO_EX_dup *dup_func,
|
||||
CRYPTO_EX_free *free_func);
|
||||
int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg);
|
||||
void *ENGINE_get_ex_data(const ENGINE *e, int idx);
|
||||
|
||||
/*
|
||||
* This function cleans up anything that needs it. Eg. the ENGINE_add()
|
||||
* function automatically ensures the list cleanup function is registered to
|
||||
* be called from ENGINE_cleanup(). Similarly, all ENGINE_register_***
|
||||
* functions ensure ENGINE_cleanup() will clean up after them.
|
||||
*/
|
||||
void ENGINE_cleanup(void);
|
||||
|
||||
/*
|
||||
* These return values from within the ENGINE structure. These can be useful
|
||||
* with functional references as well as structural references - it depends
|
||||
* which you obtained. Using the result for functional purposes if you only
|
||||
* obtained a structural reference may be problematic!
|
||||
*/
|
||||
const char *ENGINE_get_id(const ENGINE *e);
|
||||
const char *ENGINE_get_name(const ENGINE *e);
|
||||
const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e);
|
||||
const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e);
|
||||
const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e);
|
||||
const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e);
|
||||
const DH_METHOD *ENGINE_get_DH(const ENGINE *e);
|
||||
const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e);
|
||||
const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e);
|
||||
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e);
|
||||
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e);
|
||||
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e);
|
||||
ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e);
|
||||
ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e);
|
||||
ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e);
|
||||
ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE
|
||||
*e);
|
||||
ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e);
|
||||
ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e);
|
||||
ENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e);
|
||||
ENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths(const ENGINE *e);
|
||||
const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid);
|
||||
const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid);
|
||||
const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid);
|
||||
const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid);
|
||||
const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e,
|
||||
const char *str,
|
||||
int len);
|
||||
const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe,
|
||||
const char *str,
|
||||
int len);
|
||||
const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e);
|
||||
int ENGINE_get_flags(const ENGINE *e);
|
||||
|
||||
/*
|
||||
* FUNCTIONAL functions. These functions deal with ENGINE structures that
|
||||
* have (or will) be initialised for use. Broadly speaking, the structural
|
||||
* functions are useful for iterating the list of available engine types,
|
||||
* creating new engine types, and other "list" operations. These functions
|
||||
* actually deal with ENGINEs that are to be used. As such these functions
|
||||
* can fail (if applicable) when particular engines are unavailable - eg. if
|
||||
* a hardware accelerator is not attached or not functioning correctly. Each
|
||||
* ENGINE has 2 reference counts; structural and functional. Every time a
|
||||
* functional reference is obtained or released, a corresponding structural
|
||||
* reference is automatically obtained or released too.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Initialise a engine type for use (or up its reference count if it's
|
||||
* already in use). This will fail if the engine is not currently operational
|
||||
* and cannot initialise.
|
||||
*/
|
||||
int ENGINE_init(ENGINE *e);
|
||||
/*
|
||||
* Free a functional reference to a engine type. This does not require a
|
||||
* corresponding call to ENGINE_free as it also releases a structural
|
||||
* reference.
|
||||
*/
|
||||
int ENGINE_finish(ENGINE *e);
|
||||
|
||||
/*
|
||||
* The following functions handle keys that are stored in some secondary
|
||||
* location, handled by the engine. The storage may be on a card or
|
||||
* whatever.
|
||||
*/
|
||||
EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id,
|
||||
UI_METHOD *ui_method, void *callback_data);
|
||||
EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id,
|
||||
UI_METHOD *ui_method, void *callback_data);
|
||||
int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s,
|
||||
STACK_OF(X509_NAME) *ca_dn, X509 **pcert,
|
||||
EVP_PKEY **ppkey, STACK_OF(X509) **pother,
|
||||
UI_METHOD *ui_method, void *callback_data);
|
||||
|
||||
/*
|
||||
* This returns a pointer for the current ENGINE structure that is (by
|
||||
* default) performing any RSA operations. The value returned is an
|
||||
* incremented reference, so it should be free'd (ENGINE_finish) before it is
|
||||
* discarded.
|
||||
*/
|
||||
ENGINE *ENGINE_get_default_RSA(void);
|
||||
/* Same for the other "methods" */
|
||||
ENGINE *ENGINE_get_default_DSA(void);
|
||||
ENGINE *ENGINE_get_default_ECDH(void);
|
||||
ENGINE *ENGINE_get_default_ECDSA(void);
|
||||
ENGINE *ENGINE_get_default_DH(void);
|
||||
ENGINE *ENGINE_get_default_RAND(void);
|
||||
/*
|
||||
* These functions can be used to get a functional reference to perform
|
||||
* ciphering or digesting corresponding to "nid".
|
||||
*/
|
||||
ENGINE *ENGINE_get_cipher_engine(int nid);
|
||||
ENGINE *ENGINE_get_digest_engine(int nid);
|
||||
ENGINE *ENGINE_get_pkey_meth_engine(int nid);
|
||||
ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid);
|
||||
|
||||
/*
|
||||
* This sets a new default ENGINE structure for performing RSA operations. If
|
||||
* the result is non-zero (success) then the ENGINE structure will have had
|
||||
* its reference count up'd so the caller should still free their own
|
||||
* reference 'e'.
|
||||
*/
|
||||
int ENGINE_set_default_RSA(ENGINE *e);
|
||||
int ENGINE_set_default_string(ENGINE *e, const char *def_list);
|
||||
/* Same for the other "methods" */
|
||||
int ENGINE_set_default_DSA(ENGINE *e);
|
||||
int ENGINE_set_default_ECDH(ENGINE *e);
|
||||
int ENGINE_set_default_ECDSA(ENGINE *e);
|
||||
int ENGINE_set_default_DH(ENGINE *e);
|
||||
int ENGINE_set_default_RAND(ENGINE *e);
|
||||
int ENGINE_set_default_ciphers(ENGINE *e);
|
||||
int ENGINE_set_default_digests(ENGINE *e);
|
||||
int ENGINE_set_default_pkey_meths(ENGINE *e);
|
||||
int ENGINE_set_default_pkey_asn1_meths(ENGINE *e);
|
||||
|
||||
/*
|
||||
* The combination "set" - the flags are bitwise "OR"d from the
|
||||
* ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()"
|
||||
* function, this function can result in unnecessary static linkage. If your
|
||||
* application requires only specific functionality, consider using more
|
||||
* selective functions.
|
||||
*/
|
||||
int ENGINE_set_default(ENGINE *e, unsigned int flags);
|
||||
|
||||
void ENGINE_add_conf_module(void);
|
||||
|
||||
/* Deprecated functions ... */
|
||||
/* int ENGINE_clear_defaults(void); */
|
||||
|
||||
/**************************/
|
||||
/* DYNAMIC ENGINE SUPPORT */
|
||||
/**************************/
|
||||
|
||||
/* Binary/behaviour compatibility levels */
|
||||
# define OSSL_DYNAMIC_VERSION (unsigned long)0x00020000
|
||||
/*
|
||||
* Binary versions older than this are too old for us (whether we're a loader
|
||||
* or a loadee)
|
||||
*/
|
||||
# define OSSL_DYNAMIC_OLDEST (unsigned long)0x00020000
|
||||
|
||||
/*
|
||||
* When compiling an ENGINE entirely as an external shared library, loadable
|
||||
* by the "dynamic" ENGINE, these types are needed. The 'dynamic_fns'
|
||||
* structure type provides the calling application's (or library's) error
|
||||
* functionality and memory management function pointers to the loaded
|
||||
* library. These should be used/set in the loaded library code so that the
|
||||
* loading application's 'state' will be used/changed in all operations. The
|
||||
* 'static_state' pointer allows the loaded library to know if it shares the
|
||||
* same static data as the calling application (or library), and thus whether
|
||||
* these callbacks need to be set or not.
|
||||
*/
|
||||
typedef void *(*dyn_MEM_malloc_cb) (size_t);
|
||||
typedef void *(*dyn_MEM_realloc_cb) (void *, size_t);
|
||||
typedef void (*dyn_MEM_free_cb) (void *);
|
||||
typedef struct st_dynamic_MEM_fns {
|
||||
dyn_MEM_malloc_cb malloc_cb;
|
||||
dyn_MEM_realloc_cb realloc_cb;
|
||||
dyn_MEM_free_cb free_cb;
|
||||
} dynamic_MEM_fns;
|
||||
/*
|
||||
* FIXME: Perhaps the memory and locking code (crypto.h) should declare and
|
||||
* use these types so we (and any other dependant code) can simplify a bit??
|
||||
*/
|
||||
typedef void (*dyn_lock_locking_cb) (int, int, const char *, int);
|
||||
typedef int (*dyn_lock_add_lock_cb) (int *, int, int, const char *, int);
|
||||
typedef struct CRYPTO_dynlock_value *(*dyn_dynlock_create_cb) (const char *,
|
||||
int);
|
||||
typedef void (*dyn_dynlock_lock_cb) (int, struct CRYPTO_dynlock_value *,
|
||||
const char *, int);
|
||||
typedef void (*dyn_dynlock_destroy_cb) (struct CRYPTO_dynlock_value *,
|
||||
const char *, int);
|
||||
typedef struct st_dynamic_LOCK_fns {
|
||||
dyn_lock_locking_cb lock_locking_cb;
|
||||
dyn_lock_add_lock_cb lock_add_lock_cb;
|
||||
dyn_dynlock_create_cb dynlock_create_cb;
|
||||
dyn_dynlock_lock_cb dynlock_lock_cb;
|
||||
dyn_dynlock_destroy_cb dynlock_destroy_cb;
|
||||
} dynamic_LOCK_fns;
|
||||
/* The top-level structure */
|
||||
typedef struct st_dynamic_fns {
|
||||
void *static_state;
|
||||
const ERR_FNS *err_fns;
|
||||
const CRYPTO_EX_DATA_IMPL *ex_data_fns;
|
||||
dynamic_MEM_fns mem_fns;
|
||||
dynamic_LOCK_fns lock_fns;
|
||||
} dynamic_fns;
|
||||
|
||||
/*
|
||||
* The version checking function should be of this prototype. NB: The
|
||||
* ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading
|
||||
* code. If this function returns zero, it indicates a (potential) version
|
||||
* incompatibility and the loaded library doesn't believe it can proceed.
|
||||
* Otherwise, the returned value is the (latest) version supported by the
|
||||
* loading library. The loader may still decide that the loaded code's
|
||||
* version is unsatisfactory and could veto the load. The function is
|
||||
* expected to be implemented with the symbol name "v_check", and a default
|
||||
* implementation can be fully instantiated with
|
||||
* IMPLEMENT_DYNAMIC_CHECK_FN().
|
||||
*/
|
||||
typedef unsigned long (*dynamic_v_check_fn) (unsigned long ossl_version);
|
||||
# define IMPLEMENT_DYNAMIC_CHECK_FN() \
|
||||
OPENSSL_EXPORT unsigned long v_check(unsigned long v); \
|
||||
OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \
|
||||
if(v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \
|
||||
return 0; }
|
||||
|
||||
/*
|
||||
* This function is passed the ENGINE structure to initialise with its own
|
||||
* function and command settings. It should not adjust the structural or
|
||||
* functional reference counts. If this function returns zero, (a) the load
|
||||
* will be aborted, (b) the previous ENGINE state will be memcpy'd back onto
|
||||
* the structure, and (c) the shared library will be unloaded. So
|
||||
* implementations should do their own internal cleanup in failure
|
||||
* circumstances otherwise they could leak. The 'id' parameter, if non-NULL,
|
||||
* represents the ENGINE id that the loader is looking for. If this is NULL,
|
||||
* the shared library can choose to return failure or to initialise a
|
||||
* 'default' ENGINE. If non-NULL, the shared library must initialise only an
|
||||
* ENGINE matching the passed 'id'. The function is expected to be
|
||||
* implemented with the symbol name "bind_engine". A standard implementation
|
||||
* can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where the parameter
|
||||
* 'fn' is a callback function that populates the ENGINE structure and
|
||||
* returns an int value (zero for failure). 'fn' should have prototype;
|
||||
* [static] int fn(ENGINE *e, const char *id);
|
||||
*/
|
||||
typedef int (*dynamic_bind_engine) (ENGINE *e, const char *id,
|
||||
const dynamic_fns *fns);
|
||||
# define IMPLEMENT_DYNAMIC_BIND_FN(fn) \
|
||||
OPENSSL_EXPORT \
|
||||
int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \
|
||||
OPENSSL_EXPORT \
|
||||
int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \
|
||||
if(ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \
|
||||
if(!CRYPTO_set_mem_functions(fns->mem_fns.malloc_cb, \
|
||||
fns->mem_fns.realloc_cb, fns->mem_fns.free_cb)) \
|
||||
return 0; \
|
||||
CRYPTO_set_locking_callback(fns->lock_fns.lock_locking_cb); \
|
||||
CRYPTO_set_add_lock_callback(fns->lock_fns.lock_add_lock_cb); \
|
||||
CRYPTO_set_dynlock_create_callback(fns->lock_fns.dynlock_create_cb); \
|
||||
CRYPTO_set_dynlock_lock_callback(fns->lock_fns.dynlock_lock_cb); \
|
||||
CRYPTO_set_dynlock_destroy_callback(fns->lock_fns.dynlock_destroy_cb); \
|
||||
if(!CRYPTO_set_ex_data_implementation(fns->ex_data_fns)) \
|
||||
return 0; \
|
||||
if(!ERR_set_implementation(fns->err_fns)) return 0; \
|
||||
skip_cbs: \
|
||||
if(!fn(e,id)) return 0; \
|
||||
return 1; }
|
||||
|
||||
/*
|
||||
* If the loading application (or library) and the loaded ENGINE library
|
||||
* share the same static data (eg. they're both dynamically linked to the
|
||||
* same libcrypto.so) we need a way to avoid trying to set system callbacks -
|
||||
* this would fail, and for the same reason that it's unnecessary to try. If
|
||||
* the loaded ENGINE has (or gets from through the loader) its own copy of
|
||||
* the libcrypto static data, we will need to set the callbacks. The easiest
|
||||
* way to detect this is to have a function that returns a pointer to some
|
||||
* static data and let the loading application and loaded ENGINE compare
|
||||
* their respective values.
|
||||
*/
|
||||
void *ENGINE_get_static_state(void);
|
||||
|
||||
# if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(HAVE_CRYPTODEV)
|
||||
void ENGINE_setup_bsd_cryptodev(void);
|
||||
# endif
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_ENGINE_strings(void);
|
||||
|
||||
/* Error codes for the ENGINE functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define ENGINE_F_DYNAMIC_CTRL 180
|
||||
# define ENGINE_F_DYNAMIC_GET_DATA_CTX 181
|
||||
# define ENGINE_F_DYNAMIC_LOAD 182
|
||||
# define ENGINE_F_DYNAMIC_SET_DATA_CTX 183
|
||||
# define ENGINE_F_ENGINE_ADD 105
|
||||
# define ENGINE_F_ENGINE_BY_ID 106
|
||||
# define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 170
|
||||
# define ENGINE_F_ENGINE_CTRL 142
|
||||
# define ENGINE_F_ENGINE_CTRL_CMD 178
|
||||
# define ENGINE_F_ENGINE_CTRL_CMD_STRING 171
|
||||
# define ENGINE_F_ENGINE_FINISH 107
|
||||
# define ENGINE_F_ENGINE_FREE_UTIL 108
|
||||
# define ENGINE_F_ENGINE_GET_CIPHER 185
|
||||
# define ENGINE_F_ENGINE_GET_DEFAULT_TYPE 177
|
||||
# define ENGINE_F_ENGINE_GET_DIGEST 186
|
||||
# define ENGINE_F_ENGINE_GET_NEXT 115
|
||||
# define ENGINE_F_ENGINE_GET_PKEY_ASN1_METH 193
|
||||
# define ENGINE_F_ENGINE_GET_PKEY_METH 192
|
||||
# define ENGINE_F_ENGINE_GET_PREV 116
|
||||
# define ENGINE_F_ENGINE_INIT 119
|
||||
# define ENGINE_F_ENGINE_LIST_ADD 120
|
||||
# define ENGINE_F_ENGINE_LIST_REMOVE 121
|
||||
# define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150
|
||||
# define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151
|
||||
# define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT 194
|
||||
# define ENGINE_F_ENGINE_NEW 122
|
||||
# define ENGINE_F_ENGINE_REMOVE 123
|
||||
# define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189
|
||||
# define ENGINE_F_ENGINE_SET_DEFAULT_TYPE 126
|
||||
# define ENGINE_F_ENGINE_SET_ID 129
|
||||
# define ENGINE_F_ENGINE_SET_NAME 130
|
||||
# define ENGINE_F_ENGINE_TABLE_REGISTER 184
|
||||
# define ENGINE_F_ENGINE_UNLOAD_KEY 152
|
||||
# define ENGINE_F_ENGINE_UNLOCKED_FINISH 191
|
||||
# define ENGINE_F_ENGINE_UP_REF 190
|
||||
# define ENGINE_F_INT_CTRL_HELPER 172
|
||||
# define ENGINE_F_INT_ENGINE_CONFIGURE 188
|
||||
# define ENGINE_F_INT_ENGINE_MODULE_INIT 187
|
||||
# define ENGINE_F_LOG_MESSAGE 141
|
||||
|
||||
/* Reason codes. */
|
||||
# define ENGINE_R_ALREADY_LOADED 100
|
||||
# define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 133
|
||||
# define ENGINE_R_CMD_NOT_EXECUTABLE 134
|
||||
# define ENGINE_R_COMMAND_TAKES_INPUT 135
|
||||
# define ENGINE_R_COMMAND_TAKES_NO_INPUT 136
|
||||
# define ENGINE_R_CONFLICTING_ENGINE_ID 103
|
||||
# define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119
|
||||
# define ENGINE_R_DH_NOT_IMPLEMENTED 139
|
||||
# define ENGINE_R_DSA_NOT_IMPLEMENTED 140
|
||||
# define ENGINE_R_DSO_FAILURE 104
|
||||
# define ENGINE_R_DSO_NOT_FOUND 132
|
||||
# define ENGINE_R_ENGINES_SECTION_ERROR 148
|
||||
# define ENGINE_R_ENGINE_CONFIGURATION_ERROR 102
|
||||
# define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105
|
||||
# define ENGINE_R_ENGINE_SECTION_ERROR 149
|
||||
# define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128
|
||||
# define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129
|
||||
# define ENGINE_R_FINISH_FAILED 106
|
||||
# define ENGINE_R_GET_HANDLE_FAILED 107
|
||||
# define ENGINE_R_ID_OR_NAME_MISSING 108
|
||||
# define ENGINE_R_INIT_FAILED 109
|
||||
# define ENGINE_R_INTERNAL_LIST_ERROR 110
|
||||
# define ENGINE_R_INVALID_ARGUMENT 143
|
||||
# define ENGINE_R_INVALID_CMD_NAME 137
|
||||
# define ENGINE_R_INVALID_CMD_NUMBER 138
|
||||
# define ENGINE_R_INVALID_INIT_VALUE 151
|
||||
# define ENGINE_R_INVALID_STRING 150
|
||||
# define ENGINE_R_NOT_INITIALISED 117
|
||||
# define ENGINE_R_NOT_LOADED 112
|
||||
# define ENGINE_R_NO_CONTROL_FUNCTION 120
|
||||
# define ENGINE_R_NO_INDEX 144
|
||||
# define ENGINE_R_NO_LOAD_FUNCTION 125
|
||||
# define ENGINE_R_NO_REFERENCE 130
|
||||
# define ENGINE_R_NO_SUCH_ENGINE 116
|
||||
# define ENGINE_R_NO_UNLOAD_FUNCTION 126
|
||||
# define ENGINE_R_PROVIDE_PARAMETERS 113
|
||||
# define ENGINE_R_RSA_NOT_IMPLEMENTED 141
|
||||
# define ENGINE_R_UNIMPLEMENTED_CIPHER 146
|
||||
# define ENGINE_R_UNIMPLEMENTED_DIGEST 147
|
||||
# define ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD 101
|
||||
# define ENGINE_R_VERSION_INCOMPATIBILITY 145
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,269 +0,0 @@
|
||||
/* crypto/engine/enginetest.c */
|
||||
/*
|
||||
* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
|
||||
* 2000.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifdef OPENSSL_NO_ENGINE
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("No ENGINE support\n");
|
||||
return (0);
|
||||
}
|
||||
#else
|
||||
# include <openssl/buffer.h>
|
||||
# include <openssl/crypto.h>
|
||||
# include <openssl/engine.h>
|
||||
# include <openssl/err.h>
|
||||
|
||||
static void display_engine_list(void)
|
||||
{
|
||||
ENGINE *h;
|
||||
int loop;
|
||||
|
||||
h = ENGINE_get_first();
|
||||
loop = 0;
|
||||
printf("listing available engine types\n");
|
||||
while (h) {
|
||||
printf("engine %i, id = \"%s\", name = \"%s\"\n",
|
||||
loop++, ENGINE_get_id(h), ENGINE_get_name(h));
|
||||
h = ENGINE_get_next(h);
|
||||
}
|
||||
printf("end of list\n");
|
||||
/*
|
||||
* ENGINE_get_first() increases the struct_ref counter, so we must call
|
||||
* ENGINE_free() to decrease it again
|
||||
*/
|
||||
ENGINE_free(h);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
ENGINE *block[512];
|
||||
char buf[256];
|
||||
const char *id, *name;
|
||||
ENGINE *ptr;
|
||||
int loop;
|
||||
int to_return = 1;
|
||||
ENGINE *new_h1 = NULL;
|
||||
ENGINE *new_h2 = NULL;
|
||||
ENGINE *new_h3 = NULL;
|
||||
ENGINE *new_h4 = NULL;
|
||||
|
||||
/* enable memory leak checking unless explicitly disabled */
|
||||
if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL)
|
||||
&& (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off")))) {
|
||||
CRYPTO_malloc_debug_init();
|
||||
CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
|
||||
} else {
|
||||
/* OPENSSL_DEBUG_MEMORY=off */
|
||||
CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
|
||||
}
|
||||
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
memset(block, 0, 512 * sizeof(ENGINE *));
|
||||
if (((new_h1 = ENGINE_new()) == NULL) ||
|
||||
!ENGINE_set_id(new_h1, "test_id0") ||
|
||||
!ENGINE_set_name(new_h1, "First test item") ||
|
||||
((new_h2 = ENGINE_new()) == NULL) ||
|
||||
!ENGINE_set_id(new_h2, "test_id1") ||
|
||||
!ENGINE_set_name(new_h2, "Second test item") ||
|
||||
((new_h3 = ENGINE_new()) == NULL) ||
|
||||
!ENGINE_set_id(new_h3, "test_id2") ||
|
||||
!ENGINE_set_name(new_h3, "Third test item") ||
|
||||
((new_h4 = ENGINE_new()) == NULL) ||
|
||||
!ENGINE_set_id(new_h4, "test_id3") ||
|
||||
!ENGINE_set_name(new_h4, "Fourth test item")) {
|
||||
printf("Couldn't set up test ENGINE structures\n");
|
||||
goto end;
|
||||
}
|
||||
printf("\nenginetest beginning\n\n");
|
||||
display_engine_list();
|
||||
if (!ENGINE_add(new_h1)) {
|
||||
printf("Add failed!\n");
|
||||
goto end;
|
||||
}
|
||||
display_engine_list();
|
||||
ptr = ENGINE_get_first();
|
||||
if (!ENGINE_remove(ptr)) {
|
||||
printf("Remove failed!\n");
|
||||
goto end;
|
||||
}
|
||||
if (ptr)
|
||||
ENGINE_free(ptr);
|
||||
display_engine_list();
|
||||
if (!ENGINE_add(new_h3) || !ENGINE_add(new_h2)) {
|
||||
printf("Add failed!\n");
|
||||
goto end;
|
||||
}
|
||||
display_engine_list();
|
||||
if (!ENGINE_remove(new_h2)) {
|
||||
printf("Remove failed!\n");
|
||||
goto end;
|
||||
}
|
||||
display_engine_list();
|
||||
if (!ENGINE_add(new_h4)) {
|
||||
printf("Add failed!\n");
|
||||
goto end;
|
||||
}
|
||||
display_engine_list();
|
||||
if (ENGINE_add(new_h3)) {
|
||||
printf("Add *should* have failed but didn't!\n");
|
||||
goto end;
|
||||
} else
|
||||
printf("Add that should fail did.\n");
|
||||
ERR_clear_error();
|
||||
if (ENGINE_remove(new_h2)) {
|
||||
printf("Remove *should* have failed but didn't!\n");
|
||||
goto end;
|
||||
} else
|
||||
printf("Remove that should fail did.\n");
|
||||
ERR_clear_error();
|
||||
if (!ENGINE_remove(new_h3)) {
|
||||
printf("Remove failed!\n");
|
||||
goto end;
|
||||
}
|
||||
display_engine_list();
|
||||
if (!ENGINE_remove(new_h4)) {
|
||||
printf("Remove failed!\n");
|
||||
goto end;
|
||||
}
|
||||
display_engine_list();
|
||||
/*
|
||||
* Depending on whether there's any hardware support compiled in, this
|
||||
* remove may be destined to fail.
|
||||
*/
|
||||
ptr = ENGINE_get_first();
|
||||
if (ptr)
|
||||
if (!ENGINE_remove(ptr))
|
||||
printf("Remove failed!i - probably no hardware "
|
||||
"support present.\n");
|
||||
if (ptr)
|
||||
ENGINE_free(ptr);
|
||||
display_engine_list();
|
||||
if (!ENGINE_add(new_h1) || !ENGINE_remove(new_h1)) {
|
||||
printf("Couldn't add and remove to an empty list!\n");
|
||||
goto end;
|
||||
} else
|
||||
printf("Successfully added and removed to an empty list!\n");
|
||||
printf("About to beef up the engine-type list\n");
|
||||
for (loop = 0; loop < 512; loop++) {
|
||||
sprintf(buf, "id%i", loop);
|
||||
id = BUF_strdup(buf);
|
||||
sprintf(buf, "Fake engine type %i", loop);
|
||||
name = BUF_strdup(buf);
|
||||
if (((block[loop] = ENGINE_new()) == NULL) ||
|
||||
!ENGINE_set_id(block[loop], id) ||
|
||||
!ENGINE_set_name(block[loop], name)) {
|
||||
printf("Couldn't create block of ENGINE structures.\n"
|
||||
"I'll probably also core-dump now, damn.\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
for (loop = 0; loop < 512; loop++) {
|
||||
if (!ENGINE_add(block[loop])) {
|
||||
printf("\nAdding stopped at %i, (%s,%s)\n",
|
||||
loop, ENGINE_get_id(block[loop]),
|
||||
ENGINE_get_name(block[loop]));
|
||||
goto cleanup_loop;
|
||||
} else
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
}
|
||||
cleanup_loop:
|
||||
printf("\nAbout to empty the engine-type list\n");
|
||||
while ((ptr = ENGINE_get_first()) != NULL) {
|
||||
if (!ENGINE_remove(ptr)) {
|
||||
printf("\nRemove failed!\n");
|
||||
goto end;
|
||||
}
|
||||
ENGINE_free(ptr);
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
}
|
||||
for (loop = 0; loop < 512; loop++) {
|
||||
OPENSSL_free((void *)ENGINE_get_id(block[loop]));
|
||||
OPENSSL_free((void *)ENGINE_get_name(block[loop]));
|
||||
}
|
||||
printf("\nTests completed happily\n");
|
||||
to_return = 0;
|
||||
end:
|
||||
if (to_return)
|
||||
ERR_print_errors_fp(stderr);
|
||||
if (new_h1)
|
||||
ENGINE_free(new_h1);
|
||||
if (new_h2)
|
||||
ENGINE_free(new_h2);
|
||||
if (new_h3)
|
||||
ENGINE_free(new_h3);
|
||||
if (new_h4)
|
||||
ENGINE_free(new_h4);
|
||||
for (loop = 0; loop < 512; loop++)
|
||||
if (block[loop])
|
||||
ENGINE_free(block[loop]);
|
||||
ENGINE_cleanup();
|
||||
CRYPTO_cleanup_all_ex_data();
|
||||
ERR_free_strings();
|
||||
ERR_remove_thread_state(NULL);
|
||||
CRYPTO_mem_leaks_fp(stderr);
|
||||
return to_return;
|
||||
}
|
||||
#endif
|
||||
@@ -1,60 +1,15 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
#include "asn1_locl.h"
|
||||
#include <openssl/evp.h>
|
||||
#include "internal/asn1_int.h"
|
||||
|
||||
/*
|
||||
* If this symbol is defined then ENGINE_get_pkey_asn1_meth_engine(), the
|
||||
@@ -191,8 +146,8 @@ const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e,
|
||||
nidcount = e->pkey_asn1_meths(e, NULL, &nids, 0);
|
||||
for (i = 0; i < nidcount; i++) {
|
||||
e->pkey_asn1_meths(e, &ameth, NULL, nids[i]);
|
||||
if (((int)strlen(ameth->pem_str) == len) &&
|
||||
!strncasecmp(ameth->pem_str, str, len))
|
||||
if (((int)strlen(ameth->pem_str) == len)
|
||||
&& strncasecmp(ameth->pem_str, str, len) == 0)
|
||||
return ameth;
|
||||
}
|
||||
return NULL;
|
||||
@@ -215,8 +170,8 @@ static void look_str_cb(int nid, STACK_OF(ENGINE) *sk, ENGINE *def, void *arg)
|
||||
ENGINE *e = sk_ENGINE_value(sk, i);
|
||||
EVP_PKEY_ASN1_METHOD *ameth;
|
||||
e->pkey_asn1_meths(e, &ameth, NULL, nid);
|
||||
if (((int)strlen(ameth->pem_str) == lk->len) &&
|
||||
!strncasecmp(ameth->pem_str, lk->str, lk->len)) {
|
||||
if (((int)strlen(ameth->pem_str) == lk->len)
|
||||
&& strncasecmp(ameth->pem_str, lk->str, lk->len) == 0) {
|
||||
lk->e = e;
|
||||
lk->ameth = ameth;
|
||||
return;
|
||||
@@ -233,14 +188,20 @@ const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe,
|
||||
fstr.ameth = NULL;
|
||||
fstr.str = str;
|
||||
fstr.len = len;
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
|
||||
|
||||
if (!RUN_ONCE(&engine_lock_init, do_engine_lock_init)) {
|
||||
ENGINEerr(ENGINE_F_ENGINE_PKEY_ASN1_FIND_STR, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
engine_table_doall(pkey_asn1_meth_table, look_str_cb, &fstr);
|
||||
/* If found obtain a structural reference to engine */
|
||||
if (fstr.e) {
|
||||
fstr.e->struct_ref++;
|
||||
engine_ref_debug(fstr.e, 0, 1)
|
||||
engine_ref_debug(fstr.e, 0, 1);
|
||||
}
|
||||
*pe = fstr.e;
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
return fstr.ameth;
|
||||
}
|
||||
|
||||
@@ -1,66 +1,14 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2000 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
|
||||
/*
|
||||
* If this symbol is defined then ENGINE_get_cipher_engine(), the function
|
||||
* that is used by EVP to hook in cipher code and cache defaults (etc), will
|
||||
* display brief debugging summaries to stderr with the 'nid'.
|
||||
*/
|
||||
/* #define ENGINE_CIPHER_DEBUG */
|
||||
|
||||
static ENGINE_TABLE *cipher_table = NULL;
|
||||
|
||||
void ENGINE_unregister_ciphers(ENGINE *e)
|
||||
|
||||
@@ -1,66 +1,14 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2000 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
|
||||
/*
|
||||
* If this symbol is defined then ENGINE_get_default_DH(), the function that
|
||||
* is used by DH to hook in implementation code and cache defaults (etc),
|
||||
* will display brief debugging summaries to stderr with the 'nid'.
|
||||
*/
|
||||
/* #define ENGINE_DH_DEBUG */
|
||||
|
||||
static ENGINE_TABLE *dh_table = NULL;
|
||||
static const int dummy_nid = 1;
|
||||
|
||||
|
||||
@@ -1,66 +1,14 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2000 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
|
||||
/*
|
||||
* If this symbol is defined then ENGINE_get_digest_engine(), the function
|
||||
* that is used by EVP to hook in digest code and cache defaults (etc), will
|
||||
* display brief debugging summaries to stderr with the 'nid'.
|
||||
*/
|
||||
/* #define ENGINE_DIGEST_DEBUG */
|
||||
|
||||
static ENGINE_TABLE *digest_table = NULL;
|
||||
|
||||
void ENGINE_unregister_digests(ENGINE *e)
|
||||
|
||||
@@ -1,66 +1,14 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2000 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
|
||||
/*
|
||||
* If this symbol is defined then ENGINE_get_default_DSA(), the function that
|
||||
* is used by DSA to hook in implementation code and cache defaults (etc),
|
||||
* will display brief debugging summaries to stderr with the 'nid'.
|
||||
*/
|
||||
/* #define ENGINE_DSA_DEBUG */
|
||||
|
||||
static ENGINE_TABLE *dsa_table = NULL;
|
||||
static const int dummy_nid = 1;
|
||||
|
||||
|
||||
@@ -1,139 +0,0 @@
|
||||
/* crypto/engine/tb_ecdh.c */
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
*
|
||||
* The Elliptic Curve Public-Key Crypto Library (ECC Code) included
|
||||
* herein is developed by SUN MICROSYSTEMS, INC., and is contributed
|
||||
* to the OpenSSL project.
|
||||
*
|
||||
* The ECC Code is licensed pursuant to the OpenSSL open source
|
||||
* license provided below.
|
||||
*
|
||||
* The ECDH engine software is originally written by Nils Gura and
|
||||
* Douglas Stebila of Sun Microsystems Laboratories.
|
||||
*
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
|
||||
/*
|
||||
* If this symbol is defined then ENGINE_get_default_ECDH(), the function
|
||||
* that is used by ECDH to hook in implementation code and cache defaults
|
||||
* (etc), will display brief debugging summaries to stderr with the 'nid'.
|
||||
*/
|
||||
/* #define ENGINE_ECDH_DEBUG */
|
||||
|
||||
static ENGINE_TABLE *ecdh_table = NULL;
|
||||
static const int dummy_nid = 1;
|
||||
|
||||
void ENGINE_unregister_ECDH(ENGINE *e)
|
||||
{
|
||||
engine_table_unregister(&ecdh_table, e);
|
||||
}
|
||||
|
||||
static void engine_unregister_all_ECDH(void)
|
||||
{
|
||||
engine_table_cleanup(&ecdh_table);
|
||||
}
|
||||
|
||||
int ENGINE_register_ECDH(ENGINE *e)
|
||||
{
|
||||
if (e->ecdh_meth)
|
||||
return engine_table_register(&ecdh_table,
|
||||
engine_unregister_all_ECDH, e,
|
||||
&dummy_nid, 1, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ENGINE_register_all_ECDH()
|
||||
{
|
||||
ENGINE *e;
|
||||
|
||||
for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
|
||||
ENGINE_register_ECDH(e);
|
||||
}
|
||||
|
||||
int ENGINE_set_default_ECDH(ENGINE *e)
|
||||
{
|
||||
if (e->ecdh_meth)
|
||||
return engine_table_register(&ecdh_table,
|
||||
engine_unregister_all_ECDH, e,
|
||||
&dummy_nid, 1, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Exposed API function to get a functional reference from the implementation
|
||||
* table (ie. try to get a functional reference from the tabled structural
|
||||
* references).
|
||||
*/
|
||||
ENGINE *ENGINE_get_default_ECDH(void)
|
||||
{
|
||||
return engine_table_select(&ecdh_table, dummy_nid);
|
||||
}
|
||||
|
||||
/* Obtains an ECDH implementation from an ENGINE functional reference */
|
||||
const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e)
|
||||
{
|
||||
return e->ecdh_meth;
|
||||
}
|
||||
|
||||
/* Sets an ECDH implementation in an ENGINE structure */
|
||||
int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *ecdh_meth)
|
||||
{
|
||||
e->ecdh_meth = ecdh_meth;
|
||||
return 1;
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
|
||||
/*
|
||||
* If this symbol is defined then ENGINE_get_default_ECDSA(), the function
|
||||
* that is used by ECDSA to hook in implementation code and cache defaults
|
||||
* (etc), will display brief debugging summaries to stderr with the 'nid'.
|
||||
*/
|
||||
/* #define ENGINE_ECDSA_DEBUG */
|
||||
|
||||
static ENGINE_TABLE *ecdsa_table = NULL;
|
||||
static const int dummy_nid = 1;
|
||||
|
||||
void ENGINE_unregister_ECDSA(ENGINE *e)
|
||||
{
|
||||
engine_table_unregister(&ecdsa_table, e);
|
||||
}
|
||||
|
||||
static void engine_unregister_all_ECDSA(void)
|
||||
{
|
||||
engine_table_cleanup(&ecdsa_table);
|
||||
}
|
||||
|
||||
int ENGINE_register_ECDSA(ENGINE *e)
|
||||
{
|
||||
if (e->ecdsa_meth)
|
||||
return engine_table_register(&ecdsa_table,
|
||||
engine_unregister_all_ECDSA, e,
|
||||
&dummy_nid, 1, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ENGINE_register_all_ECDSA()
|
||||
{
|
||||
ENGINE *e;
|
||||
|
||||
for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
|
||||
ENGINE_register_ECDSA(e);
|
||||
}
|
||||
|
||||
int ENGINE_set_default_ECDSA(ENGINE *e)
|
||||
{
|
||||
if (e->ecdsa_meth)
|
||||
return engine_table_register(&ecdsa_table,
|
||||
engine_unregister_all_ECDSA, e,
|
||||
&dummy_nid, 1, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Exposed API function to get a functional reference from the implementation
|
||||
* table (ie. try to get a functional reference from the tabled structural
|
||||
* references).
|
||||
*/
|
||||
ENGINE *ENGINE_get_default_ECDSA(void)
|
||||
{
|
||||
return engine_table_select(&ecdsa_table, dummy_nid);
|
||||
}
|
||||
|
||||
/* Obtains an ECDSA implementation from an ENGINE functional reference */
|
||||
const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e)
|
||||
{
|
||||
return e->ecdsa_meth;
|
||||
}
|
||||
|
||||
/* Sets an ECDSA implementation in an ENGINE structure */
|
||||
int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *ecdsa_meth)
|
||||
{
|
||||
e->ecdsa_meth = ecdsa_meth;
|
||||
return 1;
|
||||
}
|
||||
72
crypto/engine/tb_eckey.c
Normal file
72
crypto/engine/tb_eckey.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
|
||||
static ENGINE_TABLE *dh_table = NULL;
|
||||
static const int dummy_nid = 1;
|
||||
|
||||
void ENGINE_unregister_EC(ENGINE *e)
|
||||
{
|
||||
engine_table_unregister(&dh_table, e);
|
||||
}
|
||||
|
||||
static void engine_unregister_all_EC(void)
|
||||
{
|
||||
engine_table_cleanup(&dh_table);
|
||||
}
|
||||
|
||||
int ENGINE_register_EC(ENGINE *e)
|
||||
{
|
||||
if (e->ec_meth != NULL)
|
||||
return engine_table_register(&dh_table,
|
||||
engine_unregister_all_EC, e, &dummy_nid,
|
||||
1, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ENGINE_register_all_EC()
|
||||
{
|
||||
ENGINE *e;
|
||||
|
||||
for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
|
||||
ENGINE_register_EC(e);
|
||||
}
|
||||
|
||||
int ENGINE_set_default_EC(ENGINE *e)
|
||||
{
|
||||
if (e->ec_meth != NULL)
|
||||
return engine_table_register(&dh_table,
|
||||
engine_unregister_all_EC, e, &dummy_nid,
|
||||
1, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Exposed API function to get a functional reference from the implementation
|
||||
* table (ie. try to get a functional reference from the tabled structural
|
||||
* references).
|
||||
*/
|
||||
ENGINE *ENGINE_get_default_EC(void)
|
||||
{
|
||||
return engine_table_select(&dh_table, dummy_nid);
|
||||
}
|
||||
|
||||
/* Obtains an EC_KEY implementation from an ENGINE functional reference */
|
||||
const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e)
|
||||
{
|
||||
return e->ec_meth;
|
||||
}
|
||||
|
||||
/* Sets an EC_KEY implementation in an ENGINE structure */
|
||||
int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ec_meth)
|
||||
{
|
||||
e->ec_meth = ec_meth;
|
||||
return 1;
|
||||
}
|
||||
@@ -1,67 +1,15 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
#include <openssl/evp.h>
|
||||
|
||||
/*
|
||||
* If this symbol is defined then ENGINE_get_pkey_meth_engine(), the function
|
||||
* that is used by EVP to hook in pkey_meth code and cache defaults (etc),
|
||||
* will display brief debugging summaries to stderr with the 'nid'.
|
||||
*/
|
||||
/* #define ENGINE_PKEY_METH_DEBUG */
|
||||
|
||||
static ENGINE_TABLE *pkey_meth_table = NULL;
|
||||
|
||||
void ENGINE_unregister_pkey_meths(ENGINE *e)
|
||||
|
||||
@@ -1,66 +1,14 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2000 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
|
||||
/*
|
||||
* If this symbol is defined then ENGINE_get_default_RAND(), the function
|
||||
* that is used by RAND to hook in implementation code and cache defaults
|
||||
* (etc), will display brief debugging summaries to stderr with the 'nid'.
|
||||
*/
|
||||
/* #define ENGINE_RAND_DEBUG */
|
||||
|
||||
static ENGINE_TABLE *rand_table = NULL;
|
||||
static const int dummy_nid = 1;
|
||||
|
||||
|
||||
@@ -1,66 +1,14 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2000 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
|
||||
/*
|
||||
* If this symbol is defined then ENGINE_get_default_RSA(), the function that
|
||||
* is used by RSA to hook in implementation code and cache defaults (etc),
|
||||
* will display brief debugging summaries to stderr with the 'nid'.
|
||||
*/
|
||||
/* #define ENGINE_RSA_DEBUG */
|
||||
|
||||
static ENGINE_TABLE *rsa_table = NULL;
|
||||
static const int dummy_nid = 1;
|
||||
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2003 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#include "eng_int.h"
|
||||
|
||||
/*
|
||||
* If this symbol is defined then ENGINE_get_default_STORE(), the function
|
||||
* that is used by STORE to hook in implementation code and cache defaults
|
||||
* (etc), will display brief debugging summaries to stderr with the 'nid'.
|
||||
*/
|
||||
/* #define ENGINE_STORE_DEBUG */
|
||||
|
||||
static ENGINE_TABLE *store_table = NULL;
|
||||
static const int dummy_nid = 1;
|
||||
|
||||
void ENGINE_unregister_STORE(ENGINE *e)
|
||||
{
|
||||
engine_table_unregister(&store_table, e);
|
||||
}
|
||||
|
||||
static void engine_unregister_all_STORE(void)
|
||||
{
|
||||
engine_table_cleanup(&store_table);
|
||||
}
|
||||
|
||||
int ENGINE_register_STORE(ENGINE *e)
|
||||
{
|
||||
if (e->store_meth)
|
||||
return engine_table_register(&store_table,
|
||||
engine_unregister_all_STORE, e,
|
||||
&dummy_nid, 1, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ENGINE_register_all_STORE()
|
||||
{
|
||||
ENGINE *e;
|
||||
|
||||
for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e))
|
||||
ENGINE_register_STORE(e);
|
||||
}
|
||||
|
||||
/* The following two functions are removed because they're useless. */
|
||||
#if 0
|
||||
int ENGINE_set_default_STORE(ENGINE *e)
|
||||
{
|
||||
if (e->store_meth)
|
||||
return engine_table_register(&store_table,
|
||||
engine_unregister_all_STORE, e,
|
||||
&dummy_nid, 1, 1);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Exposed API function to get a functional reference from the implementation
|
||||
* table (ie. try to get a functional reference from the tabled structural
|
||||
* references).
|
||||
*/
|
||||
ENGINE *ENGINE_get_default_STORE(void)
|
||||
{
|
||||
return engine_table_select(&store_table, dummy_nid);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Obtains an STORE implementation from an ENGINE functional reference */
|
||||
const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e)
|
||||
{
|
||||
return e->store_meth;
|
||||
}
|
||||
|
||||
/* Sets an STORE implementation in an ENGINE structure */
|
||||
int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *store_meth)
|
||||
{
|
||||
e->store_meth = store_meth;
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user