Lines 1-6
Link Here
|
1 |
/* Copyright (C)2004 Landmark Graphics Corporation |
1 |
/* Copyright (C)2004 Landmark Graphics Corporation |
2 |
* Copyright (C)2005 Sun Microsystems, Inc. |
2 |
* Copyright (C)2005 Sun Microsystems, Inc. |
3 |
* Copyright (C)2014, 2016 D. R. Commander |
3 |
* Copyright (C)2014, 2016, 2018 D. R. Commander |
4 |
* |
4 |
* |
5 |
* This library is free software and may be redistributed and/or modified under |
5 |
* This library is free software and may be redistributed and/or modified under |
6 |
* the terms of the wxWindows Library License, Version 3.1 or (at your option) |
6 |
* the terms of the wxWindows Library License, Version 3.1 or (at your option) |
Lines 43-74
typedef socklen_t SOCKLEN_T;
Link Here
|
43 |
|
43 |
|
44 |
#ifdef USESSL |
44 |
#ifdef USESSL |
45 |
bool Socket::sslInit=false; |
45 |
bool Socket::sslInit=false; |
|
|
46 |
#if OPENSSL_VERSION_NUMBER < 0x10100000L |
46 |
CriticalSection Socket::cryptoLock[CRYPTO_NUM_LOCKS]; |
47 |
CriticalSection Socket::cryptoLock[CRYPTO_NUM_LOCKS]; |
47 |
#endif |
48 |
#endif |
|
|
49 |
#endif |
48 |
CriticalSection Socket::mutex; |
50 |
CriticalSection Socket::mutex; |
49 |
int Socket::instanceCount=0; |
51 |
int Socket::instanceCount=0; |
50 |
|
52 |
|
51 |
|
53 |
|
52 |
#ifdef USESSL |
54 |
#ifdef USESSL |
53 |
|
55 |
|
54 |
static void progressCallback(int p, int n, void *arg) |
|
|
55 |
{ |
56 |
} |
57 |
|
58 |
|
59 |
static EVP_PKEY *newPrivateKey(int bits) |
56 |
static EVP_PKEY *newPrivateKey(int bits) |
60 |
{ |
57 |
{ |
|
|
58 |
BIGNUM *bn = NULL; |
59 |
RSA *rsa = NULL; |
61 |
EVP_PKEY *pk=NULL; |
60 |
EVP_PKEY *pk=NULL; |
62 |
|
61 |
|
63 |
try |
62 |
try |
64 |
{ |
63 |
{ |
|
|
64 |
if(!(bn = BN_new())) _throwssl(); |
65 |
if(!BN_set_word(bn, RSA_F4)) _throwssl(); |
66 |
if(!(rsa = RSA_new())) _throwssl(); |
67 |
if(!RSA_generate_key_ex(rsa, bits, bn, NULL)) _throwssl(); |
65 |
if(!(pk=EVP_PKEY_new())) _throwssl(); |
68 |
if(!(pk=EVP_PKEY_new())) _throwssl(); |
66 |
if(!EVP_PKEY_assign_RSA(pk, RSA_generate_key(bits, 0x10001, |
69 |
if(!EVP_PKEY_assign_RSA(pk, rsa)) _throwssl(); |
67 |
progressCallback, NULL))) _throwssl(); |
70 |
BN_free(bn); |
68 |
return pk; |
71 |
return pk; |
69 |
} |
72 |
} |
70 |
catch (...) |
73 |
catch (...) |
71 |
{ |
74 |
{ |
|
|
75 |
if(bn) BN_free(bn); |
76 |
if(rsa) RSA_free(rsa); |
72 |
if(pk) EVP_PKEY_free(pk); |
77 |
if(pk) EVP_PKEY_free(pk); |
73 |
throw; |
78 |
throw; |
74 |
} |
79 |
} |
Lines 147-153
Socket::Socket(bool doSSL_)
Link Here
|
147 |
#ifdef USESSL |
152 |
#ifdef USESSL |
148 |
if(!sslInit && doSSL) |
153 |
if(!sslInit && doSSL) |
149 |
{ |
154 |
{ |
150 |
#if defined(sun) || defined(sgi) |
155 |
#if !defined(HAVE_DEVURANDOM) && !defined(_WIN32) |
151 |
char buf[128]; int i; |
156 |
char buf[128]; int i; |
152 |
srandom(getpid()); |
157 |
srandom(getpid()); |
153 |
for(i = 0; i < 128; i++) |
158 |
for(i = 0; i < 128; i++) |
Lines 158-164
Socket::Socket(bool doSSL_)
Link Here
|
158 |
SSL_load_error_strings(); |
163 |
SSL_load_error_strings(); |
159 |
ERR_load_crypto_strings(); |
164 |
ERR_load_crypto_strings(); |
160 |
CRYPTO_set_id_callback(Thread::threadID); |
165 |
CRYPTO_set_id_callback(Thread::threadID); |
|
|
166 |
#if OPENSSL_VERSION_NUMBER < 0x10100000L |
161 |
CRYPTO_set_locking_callback(lockingCallback); |
167 |
CRYPTO_set_locking_callback(lockingCallback); |
|
|
168 |
#endif |
162 |
SSL_library_init(); |
169 |
SSL_library_init(); |
163 |
sslInit = true; |
170 |
sslInit = true; |
164 |
char *env = NULL; |
171 |
char *env = NULL; |