diff options
| author | cvs2svn <admin@example.com> | 2002-09-05 12:51:53 +0000 |
|---|---|---|
| committer | cvs2svn <admin@example.com> | 2002-09-05 12:51:53 +0000 |
| commit | d6e0927a98d2b936d171fcdf2ac1c56b694a3705 (patch) | |
| tree | c76a93032161bb7aba600dc59798f7100c8ff8eb /src/lib/libcrypto/engine | |
| parent | 5514995a9d5ed91db089875adb509c7781357c0e (diff) | |
| download | openbsd-OPENSSL_0_9_7_BETA1.tar.gz openbsd-OPENSSL_0_9_7_BETA1.tar.bz2 openbsd-OPENSSL_0_9_7_BETA1.zip | |
This commit was manufactured by cvs2git to create tag 'OPENSSL_0_9_7_BETA1'.OPENSSL_0_9_7_BETA1
Diffstat (limited to 'src/lib/libcrypto/engine')
| -rw-r--r-- | src/lib/libcrypto/engine/Makefile.ssl | 453 | ||||
| -rw-r--r-- | src/lib/libcrypto/engine/hw_cryptodev.c | 926 | ||||
| -rw-r--r-- | src/lib/libcrypto/engine/hw_openbsd_dev_crypto.c | 594 |
3 files changed, 1047 insertions, 926 deletions
diff --git a/src/lib/libcrypto/engine/Makefile.ssl b/src/lib/libcrypto/engine/Makefile.ssl new file mode 100644 index 0000000000..eeea47fbf5 --- /dev/null +++ b/src/lib/libcrypto/engine/Makefile.ssl | |||
| @@ -0,0 +1,453 @@ | |||
| 1 | # | ||
| 2 | # OpenSSL/crypto/engine/Makefile | ||
| 3 | # | ||
| 4 | |||
| 5 | DIR= engine | ||
| 6 | TOP= ../.. | ||
| 7 | CC= cc | ||
| 8 | INCLUDES= -I.. -I$(TOP) -I../../include | ||
| 9 | CFLAG=-g | ||
| 10 | INSTALL_PREFIX= | ||
| 11 | OPENSSLDIR= /usr/local/ssl | ||
| 12 | INSTALLTOP=/usr/local/ssl | ||
| 13 | MAKE= make -f Makefile.ssl | ||
| 14 | MAKEDEPPROG= makedepend | ||
| 15 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
| 16 | MAKEFILE= Makefile.ssl | ||
| 17 | AR= ar r | ||
| 18 | |||
| 19 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
| 20 | |||
| 21 | GENERAL=Makefile | ||
| 22 | TEST= enginetest.c | ||
| 23 | APPS= | ||
| 24 | |||
| 25 | LIB=$(TOP)/libcrypto.a | ||
| 26 | LIBSRC= eng_err.c eng_lib.c eng_list.c eng_init.c eng_ctrl.c \ | ||
| 27 | eng_table.c eng_pkey.c eng_fat.c eng_all.c \ | ||
| 28 | tb_rsa.c tb_dsa.c tb_dh.c tb_rand.c tb_cipher.c tb_digest.c \ | ||
| 29 | eng_openssl.c eng_dyn.c eng_cnf.c \ | ||
| 30 | hw_atalla.c hw_cswift.c hw_ncipher.c hw_nuron.c hw_ubsec.c \ | ||
| 31 | hw_openbsd_dev_crypto.c hw_aep.c hw_sureware.c hw_4758_cca.c | ||
| 32 | LIBOBJ= eng_err.o eng_lib.o eng_list.o eng_init.o eng_ctrl.o \ | ||
| 33 | eng_table.o eng_pkey.o eng_fat.o eng_all.o \ | ||
| 34 | tb_rsa.o tb_dsa.o tb_dh.o tb_rand.o tb_cipher.o tb_digest.o \ | ||
| 35 | eng_openssl.o eng_dyn.o eng_cnf.o \ | ||
| 36 | hw_atalla.o hw_cswift.o hw_ncipher.o hw_nuron.o hw_ubsec.o \ | ||
| 37 | hw_openbsd_dev_crypto.o hw_aep.o hw_sureware.o hw_4758_cca.o | ||
| 38 | |||
| 39 | SRC= $(LIBSRC) | ||
| 40 | |||
| 41 | EXHEADER= engine.h | ||
| 42 | HEADER= $(EXHEADER) | ||
| 43 | |||
| 44 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
| 45 | |||
| 46 | top: | ||
| 47 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
| 48 | |||
| 49 | all: lib | ||
| 50 | |||
| 51 | lib: $(LIBOBJ) | ||
| 52 | $(AR) $(LIB) $(LIBOBJ) | ||
| 53 | $(RANLIB) $(LIB) | ||
| 54 | @touch lib | ||
| 55 | |||
| 56 | files: | ||
| 57 | $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | ||
| 58 | |||
| 59 | links: | ||
| 60 | @$(TOP)/util/point.sh Makefile.ssl Makefile | ||
| 61 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
| 62 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
| 63 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | ||
| 64 | |||
| 65 | install: | ||
| 66 | @for i in $(EXHEADER) ; \ | ||
| 67 | do \ | ||
| 68 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
| 69 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
| 70 | done; | ||
| 71 | |||
| 72 | tags: | ||
| 73 | ctags $(SRC) | ||
| 74 | |||
| 75 | errors: | ||
| 76 | $(PERL) $(TOP)/util/mkerr.pl -conf hw.ec \ | ||
| 77 | -nostatic -staticloader -write hw_*.c; \ | ||
| 78 | |||
| 79 | tests: | ||
| 80 | |||
| 81 | lint: | ||
| 82 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
| 83 | |||
| 84 | depend: | ||
| 85 | $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) | ||
| 86 | |||
| 87 | dclean: | ||
| 88 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
| 89 | mv -f Makefile.new $(MAKEFILE) | ||
| 90 | |||
| 91 | clean: | ||
| 92 | rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
| 93 | |||
| 94 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
| 95 | |||
| 96 | eng_all.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 97 | eng_all.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | ||
| 98 | eng_all.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 99 | eng_all.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 100 | eng_all.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 101 | eng_all.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 102 | eng_all.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | ||
| 103 | eng_all.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 104 | eng_all.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 105 | eng_all.o: ../../include/openssl/ui.h eng_all.c eng_int.h | ||
| 106 | eng_cnf.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 107 | eng_cnf.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 108 | eng_cnf.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h | ||
| 109 | eng_cnf.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
| 110 | eng_cnf.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 111 | eng_cnf.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
| 112 | eng_cnf.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 113 | eng_cnf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 114 | eng_cnf.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 115 | eng_cnf.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 116 | eng_cnf.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 117 | eng_cnf.o: ../cryptlib.h eng_cnf.c | ||
| 118 | eng_ctrl.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 119 | eng_ctrl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 120 | eng_ctrl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 121 | eng_ctrl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 122 | eng_ctrl.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 123 | eng_ctrl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 124 | eng_ctrl.o: ../../include/openssl/opensslconf.h | ||
| 125 | eng_ctrl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 126 | eng_ctrl.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 127 | eng_ctrl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 128 | eng_ctrl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 129 | eng_ctrl.o: ../cryptlib.h eng_ctrl.c eng_int.h | ||
| 130 | eng_dyn.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 131 | eng_dyn.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 132 | eng_dyn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 133 | eng_dyn.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 134 | eng_dyn.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 135 | eng_dyn.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
| 136 | eng_dyn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 137 | eng_dyn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 138 | eng_dyn.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 139 | eng_dyn.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 140 | eng_dyn.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 141 | eng_dyn.o: ../cryptlib.h eng_dyn.c eng_int.h | ||
| 142 | eng_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 143 | eng_err.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | ||
| 144 | eng_err.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 145 | eng_err.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 146 | eng_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 147 | eng_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 148 | eng_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | ||
| 149 | eng_err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 150 | eng_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 151 | eng_err.o: ../../include/openssl/ui.h eng_err.c | ||
| 152 | eng_fat.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 153 | eng_fat.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 154 | eng_fat.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h | ||
| 155 | eng_fat.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h | ||
| 156 | eng_fat.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h | ||
| 157 | eng_fat.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
| 158 | eng_fat.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 159 | eng_fat.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 160 | eng_fat.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 161 | eng_fat.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 162 | eng_fat.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 163 | eng_fat.o: ../cryptlib.h eng_fat.c eng_int.h | ||
| 164 | eng_init.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 165 | eng_init.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 166 | eng_init.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 167 | eng_init.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 168 | eng_init.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 169 | eng_init.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 170 | eng_init.o: ../../include/openssl/opensslconf.h | ||
| 171 | eng_init.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 172 | eng_init.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 173 | eng_init.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 174 | eng_init.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 175 | eng_init.o: ../cryptlib.h eng_init.c eng_int.h | ||
| 176 | eng_lib.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 177 | eng_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 178 | eng_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 179 | eng_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 180 | eng_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 181 | eng_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 182 | eng_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 183 | eng_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | ||
| 184 | eng_lib.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 185 | eng_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 186 | eng_lib.o: ../../include/openssl/ui.h ../cryptlib.h eng_int.h eng_lib.c | ||
| 187 | eng_list.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 188 | eng_list.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 189 | eng_list.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 190 | eng_list.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 191 | eng_list.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 192 | eng_list.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 193 | eng_list.o: ../../include/openssl/opensslconf.h | ||
| 194 | eng_list.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 195 | eng_list.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 196 | eng_list.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 197 | eng_list.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 198 | eng_list.o: ../cryptlib.h eng_int.h eng_list.c | ||
| 199 | eng_openssl.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 200 | eng_openssl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 201 | eng_openssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 202 | eng_openssl.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 203 | eng_openssl.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 204 | eng_openssl.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
| 205 | eng_openssl.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 206 | eng_openssl.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 207 | eng_openssl.o: ../../include/openssl/opensslconf.h | ||
| 208 | eng_openssl.o: ../../include/openssl/opensslv.h | ||
| 209 | eng_openssl.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h | ||
| 210 | eng_openssl.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h | ||
| 211 | eng_openssl.o: ../../include/openssl/rand.h ../../include/openssl/rc4.h | ||
| 212 | eng_openssl.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 213 | eng_openssl.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 214 | eng_openssl.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 215 | eng_openssl.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 216 | eng_openssl.o: ../cryptlib.h eng_openssl.c | ||
| 217 | eng_pkey.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 218 | eng_pkey.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 219 | eng_pkey.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 220 | eng_pkey.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 221 | eng_pkey.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 222 | eng_pkey.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 223 | eng_pkey.o: ../../include/openssl/opensslconf.h | ||
| 224 | eng_pkey.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 225 | eng_pkey.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 226 | eng_pkey.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 227 | eng_pkey.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 228 | eng_pkey.o: ../cryptlib.h eng_int.h eng_pkey.c | ||
| 229 | eng_table.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 230 | eng_table.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | ||
| 231 | eng_table.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 232 | eng_table.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 233 | eng_table.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 234 | eng_table.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 235 | eng_table.o: ../../include/openssl/objects.h | ||
| 236 | eng_table.o: ../../include/openssl/opensslconf.h | ||
| 237 | eng_table.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 238 | eng_table.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 239 | eng_table.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 240 | eng_table.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 241 | eng_table.o: eng_int.h eng_table.c | ||
| 242 | hw_4758_cca.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 243 | hw_4758_cca.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 244 | hw_4758_cca.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 245 | hw_4758_cca.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 246 | hw_4758_cca.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 247 | hw_4758_cca.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
| 248 | hw_4758_cca.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 249 | hw_4758_cca.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 250 | hw_4758_cca.o: ../../include/openssl/opensslconf.h | ||
| 251 | hw_4758_cca.o: ../../include/openssl/opensslv.h | ||
| 252 | hw_4758_cca.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h | ||
| 253 | hw_4758_cca.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 254 | hw_4758_cca.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 255 | hw_4758_cca.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 256 | hw_4758_cca.o: ../../include/openssl/ui.h ../../include/openssl/x509.h | ||
| 257 | hw_4758_cca.o: ../../include/openssl/x509_vfy.h ../cryptlib.h hw_4758_cca.c | ||
| 258 | hw_4758_cca.o: hw_4758_cca_err.c hw_4758_cca_err.h vendor_defns/hw_4758_cca.h | ||
| 259 | hw_aep.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 260 | hw_aep.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | ||
| 261 | hw_aep.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 262 | hw_aep.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 263 | hw_aep.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
| 264 | hw_aep.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 265 | hw_aep.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 266 | hw_aep.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 267 | hw_aep.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 268 | hw_aep.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h hw_aep.c | ||
| 269 | hw_aep.o: hw_aep_err.c hw_aep_err.h vendor_defns/aep.h | ||
| 270 | hw_atalla.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 271 | hw_atalla.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 272 | hw_atalla.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 273 | hw_atalla.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 274 | hw_atalla.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 275 | hw_atalla.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
| 276 | hw_atalla.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 277 | hw_atalla.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 278 | hw_atalla.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 279 | hw_atalla.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 280 | hw_atalla.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 281 | hw_atalla.o: ../cryptlib.h hw_atalla.c hw_atalla_err.c hw_atalla_err.h | ||
| 282 | hw_atalla.o: vendor_defns/atalla.h | ||
| 283 | hw_cswift.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 284 | hw_cswift.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 285 | hw_cswift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 286 | hw_cswift.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 287 | hw_cswift.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 288 | hw_cswift.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
| 289 | hw_cswift.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 290 | hw_cswift.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 291 | hw_cswift.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 292 | hw_cswift.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 293 | hw_cswift.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 294 | hw_cswift.o: ../cryptlib.h hw_cswift.c hw_cswift_err.c hw_cswift_err.h | ||
| 295 | hw_cswift.o: vendor_defns/cswift.h | ||
| 296 | hw_ncipher.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 297 | hw_ncipher.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 298 | hw_ncipher.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 299 | hw_ncipher.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 300 | hw_ncipher.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 301 | hw_ncipher.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
| 302 | hw_ncipher.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 303 | hw_ncipher.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 304 | hw_ncipher.o: ../../include/openssl/opensslconf.h | ||
| 305 | hw_ncipher.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 306 | hw_ncipher.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h | ||
| 307 | hw_ncipher.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h | ||
| 308 | hw_ncipher.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 309 | hw_ncipher.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 310 | hw_ncipher.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 311 | hw_ncipher.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 312 | hw_ncipher.o: ../cryptlib.h hw_ncipher.c hw_ncipher_err.c hw_ncipher_err.h | ||
| 313 | hw_ncipher.o: vendor_defns/hwcryptohook.h | ||
| 314 | hw_nuron.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 315 | hw_nuron.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 316 | hw_nuron.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 317 | hw_nuron.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 318 | hw_nuron.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 319 | hw_nuron.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
| 320 | hw_nuron.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 321 | hw_nuron.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 322 | hw_nuron.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 323 | hw_nuron.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 324 | hw_nuron.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 325 | hw_nuron.o: ../cryptlib.h hw_nuron.c hw_nuron_err.c hw_nuron_err.h | ||
| 326 | hw_openbsd_dev_crypto.o: ../../include/openssl/asn1.h | ||
| 327 | hw_openbsd_dev_crypto.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 328 | hw_openbsd_dev_crypto.o: ../../include/openssl/conf.h | ||
| 329 | hw_openbsd_dev_crypto.o: ../../include/openssl/crypto.h | ||
| 330 | hw_openbsd_dev_crypto.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 331 | hw_openbsd_dev_crypto.o: ../../include/openssl/e_os2.h | ||
| 332 | hw_openbsd_dev_crypto.o: ../../include/openssl/engine.h | ||
| 333 | hw_openbsd_dev_crypto.o: ../../include/openssl/err.h | ||
| 334 | hw_openbsd_dev_crypto.o: ../../include/openssl/evp.h | ||
| 335 | hw_openbsd_dev_crypto.o: ../../include/openssl/lhash.h | ||
| 336 | hw_openbsd_dev_crypto.o: ../../include/openssl/obj_mac.h | ||
| 337 | hw_openbsd_dev_crypto.o: ../../include/openssl/objects.h | ||
| 338 | hw_openbsd_dev_crypto.o: ../../include/openssl/opensslconf.h | ||
| 339 | hw_openbsd_dev_crypto.o: ../../include/openssl/opensslv.h | ||
| 340 | hw_openbsd_dev_crypto.o: ../../include/openssl/ossl_typ.h | ||
| 341 | hw_openbsd_dev_crypto.o: ../../include/openssl/rand.h | ||
| 342 | hw_openbsd_dev_crypto.o: ../../include/openssl/rsa.h | ||
| 343 | hw_openbsd_dev_crypto.o: ../../include/openssl/safestack.h | ||
| 344 | hw_openbsd_dev_crypto.o: ../../include/openssl/stack.h | ||
| 345 | hw_openbsd_dev_crypto.o: ../../include/openssl/symhacks.h | ||
| 346 | hw_openbsd_dev_crypto.o: ../../include/openssl/ui.h ../evp/evp_locl.h eng_int.h | ||
| 347 | hw_openbsd_dev_crypto.o: hw_openbsd_dev_crypto.c | ||
| 348 | hw_sureware.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 349 | hw_sureware.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 350 | hw_sureware.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 351 | hw_sureware.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 352 | hw_sureware.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 353 | hw_sureware.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
| 354 | hw_sureware.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
| 355 | hw_sureware.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
| 356 | hw_sureware.o: ../../include/openssl/opensslconf.h | ||
| 357 | hw_sureware.o: ../../include/openssl/opensslv.h | ||
| 358 | hw_sureware.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h | ||
| 359 | hw_sureware.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h | ||
| 360 | hw_sureware.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 361 | hw_sureware.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 362 | hw_sureware.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 363 | hw_sureware.o: ../../include/openssl/ui.h ../../include/openssl/x509.h | ||
| 364 | hw_sureware.o: ../../include/openssl/x509_vfy.h ../cryptlib.h eng_int.h | ||
| 365 | hw_sureware.o: engine.h hw_sureware.c hw_sureware_err.c hw_sureware_err.h | ||
| 366 | hw_sureware.o: vendor_defns/sureware.h | ||
| 367 | hw_ubsec.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 368 | hw_ubsec.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
| 369 | hw_ubsec.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 370 | hw_ubsec.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 371 | hw_ubsec.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 372 | hw_ubsec.o: ../../include/openssl/engine.h ../../include/openssl/err.h | ||
| 373 | hw_ubsec.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | ||
| 374 | hw_ubsec.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 375 | hw_ubsec.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 376 | hw_ubsec.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 377 | hw_ubsec.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 378 | hw_ubsec.o: ../cryptlib.h hw_ubsec.c hw_ubsec_err.c hw_ubsec_err.h | ||
| 379 | hw_ubsec.o: vendor_defns/hw_ubsec.h | ||
| 380 | tb_cipher.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 381 | tb_cipher.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | ||
| 382 | tb_cipher.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 383 | tb_cipher.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 384 | tb_cipher.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 385 | tb_cipher.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 386 | tb_cipher.o: ../../include/openssl/objects.h | ||
| 387 | tb_cipher.o: ../../include/openssl/opensslconf.h | ||
| 388 | tb_cipher.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 389 | tb_cipher.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 390 | tb_cipher.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 391 | tb_cipher.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 392 | tb_cipher.o: eng_int.h tb_cipher.c | ||
| 393 | tb_dh.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 394 | tb_dh.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | ||
| 395 | tb_dh.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 396 | tb_dh.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 397 | tb_dh.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 398 | tb_dh.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 399 | tb_dh.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 400 | tb_dh.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 401 | tb_dh.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 402 | tb_dh.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 403 | tb_dh.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h eng_int.h | ||
| 404 | tb_dh.o: tb_dh.c | ||
| 405 | tb_digest.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 406 | tb_digest.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | ||
| 407 | tb_digest.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 408 | tb_digest.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 409 | tb_digest.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 410 | tb_digest.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 411 | tb_digest.o: ../../include/openssl/objects.h | ||
| 412 | tb_digest.o: ../../include/openssl/opensslconf.h | ||
| 413 | tb_digest.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 414 | tb_digest.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 415 | tb_digest.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 416 | tb_digest.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 417 | tb_digest.o: eng_int.h tb_digest.c | ||
| 418 | tb_dsa.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 419 | tb_dsa.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | ||
| 420 | tb_dsa.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 421 | tb_dsa.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 422 | tb_dsa.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 423 | tb_dsa.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 424 | tb_dsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 425 | tb_dsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 426 | tb_dsa.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 427 | tb_dsa.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 428 | tb_dsa.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h eng_int.h | ||
| 429 | tb_dsa.o: tb_dsa.c | ||
| 430 | tb_rand.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 431 | tb_rand.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | ||
| 432 | tb_rand.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 433 | tb_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 434 | tb_rand.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 435 | tb_rand.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 436 | tb_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 437 | tb_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 438 | tb_rand.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 439 | tb_rand.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 440 | tb_rand.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h | ||
| 441 | tb_rand.o: eng_int.h tb_rand.c | ||
| 442 | tb_rsa.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 443 | tb_rsa.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h | ||
| 444 | tb_rsa.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 445 | tb_rsa.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | ||
| 446 | tb_rsa.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 447 | tb_rsa.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 448 | tb_rsa.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 449 | tb_rsa.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 450 | tb_rsa.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h | ||
| 451 | tb_rsa.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 452 | tb_rsa.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h eng_int.h | ||
| 453 | tb_rsa.o: tb_rsa.c | ||
diff --git a/src/lib/libcrypto/engine/hw_cryptodev.c b/src/lib/libcrypto/engine/hw_cryptodev.c deleted file mode 100644 index 7c3728f395..0000000000 --- a/src/lib/libcrypto/engine/hw_cryptodev.c +++ /dev/null | |||
| @@ -1,926 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2002 Bob Beck <beck@openbsd.org> | ||
| 3 | * Copyright (c) 2002 Theo de Raadt | ||
| 4 | * All rights reserved. | ||
| 5 | * | ||
| 6 | * Redistribution and use in source and binary forms, with or without | ||
| 7 | * modification, are permitted provided that the following conditions | ||
| 8 | * are met: | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 12 | * notice, this list of conditions and the following disclaimer in the | ||
| 13 | * documentation and/or other materials provided with the distribution. | ||
| 14 | * 3. Neither the name of the author nor the names of contributors | ||
| 15 | * may be used to endorse or promote products derived from this software | ||
| 16 | * without specific prior written permission. | ||
| 17 | * | ||
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY | ||
| 19 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| 21 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY | ||
| 22 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
| 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
| 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 28 | * | ||
| 29 | */ | ||
| 30 | |||
| 31 | #include <sys/types.h> | ||
| 32 | #include <sys/param.h> | ||
| 33 | #include <crypto/cryptodev.h> | ||
| 34 | #include <sys/ioctl.h> | ||
| 35 | #include <errno.h> | ||
| 36 | #include <stdio.h> | ||
| 37 | #include <unistd.h> | ||
| 38 | #include <fcntl.h> | ||
| 39 | #include <syslog.h> | ||
| 40 | #include <stdarg.h> | ||
| 41 | #include <ssl/objects.h> | ||
| 42 | #include <ssl/engine.h> | ||
| 43 | #include <ssl/evp.h> | ||
| 44 | |||
| 45 | static int cryptodev_fd = -1; | ||
| 46 | static int cryptodev_sessions = 0; | ||
| 47 | static u_int32_t cryptodev_symfeat = 0; | ||
| 48 | |||
| 49 | static int bn2crparam(const BIGNUM *a, struct crparam *crp); | ||
| 50 | static int crparam2bn(struct crparam *crp, BIGNUM *a); | ||
| 51 | static void zapparams(struct crypt_kop *kop); | ||
| 52 | |||
| 53 | static int cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa); | ||
| 54 | static int cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a, | ||
| 55 | const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); | ||
| 56 | static int cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, | ||
| 57 | const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); | ||
| 58 | static DSA_SIG *cryptodev_dsa_do_sign(const unsigned char *dgst, | ||
| 59 | int dlen, DSA *dsa); | ||
| 60 | static int cryptodev_dsa_verify(const unsigned char *dgst, int dgst_len, | ||
| 61 | DSA_SIG *sig, DSA *dsa); | ||
| 62 | static int cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a, | ||
| 63 | const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, | ||
| 64 | BN_MONT_CTX *m_ctx); | ||
| 65 | static int cryptodev_dh_compute_key(unsigned char *key, | ||
| 66 | const BIGNUM *pub_key, DH *dh); | ||
| 67 | |||
| 68 | static const ENGINE_CMD_DEFN cryptodev_defns[] = { | ||
| 69 | { 0, NULL, NULL, 0 } | ||
| 70 | }; | ||
| 71 | |||
| 72 | static struct { | ||
| 73 | int id; | ||
| 74 | int nid; | ||
| 75 | int ivmax; | ||
| 76 | int keylen; | ||
| 77 | } ciphers[] = { | ||
| 78 | { CRYPTO_DES_CBC, NID_des_cbc, 8, 8, }, | ||
| 79 | { CRYPTO_3DES_CBC, NID_des_ede3_cbc, 8, 24, }, | ||
| 80 | { CRYPTO_AES_CBC, NID_undef, 8, 24, }, | ||
| 81 | { CRYPTO_BLF_CBC, NID_bf_cbc, 8, 16, }, | ||
| 82 | { CRYPTO_CAST_CBC, NID_cast5_cbc, 8, 8, }, | ||
| 83 | { CRYPTO_SKIPJACK_CBC, NID_undef, 0, 0, }, | ||
| 84 | { CRYPTO_ARC4, NID_rc4, 8, 16, }, | ||
| 85 | { 0, NID_undef, 0, 0, }, | ||
| 86 | }; | ||
| 87 | |||
| 88 | static struct { | ||
| 89 | int id; | ||
| 90 | int nid; | ||
| 91 | } digests[] = { | ||
| 92 | { CRYPTO_SHA1_HMAC, NID_hmacWithSHA1, }, | ||
| 93 | { CRYPTO_RIPEMD160_HMAC, NID_ripemd160, }, | ||
| 94 | { CRYPTO_MD5_KPDK, NID_undef, }, | ||
| 95 | { CRYPTO_SHA1_KPDK, NID_undef, }, | ||
| 96 | { CRYPTO_MD5, NID_md5, }, | ||
| 97 | { CRYPTO_SHA1, NID_undef, }, | ||
| 98 | { 0, NID_undef, }, | ||
| 99 | }; | ||
| 100 | |||
| 101 | /* | ||
| 102 | * Return 1 if /dev/crypto seems usable, 0 otherwise , also | ||
| 103 | * does most of the work of initting the device, if not already | ||
| 104 | * done.. This should leave is with global fd initialized with CRIOGET. | ||
| 105 | */ | ||
| 106 | static int | ||
| 107 | check_dev_crypto() | ||
| 108 | { | ||
| 109 | int fd; | ||
| 110 | |||
| 111 | if (cryptodev_fd == -1) { | ||
| 112 | if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1) | ||
| 113 | return (0); | ||
| 114 | if (ioctl(fd, CRIOGET, &cryptodev_fd) == -1) { | ||
| 115 | close(fd); | ||
| 116 | return (0); | ||
| 117 | } | ||
| 118 | close(fd); | ||
| 119 | /* close on exec */ | ||
| 120 | if (fcntl(cryptodev_fd, F_SETFD, 1) == -1) { | ||
| 121 | close(cryptodev_fd); | ||
| 122 | cryptodev_fd = -1; | ||
| 123 | return (0); | ||
| 124 | } | ||
| 125 | } | ||
| 126 | ioctl(cryptodev_fd, CIOCSYMFEAT, &cryptodev_symfeat); | ||
| 127 | |||
| 128 | return (1); | ||
| 129 | } | ||
| 130 | |||
| 131 | /* | ||
| 132 | * XXXX this needs to be set for each alg - and determined from | ||
| 133 | * a running card. | ||
| 134 | */ | ||
| 135 | static int | ||
| 136 | cryptodev_max_iv(int cipher) | ||
| 137 | { | ||
| 138 | int i; | ||
| 139 | |||
| 140 | for (i = 0; ciphers[i].id; i++) | ||
| 141 | if (ciphers[i].id == cipher) | ||
| 142 | return (ciphers[i].ivmax); | ||
| 143 | return (0); | ||
| 144 | } | ||
| 145 | |||
| 146 | /* | ||
| 147 | * XXXX this needs to be set for each alg - and determined from | ||
| 148 | * a running card. For now, fake it out - but most of these | ||
| 149 | * for real devices should return 1 for the supported key | ||
| 150 | * sizes the device can handle. | ||
| 151 | */ | ||
| 152 | static int | ||
| 153 | cryptodev_key_length_valid(int cipher, int len) | ||
| 154 | { | ||
| 155 | int i; | ||
| 156 | |||
| 157 | for (i = 0; ciphers[i].id; i++) | ||
| 158 | if (ciphers[i].id == cipher) | ||
| 159 | return (ciphers[i].keylen == len); | ||
| 160 | return (0); | ||
| 161 | } | ||
| 162 | |||
| 163 | /* convert libcrypto nids to cryptodev */ | ||
| 164 | static int | ||
| 165 | cipher_nid_to_cryptodev(int nid) | ||
| 166 | { | ||
| 167 | int i; | ||
| 168 | |||
| 169 | for (i = 0; ciphers[i].id; i++) | ||
| 170 | if (ciphers[i].nid == nid) | ||
| 171 | return (ciphers[i].id); | ||
| 172 | return (0); | ||
| 173 | } | ||
| 174 | |||
| 175 | /* | ||
| 176 | * Find out what ciphers /dev/crypto will let us have a session for. | ||
| 177 | * XXX note, that some of these openssl doesn't deal with yet! | ||
| 178 | * returning them here is harmless, as long as we return NULL | ||
| 179 | * when asked for a handler in the cryptodev_engine_ciphers routine | ||
| 180 | */ | ||
| 181 | static int | ||
| 182 | get_cryptodev_ciphers(const int **cnids) | ||
| 183 | { | ||
| 184 | static int nids[CRYPTO_ALGORITHM_MAX]; | ||
| 185 | struct session_op sess; | ||
| 186 | int i, count = 0; | ||
| 187 | |||
| 188 | memset(&sess, 0, sizeof(sess)); | ||
| 189 | sess.key = (caddr_t)"123456781234567812345678"; | ||
| 190 | |||
| 191 | for (i = 0; ciphers[i].id && count < CRYPTO_ALGORITHM_MAX; i++) { | ||
| 192 | if (ciphers[i].nid == NID_undef) | ||
| 193 | continue; | ||
| 194 | sess.cipher = ciphers[i].id; | ||
| 195 | sess.keylen = ciphers[i].keylen; | ||
| 196 | sess.mac = 0; | ||
| 197 | if (ioctl(cryptodev_fd, CIOCGSESSION, &sess) != -1 && | ||
| 198 | ioctl(cryptodev_fd, CIOCFSESSION, &sess.ses) != -1) | ||
| 199 | nids[count++] = ciphers[i].nid; | ||
| 200 | } | ||
| 201 | if (count > 0) | ||
| 202 | *cnids = nids; | ||
| 203 | else | ||
| 204 | *cnids = NULL; | ||
| 205 | return (count); | ||
| 206 | } | ||
| 207 | |||
| 208 | /* | ||
| 209 | * Find out what digests /dev/crypto will let us have a session for. | ||
| 210 | * XXX note, that some of these openssl doesn't deal with yet! | ||
| 211 | * returning them here is harmless, as long as we return NULL | ||
| 212 | * when asked for a handler in the cryptodev_engine_digests routine | ||
| 213 | */ | ||
| 214 | static int | ||
| 215 | get_cryptodev_digests(const int **cnids) | ||
| 216 | { | ||
| 217 | static int nids[CRYPTO_ALGORITHM_MAX]; | ||
| 218 | struct session_op sess; | ||
| 219 | int i, count = 0; | ||
| 220 | |||
| 221 | memset(&sess, 0, sizeof(sess)); | ||
| 222 | for (i = 0; digests[i].id && count < CRYPTO_ALGORITHM_MAX; i++) { | ||
| 223 | if (digests[i].nid == NID_undef) | ||
| 224 | continue; | ||
| 225 | sess.mac = digests[i].id; | ||
| 226 | sess.cipher = 0; | ||
| 227 | if (ioctl(cryptodev_fd, CIOCGSESSION, &sess) != -1 && | ||
| 228 | ioctl(cryptodev_fd, CIOCFSESSION, &sess.ses) != -1) | ||
| 229 | nids[count++] = digests[i].nid; | ||
| 230 | } | ||
| 231 | if (count > 0) | ||
| 232 | *cnids = nids; | ||
| 233 | else | ||
| 234 | *cnids = NULL; | ||
| 235 | return (count); | ||
| 236 | } | ||
| 237 | |||
| 238 | /* | ||
| 239 | * Find the useable ciphers|digests from dev/crypto - this is the first | ||
| 240 | * thing called by the engine init crud which determines what it | ||
| 241 | * can use for ciphers from this engine. We want to return | ||
| 242 | * only what we can do, anythine else is handled by software. | ||
| 243 | * | ||
| 244 | * If we can't initialize the device to do anything useful for | ||
| 245 | * any reason, we want to return a NULL array, and 0 length, | ||
| 246 | * which forces everything to be done is software. By putting | ||
| 247 | * the initalization of the device in here, we ensure we can | ||
| 248 | * use this engine as the default, and if for whatever reason | ||
| 249 | * /dev/crypto won't do what we want it will just be done in | ||
| 250 | * software | ||
| 251 | * | ||
| 252 | * This can (should) be greatly expanded to perhaps take into | ||
| 253 | * account speed of the device, and what we want to do. | ||
| 254 | * (although the disabling of particular alg's could be controlled | ||
| 255 | * by the device driver with sysctl's.) - this is where we | ||
| 256 | * want most of the decisions made about what we actually want | ||
| 257 | * to use from /dev/crypto. | ||
| 258 | */ | ||
| 259 | int | ||
| 260 | cryptodev_usable_ciphers(const int **nids) | ||
| 261 | { | ||
| 262 | if (!check_dev_crypto()) { | ||
| 263 | *nids = NULL; | ||
| 264 | return (0); | ||
| 265 | } | ||
| 266 | |||
| 267 | /* find what the device can do. Unfortunately, we don't | ||
| 268 | * necessarily want all of these yet, because we aren't | ||
| 269 | * yet set up to do them | ||
| 270 | */ | ||
| 271 | return (get_cryptodev_ciphers(nids)); | ||
| 272 | } | ||
| 273 | |||
| 274 | int | ||
| 275 | cryptodev_usable_digests(const int **nids) | ||
| 276 | { | ||
| 277 | #if 1 | ||
| 278 | /* | ||
| 279 | * XXXX just disable all digests for now, because it sucks. | ||
| 280 | * we need a better way to decide this - i.e. I may not | ||
| 281 | * want digests on slow cards like hifn on fast machines, | ||
| 282 | * but might want them on slow or loaded machines, etc. | ||
| 283 | * will also want them when using crypto cards that don't | ||
| 284 | * suck moose gonads - would be nice to be able to decide something | ||
| 285 | * as reasonable default without having hackery that's card dependent. | ||
| 286 | * of course, the default should probably be just do everything, | ||
| 287 | * with perhaps a sysctl to turn algoritms off (or have them off | ||
| 288 | * by default) on cards that generally suck like the hifn. | ||
| 289 | */ | ||
| 290 | *nids = NULL; | ||
| 291 | return (0); | ||
| 292 | #endif | ||
| 293 | |||
| 294 | if (!check_dev_crypto()) { | ||
| 295 | *nids = NULL; | ||
| 296 | return (0); | ||
| 297 | } | ||
| 298 | return (get_cryptodev_digests(nids)); | ||
| 299 | } | ||
| 300 | |||
| 301 | |||
| 302 | int | ||
| 303 | cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 304 | const unsigned char *in, unsigned int inl) | ||
| 305 | { | ||
| 306 | struct crypt_op cryp; | ||
| 307 | struct session_op *sess = ctx->cipher_data; | ||
| 308 | void *iiv; | ||
| 309 | unsigned char save_iv[EVP_MAX_IV_LENGTH]; | ||
| 310 | struct syslog_data sd = SYSLOG_DATA_INIT; | ||
| 311 | |||
| 312 | if (cryptodev_fd == -1) | ||
| 313 | return (0); | ||
| 314 | if (sess == NULL) | ||
| 315 | return (0); | ||
| 316 | if (!inl) | ||
| 317 | return (1); | ||
| 318 | if ((inl % ctx->cipher->block_size) != 0) | ||
| 319 | return (0); | ||
| 320 | |||
| 321 | memset(&cryp, 0, sizeof(cryp)); | ||
| 322 | |||
| 323 | cryp.ses = sess->ses; | ||
| 324 | cryp.flags = 0; | ||
| 325 | cryp.len = inl; | ||
| 326 | cryp.src = (caddr_t) in; | ||
| 327 | cryp.dst = (caddr_t) out; | ||
| 328 | cryp.mac = 0; | ||
| 329 | |||
| 330 | cryp.op = ctx->encrypt ? COP_ENCRYPT : COP_DECRYPT; | ||
| 331 | |||
| 332 | if (ctx->cipher->iv_len) { | ||
| 333 | cryp.iv = (caddr_t) ctx->iv; | ||
| 334 | if (!ctx->encrypt) { | ||
| 335 | iiv = (void *) in + inl - ctx->cipher->iv_len; | ||
| 336 | memcpy(save_iv, iiv, ctx->cipher->iv_len); | ||
| 337 | } | ||
| 338 | } else | ||
| 339 | cryp.iv = NULL; | ||
| 340 | |||
| 341 | if (ioctl(cryptodev_fd, CIOCCRYPT, &cryp) == -1) { | ||
| 342 | /* XXX need better errror handling | ||
| 343 | * this can fail for a number of different reasons. | ||
| 344 | */ | ||
| 345 | syslog_r(LOG_ERR, &sd, "CIOCCRYPT failed (%m)"); | ||
| 346 | return (0); | ||
| 347 | } | ||
| 348 | |||
| 349 | if (ctx->cipher->iv_len) { | ||
| 350 | if (ctx->encrypt) | ||
| 351 | iiv = (void *) out + inl - ctx->cipher->iv_len; | ||
| 352 | else | ||
| 353 | iiv = save_iv; | ||
| 354 | memcpy(ctx->iv, iiv, ctx->cipher->iv_len); | ||
| 355 | } | ||
| 356 | return (1); | ||
| 357 | } | ||
| 358 | |||
| 359 | int | ||
| 360 | cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
| 361 | const unsigned char *iv, int enc) | ||
| 362 | { | ||
| 363 | struct session_op *sess = ctx->cipher_data; | ||
| 364 | struct syslog_data sd = SYSLOG_DATA_INIT; | ||
| 365 | int cipher; | ||
| 366 | |||
| 367 | if ((cipher = cipher_nid_to_cryptodev(ctx->cipher->nid)) == NID_undef) | ||
| 368 | return (0); | ||
| 369 | |||
| 370 | if (!check_dev_crypto()) | ||
| 371 | return (0); | ||
| 372 | |||
| 373 | if (ctx->cipher->iv_len > cryptodev_max_iv(cipher)) | ||
| 374 | return (0); | ||
| 375 | |||
| 376 | if (!cryptodev_key_length_valid(cipher, ctx->key_len)) | ||
| 377 | return (0); | ||
| 378 | |||
| 379 | memset(sess, 0, sizeof(struct session_op)); | ||
| 380 | |||
| 381 | sess->key = (unsigned char *)key; | ||
| 382 | sess->keylen = ctx->key_len; | ||
| 383 | sess->cipher = cipher; | ||
| 384 | |||
| 385 | if (ioctl(cryptodev_fd, CIOCGSESSION, sess) == -1) { | ||
| 386 | syslog_r(LOG_ERR, &sd, "CIOCGSESSION failed (%m)"); | ||
| 387 | return (0); | ||
| 388 | } | ||
| 389 | cryptodev_sessions++; | ||
| 390 | return (1); | ||
| 391 | } | ||
| 392 | |||
| 393 | /* | ||
| 394 | * free anything we allocated earlier when initting a | ||
| 395 | * session, and close the session. | ||
| 396 | */ | ||
| 397 | int | ||
| 398 | cryptodev_cleanup(EVP_CIPHER_CTX *ctx) | ||
| 399 | { | ||
| 400 | int ret = 0; | ||
| 401 | struct session_op *sess = ctx->cipher_data; | ||
| 402 | struct syslog_data sd = SYSLOG_DATA_INIT; | ||
| 403 | |||
| 404 | if (sess == NULL) | ||
| 405 | return (0); | ||
| 406 | |||
| 407 | /* XXX if this ioctl fails, someting's wrong. the invoker | ||
| 408 | * may have called us with a bogus ctx, or we could | ||
| 409 | * have a device that for whatever reason just doesn't | ||
| 410 | * want to play ball - it's not clear what's right | ||
| 411 | * here - should this be an error? should it just | ||
| 412 | * increase a counter, hmm. For right now, we return | ||
| 413 | * 0 - I don't believe that to be "right". we could | ||
| 414 | * call the gorpy openssl lib error handlers that | ||
| 415 | * print messages to users of the library. hmm.. | ||
| 416 | */ | ||
| 417 | |||
| 418 | if (ioctl(cryptodev_fd, CIOCFSESSION, &sess->ses) == -1) { | ||
| 419 | syslog_r(LOG_ERR, &sd, "CIOCFSESSION failed (%m)"); | ||
| 420 | ret = 0; | ||
| 421 | } else { | ||
| 422 | cryptodev_sessions--; | ||
| 423 | ret = 1; | ||
| 424 | } | ||
| 425 | if (cryptodev_sessions == 0 && cryptodev_fd != -1 ) { | ||
| 426 | close(cryptodev_fd); /* XXX should this be closed? */ | ||
| 427 | cryptodev_fd = -1; | ||
| 428 | } | ||
| 429 | return (ret); | ||
| 430 | } | ||
| 431 | |||
| 432 | /* | ||
| 433 | * libcrypto EVP stuff - this is how we get wired to EVP so the engine | ||
| 434 | * gets called when libcrypto requests a cipher NID. | ||
| 435 | */ | ||
| 436 | |||
| 437 | /* ARC4 (16 byte key) */ | ||
| 438 | const EVP_CIPHER cryptodev_arc4_cipher = { | ||
| 439 | NID_rc4, | ||
| 440 | 1, 16, 0, | ||
| 441 | EVP_CIPH_VARIABLE_LENGTH, | ||
| 442 | cryptodev_init_key, | ||
| 443 | cryptodev_cipher, | ||
| 444 | cryptodev_cleanup, | ||
| 445 | sizeof(struct session_op), | ||
| 446 | NULL, | ||
| 447 | NULL, | ||
| 448 | NULL | ||
| 449 | }; | ||
| 450 | |||
| 451 | /* DES CBC EVP */ | ||
| 452 | const EVP_CIPHER cryptodev_des_cbc = { | ||
| 453 | NID_des_cbc, | ||
| 454 | 8, 8, 8, | ||
| 455 | EVP_CIPH_CBC_MODE, | ||
| 456 | cryptodev_init_key, | ||
| 457 | cryptodev_cipher, | ||
| 458 | cryptodev_cleanup, | ||
| 459 | sizeof(struct session_op), | ||
| 460 | EVP_CIPHER_set_asn1_iv, | ||
| 461 | EVP_CIPHER_get_asn1_iv, | ||
| 462 | NULL | ||
| 463 | }; | ||
| 464 | |||
| 465 | /* 3DES CBC EVP */ | ||
| 466 | const EVP_CIPHER cryptodev_3des_cbc = { | ||
| 467 | NID_des_ede3_cbc, | ||
| 468 | 8, 24, 8, | ||
| 469 | EVP_CIPH_CBC_MODE, | ||
| 470 | cryptodev_init_key, | ||
| 471 | cryptodev_cipher, | ||
| 472 | cryptodev_cleanup, | ||
| 473 | sizeof(struct session_op), | ||
| 474 | EVP_CIPHER_set_asn1_iv, | ||
| 475 | EVP_CIPHER_get_asn1_iv, | ||
| 476 | NULL | ||
| 477 | }; | ||
| 478 | |||
| 479 | |||
| 480 | /* | ||
| 481 | * Registered by the ENGINE when used to find out how to deal with | ||
| 482 | * a particular NID in the ENGINE. this says what we'll do at the | ||
| 483 | * top level - note, that list is restricted by what we answer with | ||
| 484 | */ | ||
| 485 | int | ||
| 486 | cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher, | ||
| 487 | const int **nids, int nid) | ||
| 488 | { | ||
| 489 | if (!cipher) | ||
| 490 | return (cryptodev_usable_ciphers(nids)); | ||
| 491 | |||
| 492 | switch (nid) { | ||
| 493 | case NID_rc4: | ||
| 494 | *cipher = &cryptodev_arc4_cipher; | ||
| 495 | break; | ||
| 496 | case NID_des_ede3_cbc: | ||
| 497 | *cipher = &cryptodev_3des_cbc; | ||
| 498 | break; | ||
| 499 | case NID_des_cbc: | ||
| 500 | *cipher = &cryptodev_des_cbc; | ||
| 501 | break; | ||
| 502 | default: | ||
| 503 | *cipher = NULL; | ||
| 504 | break; | ||
| 505 | } | ||
| 506 | return (*cipher != NULL); | ||
| 507 | } | ||
| 508 | |||
| 509 | int | ||
| 510 | cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest, | ||
| 511 | const int **nids, int nid) | ||
| 512 | { | ||
| 513 | if (!digest) | ||
| 514 | return (cryptodev_usable_digests(nids)); | ||
| 515 | |||
| 516 | switch (nid) { | ||
| 517 | case NID_md5: | ||
| 518 | *digest = NULL; /* need to make a clean md5 critter */ | ||
| 519 | break; | ||
| 520 | default: | ||
| 521 | *digest = NULL; | ||
| 522 | break; | ||
| 523 | } | ||
| 524 | return (*digest != NULL); | ||
| 525 | } | ||
| 526 | |||
| 527 | |||
| 528 | /* | ||
| 529 | * Convert a BIGNUM to the representation that /dev/crypto needs. | ||
| 530 | * Upon completion of use, the caller is responsible for freeing | ||
| 531 | * crp->crp_p. | ||
| 532 | */ | ||
| 533 | static int | ||
| 534 | bn2crparam(const BIGNUM *a, struct crparam *crp) | ||
| 535 | { | ||
| 536 | int i, j, n; | ||
| 537 | ssize_t words, bytes, bits; | ||
| 538 | u_char *b; | ||
| 539 | |||
| 540 | crp->crp_p = NULL; | ||
| 541 | crp->crp_nbits = 0; | ||
| 542 | |||
| 543 | bits = BN_num_bits(a); | ||
| 544 | bytes = (bits + 7) / 8; | ||
| 545 | |||
| 546 | b = malloc(bytes); | ||
| 547 | if (b == NULL) | ||
| 548 | return (1); | ||
| 549 | |||
| 550 | crp->crp_p = b; | ||
| 551 | crp->crp_nbits = bits; | ||
| 552 | |||
| 553 | words = (bits + BN_BITS2 - 1) / BN_BITS2; | ||
| 554 | |||
| 555 | n = 0; | ||
| 556 | for (i = 0; i < words && n < bytes; i++) { | ||
| 557 | BN_ULONG word; | ||
| 558 | |||
| 559 | word = a->d[i]; | ||
| 560 | for (j = 0 ; j < BN_BYTES && n < bytes; j++, n++) { | ||
| 561 | *b++ = (word & 0xff); | ||
| 562 | word >>= 8; | ||
| 563 | } | ||
| 564 | } | ||
| 565 | return (0); | ||
| 566 | } | ||
| 567 | |||
| 568 | /* Convert a /dev/crypto parameter to a BIGNUM */ | ||
| 569 | static int | ||
| 570 | crparam2bn(struct crparam *crp, BIGNUM *a) | ||
| 571 | { | ||
| 572 | int i, bytes; | ||
| 573 | |||
| 574 | bytes = (crp->crp_nbits + 7)/8; | ||
| 575 | |||
| 576 | BN_zero(a); | ||
| 577 | for (i = bytes - 1; i >= 0; i--) { | ||
| 578 | BN_lshift(a, a, 8); | ||
| 579 | BN_add_word(a, (u_char)crp->crp_p[i]); | ||
| 580 | } | ||
| 581 | |||
| 582 | return (0); | ||
| 583 | } | ||
| 584 | |||
| 585 | static void | ||
| 586 | zapparams(struct crypt_kop *kop) | ||
| 587 | { | ||
| 588 | int i; | ||
| 589 | |||
| 590 | for (i = 0; i <= kop->crk_iparams + kop->crk_oparams; i++) { | ||
| 591 | if (kop->crk_param[i].crp_p) | ||
| 592 | free(kop->crk_param[i].crp_p); | ||
| 593 | kop->crk_param[i].crp_p = NULL; | ||
| 594 | kop->crk_param[i].crp_nbits = 0; | ||
| 595 | } | ||
| 596 | } | ||
| 597 | |||
| 598 | static int | ||
| 599 | cryptodev_sym(struct crypt_kop *kop, BIGNUM *r, BIGNUM *s) | ||
| 600 | { | ||
| 601 | int ret = -1; | ||
| 602 | |||
| 603 | if (r) { | ||
| 604 | kop->crk_param[kop->crk_iparams].crp_p = malloc(256); | ||
| 605 | kop->crk_param[kop->crk_iparams].crp_nbits = 256 * 8; | ||
| 606 | kop->crk_oparams++; | ||
| 607 | } | ||
| 608 | if (s) { | ||
| 609 | kop->crk_param[kop->crk_iparams+1].crp_p = malloc(256); | ||
| 610 | kop->crk_param[kop->crk_iparams+1].crp_nbits = 256 * 8; | ||
| 611 | kop->crk_oparams++; | ||
| 612 | } | ||
| 613 | |||
| 614 | if (ioctl(cryptodev_fd, CIOCKEY, &kop) == 0) { | ||
| 615 | crparam2bn(&kop->crk_param[3], r); | ||
| 616 | ret = 0; | ||
| 617 | } | ||
| 618 | return (ret); | ||
| 619 | } | ||
| 620 | |||
| 621 | static int | ||
| 622 | cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | ||
| 623 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) | ||
| 624 | { | ||
| 625 | struct crypt_kop kop; | ||
| 626 | int ret = 0; | ||
| 627 | |||
| 628 | memset(&kop, 0, sizeof kop); | ||
| 629 | kop.crk_op = CRK_MOD_EXP; | ||
| 630 | |||
| 631 | /* inputs: a m p */ | ||
| 632 | if (bn2crparam(a, &kop.crk_param[0])) | ||
| 633 | goto err; | ||
| 634 | if (bn2crparam(m, &kop.crk_param[1])) | ||
| 635 | goto err; | ||
| 636 | if (bn2crparam(p, &kop.crk_param[2])) | ||
| 637 | goto err; | ||
| 638 | kop.crk_iparams = 3; | ||
| 639 | |||
| 640 | if (cryptodev_sym(&kop, r, NULL) == -1) { | ||
| 641 | ret = BN_mod_exp(r, a, p, m, ctx); | ||
| 642 | } | ||
| 643 | err: | ||
| 644 | zapparams(&kop); | ||
| 645 | return (ret); | ||
| 646 | } | ||
| 647 | |||
| 648 | |||
| 649 | static int | ||
| 650 | cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa) | ||
| 651 | { | ||
| 652 | struct crypt_kop kop; | ||
| 653 | int ret = 0; | ||
| 654 | |||
| 655 | if (!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp) { | ||
| 656 | /* XXX 0 means failure?? */ | ||
| 657 | goto err; | ||
| 658 | } | ||
| 659 | |||
| 660 | memset(&kop, 0, sizeof kop); | ||
| 661 | kop.crk_op = CRK_MOD_EXP_CRT; | ||
| 662 | /* inputs: rsa->p rsa->q I rsa->dmp1 rsa->dmq1 rsa->iqmp */ | ||
| 663 | if (bn2crparam(rsa->p, &kop.crk_param[0])) | ||
| 664 | goto err; | ||
| 665 | if (bn2crparam(rsa->q, &kop.crk_param[1])) | ||
| 666 | goto err; | ||
| 667 | if (bn2crparam(I, &kop.crk_param[2])) | ||
| 668 | goto err; | ||
| 669 | if (bn2crparam(rsa->dmp1, &kop.crk_param[3])) | ||
| 670 | goto err; | ||
| 671 | if (bn2crparam(rsa->dmq1, &kop.crk_param[4])) | ||
| 672 | goto err; | ||
| 673 | if (bn2crparam(rsa->iqmp, &kop.crk_param[5])) | ||
| 674 | goto err; | ||
| 675 | kop.crk_iparams = 6; | ||
| 676 | |||
| 677 | if (cryptodev_sym(&kop, r0, NULL) == -1) { | ||
| 678 | const RSA_METHOD *meth = RSA_PKCS1_SSLeay(); | ||
| 679 | |||
| 680 | ret = (*meth->rsa_mod_exp)(r0, I, rsa); | ||
| 681 | } | ||
| 682 | err: | ||
| 683 | zapparams(&kop); | ||
| 684 | return (ret); | ||
| 685 | } | ||
| 686 | |||
| 687 | static RSA_METHOD cryptodev_rsa = { | ||
| 688 | "cryptodev RSA method", | ||
| 689 | NULL, /* rsa_pub_enc */ | ||
| 690 | NULL, /* rsa_pub_dec */ | ||
| 691 | NULL, /* rsa_priv_enc */ | ||
| 692 | NULL, /* rsa_priv_dec */ | ||
| 693 | cryptodev_rsa_mod_exp, /* rsa_mod_exp */ | ||
| 694 | cryptodev_bn_mod_exp, /* bn_mod_exp */ | ||
| 695 | NULL, /* init */ | ||
| 696 | NULL, /* finish */ | ||
| 697 | 0, /* flags */ | ||
| 698 | NULL, /* app_data */ | ||
| 699 | NULL, /* rsa_sign */ | ||
| 700 | NULL /* rsa_verify */ | ||
| 701 | }; | ||
| 702 | |||
| 703 | static int | ||
| 704 | cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p, | ||
| 705 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) | ||
| 706 | { | ||
| 707 | return (cryptodev_bn_mod_exp(r, a, p, m, ctx, m_ctx)); | ||
| 708 | } | ||
| 709 | |||
| 710 | static DSA_SIG * | ||
| 711 | cryptodev_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) | ||
| 712 | { | ||
| 713 | struct crypt_kop kop; | ||
| 714 | BIGNUM *r = NULL, *s = NULL; | ||
| 715 | DSA_SIG *dsaret = NULL; | ||
| 716 | |||
| 717 | if ((r = BN_new()) == NULL) | ||
| 718 | goto err; | ||
| 719 | if ((s = BN_new()) == NULL) { | ||
| 720 | BN_free(r); | ||
| 721 | goto err; | ||
| 722 | } | ||
| 723 | |||
| 724 | memset(&kop, 0, sizeof kop); | ||
| 725 | kop.crk_op = CRK_DSA_SIGN; | ||
| 726 | |||
| 727 | /* inputs: dgst dsa->p dsa->q dsa->g dsa->priv_key */ | ||
| 728 | kop.crk_param[0].crp_p = (caddr_t)dgst; | ||
| 729 | kop.crk_param[0].crp_nbits = dlen * 8; | ||
| 730 | if (bn2crparam(dsa->p, &kop.crk_param[1])) | ||
| 731 | goto err; | ||
| 732 | if (bn2crparam(dsa->q, &kop.crk_param[2])) | ||
| 733 | goto err; | ||
| 734 | if (bn2crparam(dsa->g, &kop.crk_param[3])) | ||
| 735 | goto err; | ||
| 736 | if (bn2crparam(dsa->priv_key, &kop.crk_param[4])) | ||
| 737 | goto err; | ||
| 738 | kop.crk_iparams = 5; | ||
| 739 | |||
| 740 | if (cryptodev_sym(&kop, r, s) == 0) { | ||
| 741 | dsaret = DSA_SIG_new(); | ||
| 742 | dsaret->r = r; | ||
| 743 | dsaret->s = s; | ||
| 744 | } else { | ||
| 745 | const DSA_METHOD *meth = DSA_OpenSSL(); | ||
| 746 | |||
| 747 | BN_free(r); | ||
| 748 | BN_free(s); | ||
| 749 | dsaret = (meth->dsa_do_sign)(dgst, dlen, dsa); | ||
| 750 | } | ||
| 751 | err: | ||
| 752 | kop.crk_param[0].crp_p = NULL; | ||
| 753 | zapparams(&kop); | ||
| 754 | return (dsaret); | ||
| 755 | } | ||
| 756 | |||
| 757 | static int | ||
| 758 | cryptodev_dsa_verify(const unsigned char *dgst, int dlen, | ||
| 759 | DSA_SIG *sig, DSA *dsa) | ||
| 760 | { | ||
| 761 | struct crypt_kop kop; | ||
| 762 | int dsaret = 0; | ||
| 763 | |||
| 764 | memset(&kop, 0, sizeof kop); | ||
| 765 | kop.crk_op = CRK_DSA_VERIFY; | ||
| 766 | |||
| 767 | /* inputs: dgst dsa->p dsa->q dsa->g dsa->pub_key sig->r sig->s */ | ||
| 768 | kop.crk_param[0].crp_p = (caddr_t)dgst; | ||
| 769 | kop.crk_param[0].crp_nbits = dlen * 8; | ||
| 770 | if (bn2crparam(dsa->p, &kop.crk_param[1])) | ||
| 771 | goto err; | ||
| 772 | if (bn2crparam(dsa->q, &kop.crk_param[2])) | ||
| 773 | goto err; | ||
| 774 | if (bn2crparam(dsa->g, &kop.crk_param[3])) | ||
| 775 | goto err; | ||
| 776 | if (bn2crparam(dsa->pub_key, &kop.crk_param[4])) | ||
| 777 | goto err; | ||
| 778 | if (bn2crparam(sig->r, &kop.crk_param[5])) | ||
| 779 | goto err; | ||
| 780 | if (bn2crparam(sig->s, &kop.crk_param[6])) | ||
| 781 | goto err; | ||
| 782 | kop.crk_iparams = 7; | ||
| 783 | |||
| 784 | if (cryptodev_sym(&kop, NULL, NULL) == 0) { | ||
| 785 | dsaret = kop.crk_status; | ||
| 786 | } else { | ||
| 787 | const DSA_METHOD *meth = DSA_OpenSSL(); | ||
| 788 | |||
| 789 | dsaret = (meth->dsa_do_verify)(dgst, dlen, sig, dsa); | ||
| 790 | } | ||
| 791 | err: | ||
| 792 | kop.crk_param[0].crp_p = NULL; | ||
| 793 | zapparams(&kop); | ||
| 794 | return (dsaret); | ||
| 795 | } | ||
| 796 | |||
| 797 | static DSA_METHOD cryptodev_dsa = { | ||
| 798 | "cryptodev DSA method", | ||
| 799 | cryptodev_dsa_do_sign, | ||
| 800 | NULL, /* dsa_sign_setup */ | ||
| 801 | cryptodev_dsa_verify, | ||
| 802 | NULL, /* dsa_mod_exp */ | ||
| 803 | cryptodev_dsa_bn_mod_exp, /* bn_mod_exp */ | ||
| 804 | NULL, /* init */ | ||
| 805 | NULL, /* finish */ | ||
| 806 | 0, /* flags */ | ||
| 807 | NULL /* app_data */ | ||
| 808 | }; | ||
| 809 | |||
| 810 | static int | ||
| 811 | cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a, | ||
| 812 | const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, | ||
| 813 | BN_MONT_CTX *m_ctx) | ||
| 814 | { | ||
| 815 | return (cryptodev_bn_mod_exp(r, a, p, m, ctx, m_ctx)); | ||
| 816 | } | ||
| 817 | |||
| 818 | static int | ||
| 819 | cryptodev_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh) | ||
| 820 | { | ||
| 821 | struct crypt_kop kop; | ||
| 822 | int dhret = 0; | ||
| 823 | int keylen; | ||
| 824 | |||
| 825 | keylen = BN_num_bits(dh->p); | ||
| 826 | |||
| 827 | memset(&kop, 0, sizeof kop); | ||
| 828 | kop.crk_op = CRK_DH_COMPUTE_KEY; | ||
| 829 | |||
| 830 | /* inputs: dh->priv_key pub_key dh->p key */ | ||
| 831 | if (bn2crparam(dh->priv_key, &kop.crk_param[0])) | ||
| 832 | goto err; | ||
| 833 | if (bn2crparam(pub_key, &kop.crk_param[1])) | ||
| 834 | goto err; | ||
| 835 | if (bn2crparam(dh->p, &kop.crk_param[2])) | ||
| 836 | goto err; | ||
| 837 | kop.crk_iparams = 3; | ||
| 838 | |||
| 839 | kop.crk_param[3].crp_p = key; | ||
| 840 | kop.crk_param[3].crp_nbits = keylen * 8; | ||
| 841 | kop.crk_oparams = 1; | ||
| 842 | |||
| 843 | if (ioctl(cryptodev_fd, CIOCKEY, &kop) == -1) { | ||
| 844 | const DH_METHOD *meth = DH_OpenSSL(); | ||
| 845 | |||
| 846 | dhret = (meth->compute_key)(key, pub_key, dh); | ||
| 847 | } | ||
| 848 | err: | ||
| 849 | kop.crk_param[3].crp_p = NULL; | ||
| 850 | zapparams(&kop); | ||
| 851 | return (dhret); | ||
| 852 | } | ||
| 853 | |||
| 854 | static DH_METHOD cryptodev_dh = { | ||
| 855 | "cryptodev DH method", | ||
| 856 | NULL, /* cryptodev_dh_generate_key */ | ||
| 857 | cryptodev_dh_compute_key, | ||
| 858 | cryptodev_mod_exp_dh, | ||
| 859 | NULL, | ||
| 860 | NULL, | ||
| 861 | 0, /* flags */ | ||
| 862 | NULL /* app_data */ | ||
| 863 | }; | ||
| 864 | |||
| 865 | /* | ||
| 866 | * ctrl right now is just a wrapper that doesn't do much | ||
| 867 | * but I expect we'll want some options soon. | ||
| 868 | */ | ||
| 869 | static int | ||
| 870 | cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) | ||
| 871 | { | ||
| 872 | struct syslog_data sd = SYSLOG_DATA_INIT; | ||
| 873 | |||
| 874 | switch (cmd) { | ||
| 875 | default: | ||
| 876 | syslog_r(LOG_ERR, &sd, | ||
| 877 | "cryptodev_ctrl: unknown command %d", cmd); | ||
| 878 | break; | ||
| 879 | } | ||
| 880 | return (1); | ||
| 881 | } | ||
| 882 | |||
| 883 | void | ||
| 884 | ENGINE_load_cryptodev(void) | ||
| 885 | { | ||
| 886 | ENGINE *engine = ENGINE_new(); | ||
| 887 | const RSA_METHOD *rsa_meth; | ||
| 888 | const DH_METHOD *dh_meth; | ||
| 889 | |||
| 890 | if (engine == NULL) | ||
| 891 | return; | ||
| 892 | |||
| 893 | if (!ENGINE_set_id(engine, "cryptodev") || | ||
| 894 | !ENGINE_set_name(engine, "OpenBSD cryptodev engine") || | ||
| 895 | !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) || | ||
| 896 | !ENGINE_set_digests(engine, cryptodev_engine_digests) || | ||
| 897 | !ENGINE_set_ctrl_function(engine, cryptodev_ctrl) || | ||
| 898 | !ENGINE_set_cmd_defns(engine, cryptodev_defns)) { | ||
| 899 | ENGINE_free(engine); | ||
| 900 | return; | ||
| 901 | } | ||
| 902 | |||
| 903 | if ((cryptodev_symfeat & CRSFEAT_RSA) && | ||
| 904 | ENGINE_set_RSA(engine, &cryptodev_rsa)) { | ||
| 905 | rsa_meth = RSA_PKCS1_SSLeay(); | ||
| 906 | cryptodev_rsa.rsa_pub_enc = rsa_meth->rsa_pub_enc; | ||
| 907 | cryptodev_rsa.rsa_pub_dec = rsa_meth->rsa_pub_dec; | ||
| 908 | cryptodev_rsa.rsa_priv_enc = rsa_meth->rsa_priv_dec; | ||
| 909 | cryptodev_rsa.rsa_priv_dec = rsa_meth->rsa_priv_dec; | ||
| 910 | } | ||
| 911 | |||
| 912 | if ((cryptodev_symfeat & CRSFEAT_DSA) && | ||
| 913 | ENGINE_set_DSA(engine, &cryptodev_dsa)) { | ||
| 914 | } | ||
| 915 | |||
| 916 | if ((cryptodev_symfeat & CRSFEAT_DH) && | ||
| 917 | ENGINE_set_DH(engine, &cryptodev_dh)) { | ||
| 918 | dh_meth = DH_OpenSSL(); | ||
| 919 | cryptodev_dh.generate_key = dh_meth->generate_key; | ||
| 920 | cryptodev_dh.compute_key = dh_meth->compute_key; | ||
| 921 | } | ||
| 922 | |||
| 923 | ENGINE_add(engine); | ||
| 924 | ENGINE_free(engine); | ||
| 925 | ERR_clear_error(); | ||
| 926 | } | ||
diff --git a/src/lib/libcrypto/engine/hw_openbsd_dev_crypto.c b/src/lib/libcrypto/engine/hw_openbsd_dev_crypto.c new file mode 100644 index 0000000000..f946389b8a --- /dev/null +++ b/src/lib/libcrypto/engine/hw_openbsd_dev_crypto.c | |||
| @@ -0,0 +1,594 @@ | |||
| 1 | /* Written by Ben Laurie <ben@algroup.co.uk> August 2001 */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * licensing@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | |||
| 56 | #include <openssl/engine.h> | ||
| 57 | #include <openssl/evp.h> | ||
| 58 | #include "eng_int.h" | ||
| 59 | /* Maybe this is needed? ... */ | ||
| 60 | #ifdef FLAT_INC | ||
| 61 | #include "evp_locl.h" | ||
| 62 | #else | ||
| 63 | #include "../evp/evp_locl.h" | ||
| 64 | #endif | ||
| 65 | #include <openssl/conf.h> | ||
| 66 | |||
| 67 | #ifndef OPENSSL_OPENBSD_DEV_CRYPTO | ||
| 68 | |||
| 69 | void ENGINE_load_openbsd_dev_crypto(void) | ||
| 70 | { | ||
| 71 | /* This is a NOP unless OPENSSL_OPENBSD_DEV_CRYPTO is defined */ | ||
| 72 | return; | ||
| 73 | } | ||
| 74 | |||
| 75 | #else /* OPENSSL_OPENBSD_DEV_CRYPTO */ | ||
| 76 | |||
| 77 | #include <fcntl.h> | ||
| 78 | #include <stdio.h> | ||
| 79 | #include <errno.h> | ||
| 80 | #include <assert.h> | ||
| 81 | #include <unistd.h> | ||
| 82 | #include <sys/ioctl.h> | ||
| 83 | |||
| 84 | #include <crypto/cryptodev.h> | ||
| 85 | |||
| 86 | /****************************************************/ | ||
| 87 | /* Declare the normal generic ENGINE stuff here ... */ | ||
| 88 | |||
| 89 | static int dev_crypto_ciphers(ENGINE *e, const EVP_CIPHER **cipher, | ||
| 90 | const int **nids, int nid); | ||
| 91 | static int dev_crypto_digests(ENGINE *e, const EVP_MD **digest, | ||
| 92 | const int **nids, int nid); | ||
| 93 | |||
| 94 | static const char dev_crypto_id[] = "openbsd_dev_crypto"; | ||
| 95 | static const char dev_crypto_name[] = "OpenBSD /dev/crypto"; | ||
| 96 | |||
| 97 | static long allow_misaligned; | ||
| 98 | |||
| 99 | #define DEV_CRYPTO_CMD_ALLOW_MISALIGNED ENGINE_CMD_BASE | ||
| 100 | static const ENGINE_CMD_DEFN dev_crypto_cmd_defns[]= | ||
| 101 | { | ||
| 102 | { DEV_CRYPTO_CMD_ALLOW_MISALIGNED, | ||
| 103 | "allow_misaligned", | ||
| 104 | "Permit misaligned data to be used", | ||
| 105 | ENGINE_CMD_FLAG_NUMERIC }, | ||
| 106 | { 0, NULL, NULL, 0 } | ||
| 107 | }; | ||
| 108 | |||
| 109 | static int dev_crypto_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) | ||
| 110 | { | ||
| 111 | switch(cmd) | ||
| 112 | { | ||
| 113 | case DEV_CRYPTO_CMD_ALLOW_MISALIGNED: | ||
| 114 | allow_misaligned=i; | ||
| 115 | printf("allow misaligned=%ld\n",allow_misaligned); | ||
| 116 | break; | ||
| 117 | } | ||
| 118 | |||
| 119 | return 1; | ||
| 120 | } | ||
| 121 | |||
| 122 | static ENGINE *engine_openbsd_dev_crypto(void) | ||
| 123 | { | ||
| 124 | ENGINE *engine=ENGINE_new(); | ||
| 125 | |||
| 126 | if(!ENGINE_set_id(engine, dev_crypto_id) || | ||
| 127 | !ENGINE_set_name(engine, dev_crypto_name) || | ||
| 128 | !ENGINE_set_ciphers(engine, dev_crypto_ciphers) || | ||
| 129 | !ENGINE_set_digests(engine, dev_crypto_digests) || | ||
| 130 | !ENGINE_set_ctrl_function(engine, dev_crypto_ctrl) || | ||
| 131 | !ENGINE_set_cmd_defns(engine, dev_crypto_cmd_defns)) | ||
| 132 | { | ||
| 133 | ENGINE_free(engine); | ||
| 134 | return NULL; | ||
| 135 | } | ||
| 136 | |||
| 137 | return engine; | ||
| 138 | } | ||
| 139 | |||
| 140 | void ENGINE_load_openbsd_dev_crypto(void) | ||
| 141 | { | ||
| 142 | /* Copied from eng_[openssl|dyn].c */ | ||
| 143 | ENGINE *toadd = engine_openbsd_dev_crypto(); | ||
| 144 | if(!toadd) return; | ||
| 145 | ENGINE_add(toadd); | ||
| 146 | ENGINE_free(toadd); | ||
| 147 | ERR_clear_error(); | ||
| 148 | } | ||
| 149 | |||
| 150 | /******************************************************************************/ | ||
| 151 | /* Clip in the stuff from crypto/evp/openbsd_hw.c here. NB: What has changed? */ | ||
| 152 | /* I've removed the exposed EVP_*** functions, they're accessed through the */ | ||
| 153 | /* "dev_crypto_[ciphers|digests]" handlers. I've also moved the EVP_CIPHER */ | ||
| 154 | /* and EVP_MD structures to the bottom where they are close to the handlers */ | ||
| 155 | /* that expose them. What should be done? The global data (file-descriptors, */ | ||
| 156 | /* etc) should be put into ENGINE's ex_data support, and per-context data */ | ||
| 157 | /* (also file-descriptors perhaps) should be put into the contexts. Also code */ | ||
| 158 | /* formatting, fprintf statements, and OpenSSL-style error handling should be */ | ||
| 159 | /* added (dynamically, like the other ENGINEs). Also, "dynamic" support */ | ||
| 160 | /* be added to this ENGINE once it's up and running so that it could be built */ | ||
| 161 | /* as a shared-library. What else? device initialisation should take place */ | ||
| 162 | /* inside an ENGINE 'init()' handler (and likewise 'finish()'). ciphers and */ | ||
| 163 | /* digests won't be used by the framework unless the ENGINE has been */ | ||
| 164 | /* successfully initialised (that's one of the things you get for free) so */ | ||
| 165 | /* initialisation, including returning failure if device setup fails, can be */ | ||
| 166 | /* handled quite cleanly. This could presumably handle the opening (and then */ | ||
| 167 | /* closing inside 'finish()') of the 'cryptodev_fd' file-descriptor). */ | ||
| 168 | |||
| 169 | /* longest key supported in hardware */ | ||
| 170 | #define MAX_HW_KEY 24 | ||
| 171 | #define MAX_HW_IV 8 | ||
| 172 | |||
| 173 | #define MD5_DIGEST_LENGTH 16 | ||
| 174 | #define MD5_CBLOCK 64 | ||
| 175 | |||
| 176 | static int fd; | ||
| 177 | static int dev_failed; | ||
| 178 | |||
| 179 | typedef struct session_op session_op; | ||
| 180 | |||
| 181 | #define CDATA(ctx) EVP_C_DATA(session_op,ctx) | ||
| 182 | |||
| 183 | static void err(const char *str) | ||
| 184 | { | ||
| 185 | fprintf(stderr,"%s: errno %d\n",str,errno); | ||
| 186 | } | ||
| 187 | |||
| 188 | static int dev_crypto_init(session_op *ses) | ||
| 189 | { | ||
| 190 | if(dev_failed) | ||
| 191 | return 0; | ||
| 192 | if(!fd) | ||
| 193 | { | ||
| 194 | int cryptodev_fd; | ||
| 195 | |||
| 196 | if ((cryptodev_fd=open("/dev/crypto",O_RDWR,0)) < 0) | ||
| 197 | { | ||
| 198 | err("/dev/crypto"); | ||
| 199 | dev_failed=1; | ||
| 200 | return 0; | ||
| 201 | } | ||
| 202 | if (ioctl(cryptodev_fd,CRIOGET,&fd) == -1) | ||
| 203 | { | ||
| 204 | err("CRIOGET failed"); | ||
| 205 | close(cryptodev_fd); | ||
| 206 | dev_failed=1; | ||
| 207 | return 0; | ||
| 208 | } | ||
| 209 | close(cryptodev_fd); | ||
| 210 | } | ||
| 211 | assert(ses); | ||
| 212 | memset(ses,'\0',sizeof *ses); | ||
| 213 | |||
| 214 | return 1; | ||
| 215 | } | ||
| 216 | |||
| 217 | static int dev_crypto_cleanup(EVP_CIPHER_CTX *ctx) | ||
| 218 | { | ||
| 219 | fprintf(stderr,"cleanup %d\n",CDATA(ctx)->ses); | ||
| 220 | if(ioctl(fd,CIOCFSESSION,&CDATA(ctx)->ses) == -1) | ||
| 221 | err("CIOCFSESSION failed"); | ||
| 222 | |||
| 223 | OPENSSL_free(CDATA(ctx)->key); | ||
| 224 | |||
| 225 | return 1; | ||
| 226 | } | ||
| 227 | |||
| 228 | static int dev_crypto_init_key(EVP_CIPHER_CTX *ctx,int cipher, | ||
| 229 | const unsigned char *key,int klen) | ||
| 230 | { | ||
| 231 | if(!dev_crypto_init(CDATA(ctx))) | ||
| 232 | return 0; | ||
| 233 | |||
| 234 | CDATA(ctx)->key=OPENSSL_malloc(MAX_HW_KEY); | ||
| 235 | |||
| 236 | assert(ctx->cipher->iv_len <= MAX_HW_IV); | ||
| 237 | |||
| 238 | memcpy(CDATA(ctx)->key,key,klen); | ||
| 239 | |||
| 240 | CDATA(ctx)->cipher=cipher; | ||
| 241 | CDATA(ctx)->keylen=klen; | ||
| 242 | |||
| 243 | if (ioctl(fd,CIOCGSESSION,CDATA(ctx)) == -1) | ||
| 244 | { | ||
| 245 | err("CIOCGSESSION failed"); | ||
| 246 | return 0; | ||
| 247 | } | ||
| 248 | return 1; | ||
| 249 | } | ||
| 250 | |||
| 251 | static int dev_crypto_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out, | ||
| 252 | const unsigned char *in,unsigned int inl) | ||
| 253 | { | ||
| 254 | struct crypt_op cryp; | ||
| 255 | unsigned char lb[MAX_HW_IV]; | ||
| 256 | |||
| 257 | if(!inl) | ||
| 258 | return 1; | ||
| 259 | |||
| 260 | assert(CDATA(ctx)); | ||
| 261 | assert(!dev_failed); | ||
| 262 | |||
| 263 | memset(&cryp,'\0',sizeof cryp); | ||
| 264 | cryp.ses=CDATA(ctx)->ses; | ||
| 265 | cryp.op=ctx->encrypt ? COP_ENCRYPT : COP_DECRYPT; | ||
| 266 | cryp.flags=0; | ||
| 267 | cryp.len=inl; | ||
| 268 | assert((inl&(ctx->cipher->block_size-1)) == 0); | ||
| 269 | cryp.src=(caddr_t)in; | ||
| 270 | cryp.dst=(caddr_t)out; | ||
| 271 | cryp.mac=0; | ||
| 272 | if(ctx->cipher->iv_len) | ||
| 273 | cryp.iv=(caddr_t)ctx->iv; | ||
| 274 | |||
| 275 | if(!ctx->encrypt) | ||
| 276 | memcpy(lb,&in[cryp.len-ctx->cipher->iv_len],ctx->cipher->iv_len); | ||
| 277 | |||
| 278 | if(ioctl(fd, CIOCCRYPT, &cryp) == -1) | ||
| 279 | { | ||
| 280 | if(errno == EINVAL) /* buffers are misaligned */ | ||
| 281 | { | ||
| 282 | unsigned int cinl=0; | ||
| 283 | char *cin=NULL; | ||
| 284 | char *cout=NULL; | ||
| 285 | |||
| 286 | /* NB: this can only make cinl != inl with stream ciphers */ | ||
| 287 | cinl=(inl+3)/4*4; | ||
| 288 | |||
| 289 | if(((unsigned long)in&3) || cinl != inl) | ||
| 290 | { | ||
| 291 | cin=OPENSSL_malloc(cinl); | ||
| 292 | memcpy(cin,in,inl); | ||
| 293 | cryp.src=cin; | ||
| 294 | } | ||
| 295 | |||
| 296 | if(((unsigned long)out&3) || cinl != inl) | ||
| 297 | { | ||
| 298 | cout=OPENSSL_malloc(cinl); | ||
| 299 | cryp.dst=cout; | ||
| 300 | } | ||
| 301 | |||
| 302 | cryp.len=cinl; | ||
| 303 | |||
| 304 | if(ioctl(fd, CIOCCRYPT, &cryp) == -1) | ||
| 305 | { | ||
| 306 | err("CIOCCRYPT(2) failed"); | ||
| 307 | printf("src=%p dst=%p\n",cryp.src,cryp.dst); | ||
| 308 | abort(); | ||
| 309 | return 0; | ||
| 310 | } | ||
| 311 | |||
| 312 | if(cout) | ||
| 313 | { | ||
| 314 | memcpy(out,cout,inl); | ||
| 315 | OPENSSL_free(cout); | ||
| 316 | } | ||
| 317 | if(cin) | ||
| 318 | OPENSSL_free(cin); | ||
| 319 | } | ||
| 320 | else | ||
| 321 | { | ||
| 322 | err("CIOCCRYPT failed"); | ||
| 323 | abort(); | ||
| 324 | return 0; | ||
| 325 | } | ||
| 326 | } | ||
| 327 | |||
| 328 | if(ctx->encrypt) | ||
| 329 | memcpy(ctx->iv,&out[cryp.len-ctx->cipher->iv_len],ctx->cipher->iv_len); | ||
| 330 | else | ||
| 331 | memcpy(ctx->iv,lb,ctx->cipher->iv_len); | ||
| 332 | |||
| 333 | return 1; | ||
| 334 | } | ||
| 335 | |||
| 336 | static int dev_crypto_des_ede3_init_key(EVP_CIPHER_CTX *ctx, | ||
| 337 | const unsigned char *key, | ||
| 338 | const unsigned char *iv, int enc) | ||
| 339 | { return dev_crypto_init_key(ctx,CRYPTO_3DES_CBC,key,24); } | ||
| 340 | |||
| 341 | static int dev_crypto_rc4_init_key(EVP_CIPHER_CTX *ctx, | ||
| 342 | const unsigned char *key, | ||
| 343 | const unsigned char *iv, int enc) | ||
| 344 | { return dev_crypto_init_key(ctx,CRYPTO_ARC4,key,16); } | ||
| 345 | |||
| 346 | typedef struct | ||
| 347 | { | ||
| 348 | session_op sess; | ||
| 349 | char *data; | ||
| 350 | int len; | ||
| 351 | unsigned char md[EVP_MAX_MD_SIZE]; | ||
| 352 | } MD_DATA; | ||
| 353 | |||
| 354 | static int dev_crypto_init_digest(MD_DATA *md_data,int mac) | ||
| 355 | { | ||
| 356 | if(!dev_crypto_init(&md_data->sess)) | ||
| 357 | return 0; | ||
| 358 | |||
| 359 | md_data->len=0; | ||
| 360 | md_data->data=NULL; | ||
| 361 | |||
| 362 | md_data->sess.mac=mac; | ||
| 363 | |||
| 364 | if (ioctl(fd,CIOCGSESSION,&md_data->sess) == -1) | ||
| 365 | { | ||
| 366 | err("CIOCGSESSION failed"); | ||
| 367 | return 0; | ||
| 368 | } | ||
| 369 | fprintf(stderr,"opened %d\n",md_data->sess.ses); | ||
| 370 | return 1; | ||
| 371 | } | ||
| 372 | |||
| 373 | static int dev_crypto_cleanup_digest(MD_DATA *md_data) | ||
| 374 | { | ||
| 375 | fprintf(stderr,"cleanup %d\n",md_data->sess.ses); | ||
| 376 | if (ioctl(fd,CIOCFSESSION,&md_data->sess.ses) == -1) | ||
| 377 | { | ||
| 378 | err("CIOCFSESSION failed"); | ||
| 379 | return 0; | ||
| 380 | } | ||
| 381 | |||
| 382 | return 1; | ||
| 383 | } | ||
| 384 | |||
| 385 | /* FIXME: if device can do chained MACs, then don't accumulate */ | ||
| 386 | /* FIXME: move accumulation to the framework */ | ||
| 387 | static int dev_crypto_md5_init(EVP_MD_CTX *ctx) | ||
| 388 | { return dev_crypto_init_digest(ctx->md_data,CRYPTO_MD5); } | ||
| 389 | |||
| 390 | static int do_digest(int ses,unsigned char *md,const void *data,int len) | ||
| 391 | { | ||
| 392 | struct crypt_op cryp; | ||
| 393 | static unsigned char md5zero[16]= | ||
| 394 | { | ||
| 395 | 0xd4,0x1d,0x8c,0xd9,0x8f,0x00,0xb2,0x04, | ||
| 396 | 0xe9,0x80,0x09,0x98,0xec,0xf8,0x42,0x7e | ||
| 397 | }; | ||
| 398 | |||
| 399 | /* some cards can't do zero length */ | ||
| 400 | if(!len) | ||
| 401 | { | ||
| 402 | memcpy(md,md5zero,16); | ||
| 403 | return 1; | ||
| 404 | } | ||
| 405 | |||
| 406 | memset(&cryp,'\0',sizeof cryp); | ||
| 407 | cryp.ses=ses; | ||
| 408 | cryp.op=COP_ENCRYPT;/* required to do the MAC rather than check it */ | ||
| 409 | cryp.len=len; | ||
| 410 | cryp.src=(caddr_t)data; | ||
| 411 | cryp.dst=(caddr_t)data; // FIXME!!! | ||
| 412 | cryp.mac=(caddr_t)md; | ||
| 413 | |||
| 414 | if(ioctl(fd, CIOCCRYPT, &cryp) == -1) | ||
| 415 | { | ||
| 416 | if(errno == EINVAL && allow_misaligned) /* buffer is misaligned */ | ||
| 417 | { | ||
| 418 | char *dcopy; | ||
| 419 | |||
| 420 | dcopy=OPENSSL_malloc(len); | ||
| 421 | memcpy(dcopy,data,len); | ||
| 422 | cryp.src=dcopy; | ||
| 423 | cryp.dst=cryp.src; // FIXME!!! | ||
| 424 | |||
| 425 | if(ioctl(fd, CIOCCRYPT, &cryp) == -1) | ||
| 426 | { | ||
| 427 | err("CIOCCRYPT(MAC2) failed"); | ||
| 428 | abort(); | ||
| 429 | return 0; | ||
| 430 | } | ||
| 431 | OPENSSL_free(dcopy); | ||
| 432 | } | ||
| 433 | else | ||
| 434 | { | ||
| 435 | err("CIOCCRYPT(MAC) failed"); | ||
| 436 | abort(); | ||
| 437 | return 0; | ||
| 438 | } | ||
| 439 | } | ||
| 440 | // printf("done\n"); | ||
| 441 | |||
| 442 | return 1; | ||
| 443 | } | ||
| 444 | |||
| 445 | static int dev_crypto_md5_update(EVP_MD_CTX *ctx,const void *data, | ||
| 446 | unsigned long len) | ||
| 447 | { | ||
| 448 | MD_DATA *md_data=ctx->md_data; | ||
| 449 | |||
| 450 | if(ctx->flags&EVP_MD_CTX_FLAG_ONESHOT) | ||
| 451 | return do_digest(md_data->sess.ses,md_data->md,data,len); | ||
| 452 | |||
| 453 | md_data->data=OPENSSL_realloc(md_data->data,md_data->len+len); | ||
| 454 | memcpy(md_data->data+md_data->len,data,len); | ||
| 455 | md_data->len+=len; | ||
| 456 | |||
| 457 | return 1; | ||
| 458 | } | ||
| 459 | |||
| 460 | static int dev_crypto_md5_final(EVP_MD_CTX *ctx,unsigned char *md) | ||
| 461 | { | ||
| 462 | int ret; | ||
| 463 | MD_DATA *md_data=ctx->md_data; | ||
| 464 | |||
| 465 | if(ctx->flags&EVP_MD_CTX_FLAG_ONESHOT) | ||
| 466 | { | ||
| 467 | memcpy(md,md_data->md,MD5_DIGEST_LENGTH); | ||
| 468 | ret=1; | ||
| 469 | } | ||
| 470 | else | ||
| 471 | { | ||
| 472 | ret=do_digest(md_data->sess.ses,md,md_data->data,md_data->len); | ||
| 473 | OPENSSL_free(md_data->data); | ||
| 474 | md_data->data=NULL; | ||
| 475 | md_data->len=0; | ||
| 476 | } | ||
| 477 | |||
| 478 | return ret; | ||
| 479 | } | ||
| 480 | |||
| 481 | static int dev_crypto_md5_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from) | ||
| 482 | { | ||
| 483 | const MD_DATA *from_md=from->md_data; | ||
| 484 | MD_DATA *to_md=to->md_data; | ||
| 485 | |||
| 486 | // How do we copy sessions? | ||
| 487 | assert(from->digest->flags&EVP_MD_FLAG_ONESHOT); | ||
| 488 | |||
| 489 | to_md->data=OPENSSL_malloc(from_md->len); | ||
| 490 | memcpy(to_md->data,from_md->data,from_md->len); | ||
| 491 | |||
| 492 | return 1; | ||
| 493 | } | ||
| 494 | |||
| 495 | static int dev_crypto_md5_cleanup(EVP_MD_CTX *ctx) | ||
| 496 | { | ||
| 497 | return dev_crypto_cleanup_digest(ctx->md_data); | ||
| 498 | } | ||
| 499 | |||
| 500 | /**************************************************************************/ | ||
| 501 | /* Here are the moved declarations of the EVP_CIPHER and EVP_MD */ | ||
| 502 | /* implementations. They're down here to be within easy editor-distance */ | ||
| 503 | /* of the digests and ciphers handler functions. */ | ||
| 504 | |||
| 505 | #define dev_crypto_des_ede3_cbc_cipher dev_crypto_cipher | ||
| 506 | |||
| 507 | BLOCK_CIPHER_def_cbc(dev_crypto_des_ede3, session_op, NID_des_ede3, 8, 24, 8, | ||
| 508 | 0, dev_crypto_des_ede3_init_key, | ||
| 509 | dev_crypto_cleanup, | ||
| 510 | EVP_CIPHER_set_asn1_iv, | ||
| 511 | EVP_CIPHER_get_asn1_iv, | ||
| 512 | NULL) | ||
| 513 | |||
| 514 | static const EVP_CIPHER r4_cipher= | ||
| 515 | { | ||
| 516 | NID_rc4, | ||
| 517 | 1,16,0, /* FIXME: key should be up to 256 bytes */ | ||
| 518 | EVP_CIPH_VARIABLE_LENGTH, | ||
| 519 | dev_crypto_rc4_init_key, | ||
| 520 | dev_crypto_cipher, | ||
| 521 | dev_crypto_cleanup, | ||
| 522 | sizeof(session_op), | ||
| 523 | NULL, | ||
| 524 | NULL, | ||
| 525 | NULL | ||
| 526 | }; | ||
| 527 | |||
| 528 | static const EVP_MD md5_md= | ||
| 529 | { | ||
| 530 | NID_md5, | ||
| 531 | NID_md5WithRSAEncryption, | ||
| 532 | MD5_DIGEST_LENGTH, | ||
| 533 | EVP_MD_FLAG_ONESHOT, // XXX: set according to device info... | ||
| 534 | dev_crypto_md5_init, | ||
| 535 | dev_crypto_md5_update, | ||
| 536 | dev_crypto_md5_final, | ||
| 537 | dev_crypto_md5_copy, | ||
| 538 | dev_crypto_md5_cleanup, | ||
| 539 | EVP_PKEY_RSA_method, | ||
| 540 | MD5_CBLOCK, | ||
| 541 | sizeof(MD_DATA), | ||
| 542 | }; | ||
| 543 | |||
| 544 | /****************************************************************/ | ||
| 545 | /* Implement the dev_crypto_[ciphers|digests] handlers here ... */ | ||
| 546 | |||
| 547 | static int cipher_nids[] = {NID_des_ede3_cbc, NID_rc4}; | ||
| 548 | static int cipher_nids_num = 2; | ||
| 549 | static int digest_nids[] = {NID_md5}; | ||
| 550 | static int digest_nids_num = 1; | ||
| 551 | |||
| 552 | static int dev_crypto_ciphers(ENGINE *e, const EVP_CIPHER **cipher, | ||
| 553 | const int **nids, int nid) | ||
| 554 | { | ||
| 555 | if(!cipher) | ||
| 556 | { | ||
| 557 | /* We are returning a list of supported nids */ | ||
| 558 | *nids = cipher_nids; | ||
| 559 | return cipher_nids_num; | ||
| 560 | } | ||
| 561 | /* We are being asked for a specific cipher */ | ||
| 562 | if(nid == NID_rc4) | ||
| 563 | *cipher = &r4_cipher; | ||
| 564 | else if(nid == NID_des_ede3_cbc) | ||
| 565 | *cipher = &dev_crypto_des_ede3_cbc; | ||
| 566 | else | ||
| 567 | { | ||
| 568 | *cipher = NULL; | ||
| 569 | return 0; | ||
| 570 | } | ||
| 571 | return 1; | ||
| 572 | } | ||
| 573 | |||
| 574 | static int dev_crypto_digests(ENGINE *e, const EVP_MD **digest, | ||
| 575 | const int **nids, int nid) | ||
| 576 | { | ||
| 577 | if(!digest) | ||
| 578 | { | ||
| 579 | /* We are returning a list of supported nids */ | ||
| 580 | *nids = digest_nids; | ||
| 581 | return digest_nids_num; | ||
| 582 | } | ||
| 583 | /* We are being asked for a specific digest */ | ||
| 584 | if(nid == NID_md5) | ||
| 585 | *digest = &md5_md; | ||
| 586 | else | ||
| 587 | { | ||
| 588 | *digest = NULL; | ||
| 589 | return 0; | ||
| 590 | } | ||
| 591 | return 1; | ||
| 592 | } | ||
| 593 | |||
| 594 | #endif /* OPENSSL_OPENBSD_DEV_CRYPTO */ | ||
