From 796d609550df3a33fc11468741c5d2f6d3df4c11 Mon Sep 17 00:00:00 2001 From: beck <> Date: Sun, 19 Mar 2000 11:13:58 +0000 Subject: OpenSSL 0.9.5 merge *warning* this bumps shared lib minors for libssl and libcrypto from 2.1 to 2.2 if you are using the ssl26 packages for ssh and other things to work you will need to get new ones (see ~beck/libsslsnap/) on cvs or ~beck/src-patent.tar.gz on cvs --- src/lib/libcrypto/threads/README | 14 ++++ src/lib/libcrypto/threads/mttest.c | 122 +++++++++++++++++++---------- src/lib/libcrypto/threads/profile.sh | 4 + src/lib/libcrypto/threads/ptest.bat | 4 + src/lib/libcrypto/threads/pthread.sh | 9 +++ src/lib/libcrypto/threads/pthread2.sh | 7 ++ src/lib/libcrypto/threads/pthreads-vms.com | 9 +++ src/lib/libcrypto/threads/purify.sh | 4 + src/lib/libcrypto/threads/solaris.sh | 4 + src/lib/libcrypto/threads/th-lock.c | 55 ++++++++----- src/lib/libcrypto/threads/win32.bat | 4 + 11 files changed, 176 insertions(+), 60 deletions(-) create mode 100644 src/lib/libcrypto/threads/README create mode 100644 src/lib/libcrypto/threads/profile.sh create mode 100644 src/lib/libcrypto/threads/ptest.bat create mode 100644 src/lib/libcrypto/threads/pthread.sh create mode 100644 src/lib/libcrypto/threads/pthread2.sh create mode 100644 src/lib/libcrypto/threads/pthreads-vms.com create mode 100644 src/lib/libcrypto/threads/purify.sh create mode 100644 src/lib/libcrypto/threads/solaris.sh create mode 100644 src/lib/libcrypto/threads/win32.bat (limited to 'src/lib/libcrypto/threads') diff --git a/src/lib/libcrypto/threads/README b/src/lib/libcrypto/threads/README new file mode 100644 index 0000000000..df6b26e146 --- /dev/null +++ b/src/lib/libcrypto/threads/README @@ -0,0 +1,14 @@ +Mutithreading testing area. + +Since this stuff is very very platorm specific, this is not part of the +normal build. Have a read of doc/threads.doc. + +mttest will do some testing and will currently build under Windows NT/95, +Solaris and Linux. The IRIX stuff is not finished. + +I have tested this program on a 12 CPU ultra sparc box (solaris 2.5.1) +and things seem to work ok. + +The Linux pthreads package can be retrieved from +http://www.mit.edu:8001/people/proven/pthreads.html + diff --git a/src/lib/libcrypto/threads/mttest.c b/src/lib/libcrypto/threads/mttest.c index 142623edda..24713a3157 100644 --- a/src/lib/libcrypto/threads/mttest.c +++ b/src/lib/libcrypto/threads/mttest.c @@ -74,26 +74,29 @@ #include #include #endif +#ifdef PTHREADS +#include +#endif #include #include #include -#include "../e_os.h" +#include "../../e_os.h" #include #include #include +#include #ifdef NO_FP_API #define APPS_WIN16 -#include "../crypto/buffer/bss_file.c" +#include "../buffer/bss_file.c" #endif -#define TEST_SERVER_CERT "../apps/server.pem" -#define TEST_CLIENT_CERT "../apps/client.pem" +#define TEST_SERVER_CERT "../../apps/server.pem" +#define TEST_CLIENT_CERT "../../apps/client.pem" #define MAX_THREAD_NUMBER 100 -int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, - int error,char *arg); +int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *xs); void thread_setup(void); void thread_cleanup(void); void do_threads(SSL_CTX *s_ctx,SSL_CTX *c_ctx); @@ -121,6 +124,8 @@ int number_of_loops=10; int reconnect=0; int cache_stats=0; +static const char rnd_seed[] = "string to make the random number generator think it has entropy"; + int doit(char *ctx[4]); static void print_stats(FILE *fp, SSL_CTX *ctx) { @@ -170,6 +175,8 @@ int main(int argc, char *argv[]) char *ccert=TEST_CLIENT_CERT; SSL_METHOD *ssl_method=SSLv23_method(); + RAND_seed(rnd_seed, sizeof rnd_seed); + if (bio_err == NULL) bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); if (bio_stdout == NULL) @@ -244,7 +251,7 @@ bad: if (cipher == NULL) cipher=getenv("SSL_CIPHER"); SSL_load_error_strings(); - SSLeay_add_ssl_algorithms(); + OpenSSL_add_ssl_algorithms(); c_ctx=SSL_CTX_new(ssl_method); s_ctx=SSL_CTX_new(ssl_method); @@ -259,8 +266,15 @@ bad: SSL_CTX_set_session_cache_mode(c_ctx, SSL_SESS_CACHE_NO_AUTO_CLEAR|SSL_SESS_CACHE_SERVER); - SSL_CTX_use_certificate_file(s_ctx,scert,SSL_FILETYPE_PEM); - SSL_CTX_use_RSAPrivateKey_file(s_ctx,scert,SSL_FILETYPE_PEM); + if (!SSL_CTX_use_certificate_file(s_ctx,scert,SSL_FILETYPE_PEM)) + { + ERR_print_errors(bio_err); + } + else if (!SSL_CTX_use_RSAPrivateKey_file(s_ctx,scert,SSL_FILETYPE_PEM)) + { + ERR_print_errors(bio_err); + goto end; + } if (client_auth) { @@ -489,6 +503,7 @@ int doit(char *ctx[4]) else { fprintf(stderr,"ERROR in CLIENT\n"); + ERR_print_errors_fp(stderr); return(1); } } @@ -520,6 +535,7 @@ int doit(char *ctx[4]) else { fprintf(stderr,"ERROR in CLIENT\n"); + ERR_print_errors_fp(stderr); return(1); } } @@ -652,18 +668,23 @@ err: return(0); } -int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, - int error, char *arg) +int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx) { - char buf[256]; + char *s, buf[256]; if (verbose) { - X509_NAME_oneline(X509_get_subject_name(xs),buf,256); - if (ok) - fprintf(stderr,"depth=%d %s\n",depth,buf); - else - fprintf(stderr,"depth=%d error=%d %s\n",depth,error,buf); + s=X509_NAME_oneline(X509_get_subject_name(ctx->current_cert), + buf,256); + if (s != NULL) + { + if (ok) + fprintf(stderr,"depth=%d %s\n", + ctx->error_depth,buf); + else + fprintf(stderr,"depth=%d error=%d %s\n", + ctx->error_depth,ctx->error,buf); + } } return(ok); } @@ -672,13 +693,14 @@ int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, #ifdef WIN32 -static HANDLE lock_cs[CRYPTO_NUM_LOCKS]; +static HANDLE *lock_cs; void thread_setup(void) { int i; - for (i=0; ireferences,c_ctx->references); + s_ctx->references,c_ctx->references); } unsigned long pthreads_thread_id(void) diff --git a/src/lib/libcrypto/threads/profile.sh b/src/lib/libcrypto/threads/profile.sh new file mode 100644 index 0000000000..6e3e342fc0 --- /dev/null +++ b/src/lib/libcrypto/threads/profile.sh @@ -0,0 +1,4 @@ +#!/bin/sh +/bin/rm -f mttest +cc -p -DSOLARIS -I../../include -g mttest.c -o mttest -L/usr/lib/libc -ldl -L../.. -lthread -lssl -lcrypto -lnsl -lsocket + diff --git a/src/lib/libcrypto/threads/ptest.bat b/src/lib/libcrypto/threads/ptest.bat new file mode 100644 index 0000000000..4071b5ffea --- /dev/null +++ b/src/lib/libcrypto/threads/ptest.bat @@ -0,0 +1,4 @@ +del mttest.exe + +purify cl /O2 -DWIN32 /MD -I..\..\out mttest.c /Femttest ..\..\out\ssl32.lib ..\..\out\crypt32.lib + diff --git a/src/lib/libcrypto/threads/pthread.sh b/src/lib/libcrypto/threads/pthread.sh new file mode 100644 index 0000000000..f1c49821d2 --- /dev/null +++ b/src/lib/libcrypto/threads/pthread.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# +# build using pthreads +# +# http://www.mit.edu:8001/people/proven/pthreads.html +# +/bin/rm -f mttest +pgcc -DPTHREADS -I../../include -g mttest.c -o mttest -L../.. -lssl -lcrypto + diff --git a/src/lib/libcrypto/threads/pthread2.sh b/src/lib/libcrypto/threads/pthread2.sh new file mode 100644 index 0000000000..41264c6a50 --- /dev/null +++ b/src/lib/libcrypto/threads/pthread2.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# +# build using pthreads where it's already built into the system +# +/bin/rm -f mttest +gcc -DPTHREADS -I../../include -g mttest.c -o mttest -L../.. -lssl -lcrypto -lpthread + diff --git a/src/lib/libcrypto/threads/pthreads-vms.com b/src/lib/libcrypto/threads/pthreads-vms.com new file mode 100644 index 0000000000..63f5b8cc2e --- /dev/null +++ b/src/lib/libcrypto/threads/pthreads-vms.com @@ -0,0 +1,9 @@ +$! To compile mttest on VMS. +$! +$! WARNING: only tested with DEC C so far. +$ +$ arch := vax +$ if f$getsyi("CPU") .ge. 128 then arch := axp +$ define/user openssl [--.include.openssl] +$ cc/def=PTHREADS mttest.c +$ link mttest,[--.'arch'.exe.ssl]libssl/lib,[--.'arch'.exe.crypto]libcrypto/lib diff --git a/src/lib/libcrypto/threads/purify.sh b/src/lib/libcrypto/threads/purify.sh new file mode 100644 index 0000000000..6d44fe26b7 --- /dev/null +++ b/src/lib/libcrypto/threads/purify.sh @@ -0,0 +1,4 @@ +#!/bin/sh +/bin/rm -f mttest +purify cc -DSOLARIS -I../../include -g mttest.c -o mttest -L../.. -lthread -lssl -lcrypto -lnsl -lsocket + diff --git a/src/lib/libcrypto/threads/solaris.sh b/src/lib/libcrypto/threads/solaris.sh new file mode 100644 index 0000000000..bc93094a27 --- /dev/null +++ b/src/lib/libcrypto/threads/solaris.sh @@ -0,0 +1,4 @@ +#!/bin/sh +/bin/rm -f mttest +cc -DSOLARIS -I../../include -g mttest.c -o mttest -L../.. -lthread -lssl -lcrypto -lnsl -lsocket + diff --git a/src/lib/libcrypto/threads/th-lock.c b/src/lib/libcrypto/threads/th-lock.c index afb4f4caf2..3ee978060c 100644 --- a/src/lib/libcrypto/threads/th-lock.c +++ b/src/lib/libcrypto/threads/th-lock.c @@ -74,6 +74,9 @@ #include #include #endif +#ifdef PTHREADS +#include +#endif #include #include #include @@ -82,7 +85,7 @@ #include #include -int CRYPTO_thread_setup(void); +void CRYPTO_thread_setup(void); void CRYPTO_thread_cleanup(void); static void irix_locking_callback(int mode,int type,char *file,int line); @@ -96,7 +99,7 @@ static unsigned long pthreads_thread_id(void ); /* usage: * CRYPTO_thread_setup(); - * applicaion code + * application code * CRYPTO_thread_cleanup(); */ @@ -104,13 +107,14 @@ static unsigned long pthreads_thread_id(void ); #ifdef WIN32 -static HANDLE lock_cs[CRYPTO_NUM_LOCKS]; +static HANDLE *lock_cs; -int CRYPTO_thread_setup(void) +void CRYPTO_thread_setup(void) { int i; - for (i=0; i