Check-in [2ed4afb942]
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Whitspace formatting changes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | openssl-1.1
Files: files | file ages | folders
SHA1: 2ed4afb942bd4c37f2560974ef6359b75bb143a2
User & Date: rkeene 2016-12-08 07:25:14
Context
2016-12-08
07:32
Do not try to set memory functions -- prototype is broken in newer version and older versions have bugs related to it check-in: bbe273b3dc user: rkeene tags: openssl-1.1
07:25
Whitspace formatting changes check-in: 2ed4afb942 user: rkeene tags: openssl-1.1
07:08
Updated fallback DH params for OpenSSL, supporting OpenSSL 1.1 and older versions check-in: bc2460fc22 user: rkeene tags: openssl-1.1
Changes

Changes to tls.c.

  1745   1745    *
  1746   1746    *------------------------------------------------------*
  1747   1747    */
  1748   1748   static int TlsLibInit (void) {
  1749   1749       static int initialized = 0;
  1750   1750       int i;
  1751   1751       char rnd_seed[16] = "GrzSlplKqUdnnzP!";	/* 16 bytes */
  1752         -    int status=TCL_OK;
         1752  +    int status = TCL_OK;
  1753   1753   
  1754   1754       if (initialized) {
  1755         -        return status;
         1755  +        return(status);
  1756   1756       }
  1757   1757       initialized = 1;
  1758   1758   
  1759   1759   #if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
  1760   1760       size_t num_locks;
  1761   1761   
  1762   1762       Tcl_MutexLock(&init_mx);
  1763   1763   #endif
  1764   1764   
  1765         -	    if (CRYPTO_set_mem_functions((void *(*)(size_t))Tcl_Alloc,
  1766         -					 (void *(*)(void *, size_t))Tcl_Realloc,
  1767         -					 (void(*)(void *))Tcl_Free) == 0) {
  1768         -	       /* Not using Tcl's mem functions ... not critical */
  1769         -	    }
         1765  +    if (CRYPTO_set_mem_functions((void *(*)(size_t))Tcl_Alloc,
         1766  +				 (void *(*)(void *, size_t))Tcl_Realloc,
         1767  +				 (void(*)(void *))Tcl_Free) == 0) {
         1768  +       /* Not using Tcl's mem functions ... not critical */
         1769  +    }
  1770   1770   
  1771   1771   #if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
  1772         -	    /* should we consider allocating mutexes? */
  1773         -	    num_locks = CRYPTO_num_locks();
  1774         -	    if (num_locks > CRYPTO_NUM_LOCKS) {
  1775         -		status=TCL_ERROR;
  1776         -		goto done;
  1777         -	    }
         1772  +    /* should we consider allocating mutexes? */
         1773  +    num_locks = CRYPTO_num_locks();
         1774  +    if (num_locks > CRYPTO_NUM_LOCKS) {
         1775  +	status = TCL_ERROR;
         1776  +	goto done;
         1777  +    }
  1778   1778   
  1779         -	    CRYPTO_set_locking_callback(CryptoThreadLockCallback);
  1780         -	    CRYPTO_set_id_callback(CryptoThreadIdCallback);
         1779  +    CRYPTO_set_locking_callback(CryptoThreadLockCallback);
         1780  +    CRYPTO_set_id_callback(CryptoThreadIdCallback);
  1781   1781   #endif
  1782   1782   
  1783         -	    if (SSL_library_init() != 1) {
  1784         -	    	status=TCL_ERROR;
  1785         -		goto done;
  1786         -	    }
  1787         -	    SSL_load_error_strings();
  1788         -	    ERR_load_crypto_strings();
         1783  +    if (SSL_library_init() != 1) {
         1784  +    	status = TCL_ERROR;
         1785  +	goto done;
         1786  +    }
         1787  +    SSL_load_error_strings();
         1788  +    ERR_load_crypto_strings();
  1789   1789   
  1790         -	    /*
  1791         -	     * Seed the random number generator in the SSL library,
  1792         -	     * using the do/while construct because of the bug note in the
  1793         -	     * OpenSSL FAQ at http://www.openssl.org/support/faq.html#USER1
  1794         -	     *
  1795         -	     * The crux of the problem is that Solaris 7 does not have a 
  1796         -	     * /dev/random or /dev/urandom device so it cannot gather enough
  1797         -	     * entropy from the RAND_seed() when TLS initializes and refuses
  1798         -	     * to go further. Earlier versions of OpenSSL carried on regardless.
  1799         -	     */
  1800         -	    srand((unsigned int) time((time_t *) NULL));
  1801         -	    do {
  1802         -		for (i = 0; i < 16; i++) {
  1803         -		    rnd_seed[i] = 1 + (char) (255.0 * rand()/(RAND_MAX+1.0));
  1804         -		}
  1805         -		RAND_seed(rnd_seed, sizeof(rnd_seed));
  1806         -	    } while (RAND_status() != 1);
         1790  +    /*
         1791  +     * Seed the random number generator in the SSL library,
         1792  +     * using the do/while construct because of the bug note in the
         1793  +     * OpenSSL FAQ at http://www.openssl.org/support/faq.html#USER1
         1794  +     *
         1795  +     * The crux of the problem is that Solaris 7 does not have a 
         1796  +     * /dev/random or /dev/urandom device so it cannot gather enough
         1797  +     * entropy from the RAND_seed() when TLS initializes and refuses
         1798  +     * to go further. Earlier versions of OpenSSL carried on regardless.
         1799  +     */
         1800  +    srand((unsigned int) time((time_t *) NULL));
         1801  +    do {
         1802  +	for (i = 0; i < 16; i++) {
         1803  +	    rnd_seed[i] = 1 + (char) (255.0 * rand()/(RAND_MAX+1.0));
         1804  +	}
         1805  +	RAND_seed(rnd_seed, sizeof(rnd_seed));
         1806  +    } while (RAND_status() != 1);
  1807   1807   done:
  1808   1808   
  1809   1809   #if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
  1810         -	Tcl_MutexUnlock(&init_mx);
         1810  +    Tcl_MutexUnlock(&init_mx);
  1811   1811   #endif
         1812  +
  1812   1813       return status;
  1813   1814   }