summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/cryptlib.c
diff options
context:
space:
mode:
authorbeck <>1999-09-29 04:37:45 +0000
committerbeck <>1999-09-29 04:37:45 +0000
commitde8f24ea083384bb66b32ec105dc4743c5663cdf (patch)
tree1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/cryptlib.c
parentcb929d29896bcb87c2a97417fbd03e50078fc178 (diff)
downloadopenbsd-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.c85
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)
66static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */ 65static 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 */
70static char* lock_names[CRYPTO_NUM_LOCKS] = 69static 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
95static STACK *app_locks=NULL; 100static STACK *app_locks=NULL;
96 101
97#ifndef NOPROTO
98static void (MS_FAR *locking_callback)(int mode,int type, 102static void (MS_FAR *locking_callback)(int mode,int type,
99 char *file,int line)=NULL; 103 const char *file,int line)=NULL;
100static int (MS_FAR *add_lock_callback)(int *pointer,int amount, 104static 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;
102static unsigned long (MS_FAR *id_callback)(void)=NULL; 106static unsigned long (MS_FAR *id_callback)(void)=NULL;
103#else 107int CRYPTO_get_new_lockid(char *name)
104static void (MS_FAR *locking_callback)()=NULL;
105static int (MS_FAR *add_lock_callback)()=NULL;
106static unsigned long (MS_FAR *id_callback)()=NULL;
107#endif
108
109int CRYPTO_get_new_lockid(name)
110char *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
137void (*CRYPTO_get_locking_callback(P_V))(P_I_I_P_I) 135int CRYPTO_num_locks(void)
136 {
137 return CRYPTO_NUM_LOCKS;
138 }
139
140void (*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
142int (*CRYPTO_get_add_lock_callback(P_V))(P_IP_I_I_P_I) 146int (*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
147void CRYPTO_set_locking_callback(func) 152void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
148void (*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
153void CRYPTO_set_add_lock_callback(func) 158void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
154int (*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
159unsigned long (*CRYPTO_get_id_callback(P_V))(P_V) 164unsigned long (*CRYPTO_get_id_callback(void))(void)
160 { 165 {
161 return(id_callback); 166 return(id_callback);
162 } 167 }
163 168
164void CRYPTO_set_id_callback(func) 169void CRYPTO_set_id_callback(unsigned long (*func)(void))
165unsigned long (*func)(P_V);
166 { 170 {
167 id_callback=func; 171 id_callback=func;
168 } 172 }
169 173
170unsigned long CRYPTO_thread_id() 174unsigned 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
191void CRYPTO_lock(mode,type,file,line) 195void CRYPTO_lock(int mode, int type, const char *file, int line)
192int mode;
193int type;
194char *file;
195int 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
224int CRYPTO_add_lock(pointer,amount,type,file,line) 224int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
225int *pointer; 225 int line)
226int amount;
227int type;
228char *file;
229int 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
267char *CRYPTO_get_lock_name(type) 263const char *CRYPTO_get_lock_name(int type)
268int 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
286BOOL WINAPI DLLEntryPoint(hinstDLL,fdwReason,lpvReserved) 281BOOL WINAPI DLLEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason,
287HINSTANCE hinstDLL; 282 LPVOID lpvReserved)
288DWORD fdwReason;
289LPVOID lpvReserved;
290 { 283 {
291 switch(fdwReason) 284 switch(fdwReason)
292 { 285 {