Use nid_list table to lookup curve IDs.
[openssl.git] / ssl / ssl_init.c
index 112def1f430cb438a3ee7318822fd71f3aaf91f8..7d89ed0a60e55349ed1da71f385f1a081784696c 100644 (file)
@@ -234,7 +234,7 @@ static void ossl_init_ssl_base(void)
      * We ignore an error return here. Not much we can do - but not that bad
      * either. We can still safely continue.
      */
-    OPENSSL_INIT_register_stop_handler(ssl_library_stop);
+    OPENSSL_atexit(ssl_library_stop);
     ssl_base_inited = 1;
 }
 
@@ -294,19 +294,32 @@ static void ssl_library_stop(void)
     }
 }
 
+
 /*
  * If this function is called with a non NULL settings value then it must be
  * called prior to any threads making calls to any OpenSSL functions,
  * i.e. passing a non-null settings value is assumed to be single-threaded.
  */
-void OPENSSL_INIT_ssl_library_start(uint64_t opts,
-                                 const OPENSSL_INIT_SETTINGS *settings)
+int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
 {
-    /* XXX TODO WARNING To be updated to return a value not assert. */
-    assert(!stopped);
+    static int stoperrset = 0;
+
+    if (stopped) {
+        if (!stoperrset) {
+            /*
+             * We only ever set this once to avoid getting into an infinite
+             * loop where the error system keeps trying to init and fails so
+             * sets an error etc
+             */
+            stoperrset = 1;
+            SSLerr(SSL_F_OPENSSL_INIT_SSL, ERR_R_INIT_FAIL);
+        }
+        return 0;
+    }
 
-    OPENSSL_INIT_crypto_library_start(opts | OPENSSL_INIT_ADD_ALL_CIPHERS
-                                   | OPENSSL_INIT_ADD_ALL_DIGESTS, settings);
+    if (!OPENSSL_init_crypto(opts | OPENSSL_INIT_ADD_ALL_CIPHERS
+                             | OPENSSL_INIT_ADD_ALL_DIGESTS, settings))
+        return 0;
 
     ossl_init_once_run(&ssl_base, ossl_init_ssl_base);
 
@@ -315,5 +328,7 @@ void OPENSSL_INIT_ssl_library_start(uint64_t opts,
 
     if (opts & OPENSSL_INIT_LOAD_SSL_STRINGS)
         ossl_init_once_run(&ssl_strings, ossl_init_load_ssl_strings);
+
+    return 1;
 }