diff options
author | beck <> | 1999-09-29 04:37:45 +0000 |
---|---|---|
committer | beck <> | 1999-09-29 04:37:45 +0000 |
commit | de8f24ea083384bb66b32ec105dc4743c5663cdf (patch) | |
tree | 1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/cryptlib.c | |
parent | cb929d29896bcb87c2a97417fbd03e50078fc178 (diff) | |
download | openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2 openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip |
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/cryptlib.c')
-rw-r--r-- | src/lib/libcrypto/cryptlib.c | 85 |
1 files changed, 39 insertions, 46 deletions
diff --git a/src/lib/libcrypto/cryptlib.c b/src/lib/libcrypto/cryptlib.c index 9a7e80b7f8..356c476a99 100644 --- a/src/lib/libcrypto/cryptlib.c +++ b/src/lib/libcrypto/cryptlib.c | |||
@@ -59,15 +59,14 @@ | |||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include <string.h> | 60 | #include <string.h> |
61 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
62 | #include "crypto.h" | 62 | #include <openssl/crypto.h> |
63 | #include "date.h" | ||
64 | 63 | ||
65 | #if defined(WIN32) || defined(WIN16) | 64 | #if defined(WIN32) || defined(WIN16) |
66 | static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */ | 65 | static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */ |
67 | #endif | 66 | #endif |
68 | 67 | ||
69 | /* real #defines in crypto.h, keep these upto date */ | 68 | /* real #defines in crypto.h, keep these upto date */ |
70 | static char* lock_names[CRYPTO_NUM_LOCKS] = | 69 | static const char* lock_names[CRYPTO_NUM_LOCKS] = |
71 | { | 70 | { |
72 | "<<ERROR>>", | 71 | "<<ERROR>>", |
73 | "err", | 72 | "err", |
@@ -84,30 +83,28 @@ static char* lock_names[CRYPTO_NUM_LOCKS] = | |||
84 | "ssl_ctx", | 83 | "ssl_ctx", |
85 | "ssl_cert", | 84 | "ssl_cert", |
86 | "ssl_session", | 85 | "ssl_session", |
86 | "ssl_sess_cert", | ||
87 | "ssl", | 87 | "ssl", |
88 | "rand", | 88 | "rand", |
89 | "debug_malloc", | 89 | "debug_malloc", |
90 | "BIO", | 90 | "BIO", |
91 | "bio_gethostbyname", | 91 | "gethostbyname", |
92 | "getservbyname", | ||
93 | "readdir", | ||
92 | "RSA_blinding", | 94 | "RSA_blinding", |
95 | #if CRYPTO_NUM_LOCKS != 24 | ||
96 | # error "Inconsistency between crypto.h and cryptlib.c" | ||
97 | #endif | ||
93 | }; | 98 | }; |
94 | 99 | ||
95 | static STACK *app_locks=NULL; | 100 | static STACK *app_locks=NULL; |
96 | 101 | ||
97 | #ifndef NOPROTO | ||
98 | static void (MS_FAR *locking_callback)(int mode,int type, | 102 | static void (MS_FAR *locking_callback)(int mode,int type, |
99 | char *file,int line)=NULL; | 103 | const char *file,int line)=NULL; |
100 | static int (MS_FAR *add_lock_callback)(int *pointer,int amount, | 104 | static int (MS_FAR *add_lock_callback)(int *pointer,int amount, |
101 | int type,char *file,int line)=NULL; | 105 | int type,const char *file,int line)=NULL; |
102 | static unsigned long (MS_FAR *id_callback)(void)=NULL; | 106 | static unsigned long (MS_FAR *id_callback)(void)=NULL; |
103 | #else | 107 | int CRYPTO_get_new_lockid(char *name) |
104 | static void (MS_FAR *locking_callback)()=NULL; | ||
105 | static int (MS_FAR *add_lock_callback)()=NULL; | ||
106 | static unsigned long (MS_FAR *id_callback)()=NULL; | ||
107 | #endif | ||
108 | |||
109 | int CRYPTO_get_new_lockid(name) | ||
110 | char *name; | ||
111 | { | 108 | { |
112 | char *str; | 109 | char *str; |
113 | int i; | 110 | int i; |
@@ -120,10 +117,11 @@ char *name; | |||
120 | SSLeay_MSVC5_hack=(double)name[0]*(double)name[1]; | 117 | SSLeay_MSVC5_hack=(double)name[0]*(double)name[1]; |
121 | #endif | 118 | #endif |
122 | 119 | ||
123 | if (app_locks == NULL) | 120 | if ((app_locks == NULL) && ((app_locks=sk_new_null()) == NULL)) |
124 | if ((app_locks=sk_new_null()) == NULL) | 121 | { |
125 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE); | 122 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE); |
126 | return(0); | 123 | return(0); |
124 | } | ||
127 | if ((str=BUF_strdup(name)) == NULL) | 125 | if ((str=BUF_strdup(name)) == NULL) |
128 | return(0); | 126 | return(0); |
129 | i=sk_push(app_locks,str); | 127 | i=sk_push(app_locks,str); |
@@ -134,40 +132,46 @@ char *name; | |||
134 | return(i); | 132 | return(i); |
135 | } | 133 | } |
136 | 134 | ||
137 | void (*CRYPTO_get_locking_callback(P_V))(P_I_I_P_I) | 135 | int CRYPTO_num_locks(void) |
136 | { | ||
137 | return CRYPTO_NUM_LOCKS; | ||
138 | } | ||
139 | |||
140 | void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file, | ||
141 | int line) | ||
138 | { | 142 | { |
139 | return(locking_callback); | 143 | return(locking_callback); |
140 | } | 144 | } |
141 | 145 | ||
142 | int (*CRYPTO_get_add_lock_callback(P_V))(P_IP_I_I_P_I) | 146 | int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type, |
147 | const char *file,int line) | ||
143 | { | 148 | { |
144 | return(add_lock_callback); | 149 | return(add_lock_callback); |
145 | } | 150 | } |
146 | 151 | ||
147 | void CRYPTO_set_locking_callback(func) | 152 | void CRYPTO_set_locking_callback(void (*func)(int mode,int type, |
148 | void (*func)(P_I_I_P_I); | 153 | const char *file,int line)) |
149 | { | 154 | { |
150 | locking_callback=func; | 155 | locking_callback=func; |
151 | } | 156 | } |
152 | 157 | ||
153 | void CRYPTO_set_add_lock_callback(func) | 158 | void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type, |
154 | int (*func)(P_IP_I_I_P_I); | 159 | const char *file,int line)) |
155 | { | 160 | { |
156 | add_lock_callback=func; | 161 | add_lock_callback=func; |
157 | } | 162 | } |
158 | 163 | ||
159 | unsigned long (*CRYPTO_get_id_callback(P_V))(P_V) | 164 | unsigned long (*CRYPTO_get_id_callback(void))(void) |
160 | { | 165 | { |
161 | return(id_callback); | 166 | return(id_callback); |
162 | } | 167 | } |
163 | 168 | ||
164 | void CRYPTO_set_id_callback(func) | 169 | void CRYPTO_set_id_callback(unsigned long (*func)(void)) |
165 | unsigned long (*func)(P_V); | ||
166 | { | 170 | { |
167 | id_callback=func; | 171 | id_callback=func; |
168 | } | 172 | } |
169 | 173 | ||
170 | unsigned long CRYPTO_thread_id() | 174 | unsigned long CRYPTO_thread_id(void) |
171 | { | 175 | { |
172 | unsigned long ret=0; | 176 | unsigned long ret=0; |
173 | 177 | ||
@@ -188,11 +192,7 @@ unsigned long CRYPTO_thread_id() | |||
188 | return(ret); | 192 | return(ret); |
189 | } | 193 | } |
190 | 194 | ||
191 | void CRYPTO_lock(mode,type,file,line) | 195 | void CRYPTO_lock(int mode, int type, const char *file, int line) |
192 | int mode; | ||
193 | int type; | ||
194 | char *file; | ||
195 | int line; | ||
196 | { | 196 | { |
197 | #ifdef LOCK_DEBUG | 197 | #ifdef LOCK_DEBUG |
198 | { | 198 | { |
@@ -221,12 +221,8 @@ int line; | |||
221 | locking_callback(mode,type,file,line); | 221 | locking_callback(mode,type,file,line); |
222 | } | 222 | } |
223 | 223 | ||
224 | int CRYPTO_add_lock(pointer,amount,type,file,line) | 224 | int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file, |
225 | int *pointer; | 225 | int line) |
226 | int amount; | ||
227 | int type; | ||
228 | char *file; | ||
229 | int line; | ||
230 | { | 226 | { |
231 | int ret; | 227 | int ret; |
232 | 228 | ||
@@ -264,8 +260,7 @@ int line; | |||
264 | return(ret); | 260 | return(ret); |
265 | } | 261 | } |
266 | 262 | ||
267 | char *CRYPTO_get_lock_name(type) | 263 | const char *CRYPTO_get_lock_name(int type) |
268 | int type; | ||
269 | { | 264 | { |
270 | if (type < 0) | 265 | if (type < 0) |
271 | return("ERROR"); | 266 | return("ERROR"); |
@@ -283,10 +278,8 @@ int type; | |||
283 | /* All we really need to do is remove the 'error' state when a thread | 278 | /* All we really need to do is remove the 'error' state when a thread |
284 | * detaches */ | 279 | * detaches */ |
285 | 280 | ||
286 | BOOL WINAPI DLLEntryPoint(hinstDLL,fdwReason,lpvReserved) | 281 | BOOL WINAPI DLLEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason, |
287 | HINSTANCE hinstDLL; | 282 | LPVOID lpvReserved) |
288 | DWORD fdwReason; | ||
289 | LPVOID lpvReserved; | ||
290 | { | 283 | { |
291 | switch(fdwReason) | 284 | switch(fdwReason) |
292 | { | 285 | { |