summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/engine/hw_cryptodev.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/engine/hw_cryptodev.c')
-rw-r--r--src/lib/libcrypto/engine/hw_cryptodev.c44
1 files changed, 9 insertions, 35 deletions
diff --git a/src/lib/libcrypto/engine/hw_cryptodev.c b/src/lib/libcrypto/engine/hw_cryptodev.c
index 40af97ac24..034c7ca213 100644
--- a/src/lib/libcrypto/engine/hw_cryptodev.c
+++ b/src/lib/libcrypto/engine/hw_cryptodev.c
@@ -29,32 +29,8 @@
29 * 29 *
30 */ 30 */
31 31
32#include <openssl/objects.h>
33#include <openssl/engine.h>
34#include <openssl/evp.h>
35
36#if (defined(__unix__) || defined(unix)) && !defined(USG)
37#include <sys/param.h>
38# if (OpenBSD >= 200112) || ((__FreeBSD_version >= 470101 && __FreeBSD_version < 500000) || __FreeBSD_version >= 500041)
39# define HAVE_CRYPTODEV
40# endif
41# if (OpenBSD >= 200110)
42# define HAVE_SYSLOG_R
43# endif
44#endif
45
46#ifndef HAVE_CRYPTODEV
47
48void
49ENGINE_load_cryptodev(void)
50{
51 /* This is a NOP on platforms without /dev/crypto */
52 return;
53}
54
55#else
56
57#include <sys/types.h> 32#include <sys/types.h>
33#include <sys/param.h>
58#include <crypto/cryptodev.h> 34#include <crypto/cryptodev.h>
59#include <sys/ioctl.h> 35#include <sys/ioctl.h>
60#include <errno.h> 36#include <errno.h>
@@ -63,6 +39,9 @@ ENGINE_load_cryptodev(void)
63#include <fcntl.h> 39#include <fcntl.h>
64#include <stdarg.h> 40#include <stdarg.h>
65#include <syslog.h> 41#include <syslog.h>
42#include <ssl/objects.h>
43#include <ssl/engine.h>
44#include <ssl/evp.h>
66#include <errno.h> 45#include <errno.h>
67#include <string.h> 46#include <string.h>
68 47
@@ -122,6 +101,10 @@ static int cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p,
122void ENGINE_load_cryptodev(void); 101void ENGINE_load_cryptodev(void);
123 102
124static const ENGINE_CMD_DEFN cryptodev_defns[] = { 103static const ENGINE_CMD_DEFN cryptodev_defns[] = {
104 {ENGINE_CMD_BASE,
105 "SO_PATH",
106 "Specifies the path to the some stupid shared library",
107 ENGINE_CMD_FLAG_STRING},
125 { 0, NULL, NULL, 0 } 108 { 0, NULL, NULL, 0 }
126}; 109};
127 110
@@ -874,7 +857,6 @@ cryptodev_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
874 goto err; 857 goto err;
875 } 858 }
876 859
877 printf("bar\n");
878 memset(&kop, 0, sizeof kop); 860 memset(&kop, 0, sizeof kop);
879 kop.crk_op = CRK_DSA_SIGN; 861 kop.crk_op = CRK_DSA_SIGN;
880 862
@@ -1029,18 +1011,12 @@ static DH_METHOD cryptodev_dh = {
1029static int 1011static int
1030cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) 1012cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
1031{ 1013{
1032#ifdef HAVE_SYSLOG_R
1033 struct syslog_data sd = SYSLOG_DATA_INIT; 1014 struct syslog_data sd = SYSLOG_DATA_INIT;
1034#endif
1035 1015
1036 switch (cmd) { 1016 switch (cmd) {
1037 default: 1017 default:
1038#ifdef HAVE_SYSLOG_R
1039 syslog_r(LOG_ERR, &sd, 1018 syslog_r(LOG_ERR, &sd,
1040 "cryptodev_ctrl: unknown command %d", cmd); 1019 "cryptodev_ctrl: unknown command %d", cmd);
1041#else
1042 syslog(LOG_ERR, "cryptodev_ctrl: unknown command %d", cmd);
1043#endif
1044 break; 1020 break;
1045 } 1021 }
1046 return (1); 1022 return (1);
@@ -1067,7 +1043,7 @@ ENGINE_load_cryptodev(void)
1067 close(fd); 1043 close(fd);
1068 1044
1069 if (!ENGINE_set_id(engine, "cryptodev") || 1045 if (!ENGINE_set_id(engine, "cryptodev") ||
1070 !ENGINE_set_name(engine, "BSD cryptodev engine") || 1046 !ENGINE_set_name(engine, "OpenBSD cryptodev engine") ||
1071 !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) || 1047 !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) ||
1072 !ENGINE_set_digests(engine, cryptodev_engine_digests) || 1048 !ENGINE_set_digests(engine, cryptodev_engine_digests) ||
1073 !ENGINE_set_ctrl_function(engine, cryptodev_ctrl) || 1049 !ENGINE_set_ctrl_function(engine, cryptodev_ctrl) ||
@@ -1128,5 +1104,3 @@ ENGINE_load_cryptodev(void)
1128 ENGINE_free(engine); 1104 ENGINE_free(engine);
1129 ERR_clear_error(); 1105 ERR_clear_error();
1130} 1106}
1131
1132#endif /* HAVE_CRYPTODEV */