Browse code

tls: fixed prototypes for seed() and add() functions for kxlibssl rand engine

- libssl 1.1.x docs seem to be inconsistent with the code

Daniel-Constantin Mierla authored on 08/10/2019 10:10:35
Showing 1 changed files
... ...
@@ -209,42 +209,38 @@ void ksr_kxlibssl_init(void)
209 209
 	}
210 210
 }
211 211
 
212
-#ifdef __OS_darwin
213
-int ksr_kxlibssl_seed(const void *buf, int num)
214
-#else
212
+#ifdef KSRTLSVOID
215 213
 void ksr_kxlibssl_seed(const void *buf, int num)
216
-#endif
217 214
 {
218
-#ifdef __OS_darwin
215
+	ksr_kxlibssl_init();
216
+	if(_ksr_kxlibssl_local_lock == 0 || _ksr_kxlibssl_local_method == 0) {
217
+		return;
218
+	}
219
+	if(_ksr_kxlibssl_local_method->seed == NULL) {
220
+		return;
221
+	}
222
+	lock_get(_ksr_kxlibssl_local_lock);
223
+	_ksr_kxlibssl_local_method->seed(buf, num);
224
+	lock_release(_ksr_kxlibssl_local_lock);
225
+}
226
+#else
227
+int ksr_kxlibssl_seed(const void *buf, int num)
228
+{
219 229
 	int ret;
220
-#endif
221 230
 
222 231
 	ksr_kxlibssl_init();
223 232
 	if(_ksr_kxlibssl_local_lock == 0 || _ksr_kxlibssl_local_method == 0) {
224
-#ifdef __OS_darwin
225 233
 		return 0;
226
-#else
227
-		return;
228
-#endif
229 234
 	}
230 235
 	if(_ksr_kxlibssl_local_method->seed == NULL) {
231
-#ifdef __OS_darwin
232 236
 		return 0;
233
-#else
234
-		return;
235
-#endif
236 237
 	}
237 238
 	lock_get(_ksr_kxlibssl_local_lock);
238
-#ifdef __OS_darwin
239 239
 	ret = _ksr_kxlibssl_local_method->seed(buf, num);
240
-#else
241
-	_ksr_kxlibssl_local_method->seed(buf, num);
242
-#endif
243 240
 	lock_release(_ksr_kxlibssl_local_lock);
244
-#ifdef __OS_darwin
245 241
 	return ret;
246
-#endif
247 242
 }
243
+#endif
248 244
 
249 245
 int ksr_kxlibssl_bytes(unsigned char *buf, int num)
250 246
 {
... ...
@@ -277,42 +273,39 @@ void ksr_kxlibssl_cleanup(void)
277 277
 	lock_release(_ksr_kxlibssl_local_lock);
278 278
 }
279 279
 
280
-#ifdef __OS_darwin
281
-int ksr_kxlibssl_add(const void *buf, int num, double randomness)
282
-#else
280
+#ifdef KSRTLSVOID
283 281
 void ksr_kxlibssl_add(const void *buf, int num, int randomness)
284
-#endif
285 282
 {
286
-#ifdef __OS_darwin
283
+	ksr_kxlibssl_init();
284
+	if(_ksr_kxlibssl_local_lock == 0 || _ksr_kxlibssl_local_method == 0) {
285
+		return;
286
+	}
287
+	if(_ksr_kxlibssl_local_method->add == NULL) {
288
+		return;
289
+	}
290
+	lock_get(_ksr_kxlibssl_local_lock);
291
+	_ksr_kxlibssl_local_method->add(buf, num, randomness);
292
+	lock_release(_ksr_kxlibssl_local_lock);
293
+}
294
+#else
295
+int ksr_kxlibssl_add(const void *buf, int num, double randomness)
296
+{
287 297
 	int ret;
288
-#endif
289 298
 
290 299
 	ksr_kxlibssl_init();
291 300
 	if(_ksr_kxlibssl_local_lock == 0 || _ksr_kxlibssl_local_method == 0) {
292
-#ifdef __OS_darwin
293 301
 		return 0;
294
-#else
295
-		return;
296
-#endif
297 302
 	}
298 303
 	if(_ksr_kxlibssl_local_method->add == NULL) {
299
-#ifdef __OS_darwin
300 304
 		return 0;
301
-#else
302
-		return;
303
-#endif
304 305
 	}
305 306
 	lock_get(_ksr_kxlibssl_local_lock);
306
-#ifdef __OS_darwin
307 307
 	ret = _ksr_kxlibssl_local_method->add(buf, num, randomness);
308
-#else
309
-	_ksr_kxlibssl_local_method->add(buf, num, randomness);
310
-#endif
311 308
 	lock_release(_ksr_kxlibssl_local_lock);
312
-#ifdef __OS_darwin
309
+
313 310
 	return ret;
314
-#endif
315 311
 }
312
+#endif
316 313
 
317 314
 int ksr_kxlibssl_pseudorand(unsigned char *buf, int num)
318 315
 {