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 273
 	lock_release(_ksr_kxlibssl_local_lock);
278 274
 }
279 275
 
280
-#ifdef __OS_darwin
281
-int ksr_kxlibssl_add(const void *buf, int num, double randomness)
282
-#else
276
+#ifdef KSRTLSVOID
283 277
 void ksr_kxlibssl_add(const void *buf, int num, int randomness)
284
-#endif
285 278
 {
286
-#ifdef __OS_darwin
279
+	ksr_kxlibssl_init();
280
+	if(_ksr_kxlibssl_local_lock == 0 || _ksr_kxlibssl_local_method == 0) {
281
+		return;
282
+	}
283
+	if(_ksr_kxlibssl_local_method->add == NULL) {
284
+		return;
285
+	}
286
+	lock_get(_ksr_kxlibssl_local_lock);
287
+	_ksr_kxlibssl_local_method->add(buf, num, randomness);
288
+	lock_release(_ksr_kxlibssl_local_lock);
289
+}
290
+#else
291
+int ksr_kxlibssl_add(const void *buf, int num, double randomness)
292
+{
287 293
 	int ret;
288
-#endif
289 294
 
290 295
 	ksr_kxlibssl_init();
291 296
 	if(_ksr_kxlibssl_local_lock == 0 || _ksr_kxlibssl_local_method == 0) {
292
-#ifdef __OS_darwin
293 297
 		return 0;
294
-#else
295
-		return;
296
-#endif
297 298
 	}
298 299
 	if(_ksr_kxlibssl_local_method->add == NULL) {
299
-#ifdef __OS_darwin
300 300
 		return 0;
301
-#else
302
-		return;
303
-#endif
304 301
 	}
305 302
 	lock_get(_ksr_kxlibssl_local_lock);
306
-#ifdef __OS_darwin
307 303
 	ret = _ksr_kxlibssl_local_method->add(buf, num, randomness);
308
-#else
309
-	_ksr_kxlibssl_local_method->add(buf, num, randomness);
310
-#endif
311 304
 	lock_release(_ksr_kxlibssl_local_lock);
312
-#ifdef __OS_darwin
305
+
313 306
 	return ret;
314
-#endif
315 307
 }
308
+#endif
316 309
 
317 310
 int ksr_kxlibssl_pseudorand(unsigned char *buf, int num)
318 311
 {