Hello,

The following modifications (or similar) are needed to enable
cryptodev support on FreeBSD (which has imported OpenBSD's
/dev/crypto).  FreeBSD's /dev/crypto is available in 5.0-RELEASE and
in 4-STABLE (and the upcoming 4.8-RELEASE).

Cheers,
-- 
Jacques A. Vidrine <[EMAIL PROTECTED]>          http://www.celabo.org/
NTT/Verio SME          .     FreeBSD UNIX     .       Heimdal Kerberos
[EMAIL PROTECTED]     .  [EMAIL PROTECTED]  .          [EMAIL PROTECTED]


diff -ru openssl-0.9.7/crypto/engine/eng_all.c openssl-0.9.7/crypto/engine/eng_all.c
--- openssl-0.9.7/crypto/engine/eng_all.c       Tue Oct  1 19:18:47 2002
+++ openssl-0.9.7/crypto/engine/eng_all.c       Mon Jan 13 06:21:33 2003
@@ -95,19 +95,19 @@
 #ifndef OPENSSL_NO_HW_4758_CCA
        ENGINE_load_4758cca();
 #endif
-#ifdef __OpenBSD__
+#if defined(__OpenBSD__) || defined(__FreeBSD__)
        ENGINE_load_cryptodev();
 #endif
 #endif
        }
 
-#ifdef __OpenBSD__
-void ENGINE_setup_openbsd(void) {
-       static int openbsd_default_loaded = 0;
-       if (!openbsd_default_loaded) {
+#if defined(__OpenBSD__) || defined(__FreeBSD__)
+void ENGINE_setup_bsd_cryptodev(void) {
+       static int bsd_cryptodev_default_loaded = 0;
+       if (!bsd_cryptodev_default_loaded) {
                ENGINE_load_cryptodev();
                ENGINE_register_all_complete();
        }
-       openbsd_default_loaded=1;
+       bsd_cryptodev_default_loaded=1;
 }
 #endif
diff -ru openssl-0.9.7/crypto/engine/hw_cryptodev.c 
openssl-0.9.7/crypto/engine/hw_cryptodev.c
--- openssl-0.9.7/crypto/engine/hw_cryptodev.c  Thu Dec  5 04:17:08 2002
+++ openssl-0.9.7/crypto/engine/hw_cryptodev.c  Mon Jan 13 09:29:09 2003
@@ -33,31 +33,28 @@
 #include <openssl/engine.h>
 #include <openssl/evp.h>
 
-#ifndef __OpenBSD__
-
-void
-ENGINE_load_cryptodev(void)
-{
-       /* This is a NOP unless __OpenBSD__ is defined */
-       return;
-}
-
-#else /* __OpenBSD__ */
-
-#include <sys/types.h>
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
 #include <sys/param.h>
+# if (OpenBSD >= 200112) || ((__FreeBSD_version >= 470101 && __FreeBSD_version < 
+50000) || __FreeBSD_version >= 50041)
+# define HAVE_CRYPTODEV
+# endif
+# if (OpenBSD >= 200110)
+# define HAVE_SYSLOG_R
+# endif
+#endif
 
-#if OpenBSD < 200112
+#ifndef HAVE_CRYPTODEV
 
 void
 ENGINE_load_cryptodev(void)
 {
-       /* This is a NOP unless we have release 3.0 (released december 2001) */
+       /* This is a NOP on platforms without /dev/crypto */
        return;
 }
 
-#else /* OpenBSD 3.0 or above */
+#else 
 
+#include <sys/types.h>
 #include <crypto/cryptodev.h>
 #include <sys/ioctl.h>
 #include <errno.h>
@@ -1032,12 +1029,18 @@
 static int
 cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
 {
+#ifdef HAVE_SYSLOG_R
        struct syslog_data sd = SYSLOG_DATA_INIT;
+#endif
 
        switch (cmd) {
        default:
+#ifdef HAVE_SYSLOG_R
                syslog_r(LOG_ERR, &sd,
                    "cryptodev_ctrl: unknown command %d", cmd);
+#else
+               syslog(LOG_ERR, "cryptodev_ctrl: unknown command %d", cmd);
+#endif
                break;
        }
        return (1);
@@ -1064,7 +1067,7 @@
        close(fd);
 
        if (!ENGINE_set_id(engine, "cryptodev") ||
-           !ENGINE_set_name(engine, "OpenBSD cryptodev engine") ||
+           !ENGINE_set_name(engine, "BSD cryptodev engine") ||
            !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) ||
            !ENGINE_set_digests(engine, cryptodev_engine_digests) ||
            !ENGINE_set_ctrl_function(engine, cryptodev_ctrl) ||
@@ -1126,5 +1129,4 @@
        ERR_clear_error();
 }
 
-#endif /* OpenBSD 3.0 or above */
-#endif /* __OpenBSD__ */
+#endif /* HAVE_CRYPTODEV */
diff -ru openssl-0.9.7/crypto/evp/c_all.c openssl-0.9.7/crypto/evp/c_all.c
--- openssl-0.9.7/crypto/evp/c_all.c    Tue Oct  1 19:18:55 2002
+++ openssl-0.9.7/crypto/evp/c_all.c    Thu Jan 16 10:39:37 2003
@@ -73,7 +73,7 @@
        {
        OpenSSL_add_all_ciphers();
        OpenSSL_add_all_digests();
-#ifdef __OpenBSD__
-       ENGINE_setup_openbsd();
+#if defined(__OpenBSD__) || defined(__FreeBSD__)
+       ENGINE_setup_bsd_cryptodev();
 #endif
        }

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to