4002N/A#
4002N/A# Patch developed in-house. Solaris-specific; not suitable for upstream.
4002N/A#
363N/A--- openssl-0.9.8m/apps/openssl.c Thu Oct 15 19:28:02 2009
363N/A+++ openssl-0.9.8m/apps/openssl.c Fri Feb 26 16:12:30 2010
4002N/A@@ -135,6 +135,9 @@
4002N/A # include <openssl/fips.h>
2208N/A #endif
363N/A
363N/A+/* Solaris OpenSSL */
363N/A+#include <dlfcn.h>
363N/A+
4002N/A /*
4002N/A * The LHASH callbacks ("hash" & "cmp") have been replaced by functions with
4002N/A * the base prototypes (we cast each variable inside the function to the
4002N/A@@ -155,9 +158,10 @@
4002N/A BIO *bio_err = NULL;
363N/A #endif
363N/A
363N/A+static int *modes;
363N/A+
363N/A static void lock_dbg_cb(int mode, int type, const char *file, int line)
4002N/A {
4002N/A- static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */
4002N/A const char *errstr = NULL;
4002N/A int rw;
4002N/A
4002N/A@@ -167,7 +168,7 @@
4002N/A goto err;
4002N/A }
363N/A
4002N/A- if (type < 0 || type >= CRYPTO_NUM_LOCKS) {
4002N/A+ if (type < 0 || type >= CRYPTO_num_locks()) {
4002N/A errstr = "type out of bounds";
4002N/A goto err;
4002N/A }
4002N/A@@ -305,6 +306,14 @@
4002N/A if (getenv("OPENSSL_DEBUG_LOCKING") != NULL)
2208N/A #endif
4002N/A {
4002N/A+ modes = OPENSSL_malloc(CRYPTO_num_locks() * sizeof (int));
4002N/A+ if (modes == NULL) {
4002N/A+ ERR_load_crypto_strings();
4002N/A+ BIO_printf(bio_err,"Memory allocation failure\n");
4002N/A+ ERR_print_errors(bio_err);
4002N/A+ EXIT(1);
4002N/A+ }
4002N/A+ memset(modes, 0, CRYPTO_num_locks() * sizeof (int));
4002N/A CRYPTO_set_locking_callback(lock_dbg_cb);
4002N/A }
363N/A
4002N/A@@ -308,18 +320,28 @@
4002N/A CRYPTO_set_locking_callback(lock_dbg_cb);
4002N/A }
363N/A
363N/A+/*
363N/A+ * Solaris OpenSSL
363N/A+ * Add a further check for the FIPS_mode_set() symbol before calling to
363N/A+ * allow openssl(1openssl) to be run against both fips and non-fips libraries.
363N/A+ */
4002N/A if (getenv("OPENSSL_FIPS")) {
363N/A-#ifdef OPENSSL_FIPS
4002N/A- if (!FIPS_mode_set(1)) {
363N/A+
4002N/A+ int (*FIPS_mode_set)(int);
4002N/A+ FIPS_mode_set = (int (*)(int)) dlsym(RTLD_NEXT, "FIPS_mode_set");
363N/A+
4002N/A+ if (FIPS_mode_set != NULL) {
4002N/A+ if (!(*FIPS_mode_set)(1)) {
4002N/A ERR_load_crypto_strings();
4002N/A ERR_print_errors(BIO_new_fp(stderr, BIO_NOCLOSE));
4002N/A EXIT(1);
4002N/A }
363N/A-#else
4002N/A- fprintf(stderr, "FIPS mode not supported.\n");
4002N/A+ } else {
4002N/A+ fprintf(stderr, "Failed to enable FIPS mode. "
4002N/A+ "For more information about running in FIPS mode see openssl(5).\n");
4002N/A EXIT(1);
363N/A-#endif
4002N/A }
4002N/A+ }
363N/A
4002N/A apps_startup();
363N/A