@@ -242,95 +242,6 @@ ssize_t jent_read_entropy(struct rand_data *ec, char *data, size_t len)
242
242
static struct rand_data * _jent_entropy_collector_alloc (unsigned int osr ,
243
243
unsigned int flags );
244
244
245
- /**
246
- * Entry function: Obtain entropy for the caller.
247
- *
248
- * This is a service function to jent_read_entropy() with the difference
249
- * that it automatically re-allocates the entropy collector if a health
250
- * test failure is observed. Before reallocation, a new power-on health test
251
- * is performed. The allocation of the new entropy collector automatically
252
- * increases the OSR by one. This is done based on the idea that a health
253
- * test failure indicates that the assumed entropy rate is too high.
254
- *
255
- * Note the function returns with an health test error if the OSR is
256
- * getting too large. If an error is returned by this function, the Jitter RNG
257
- * is not safe to be used on the current system.
258
- *
259
- * @ec [in] Reference to entropy collector - this is a double pointer as
260
- * The entropy collector may be freed and reallocated.
261
- * @data [out] pointer to buffer for storing random data -- buffer must
262
- * already exist
263
- * @len [in] size of the buffer, specifying also the requested number of random
264
- * in bytes
265
- *
266
- * @return see jent_read_entropy()
267
- */
268
- JENT_PRIVATE_STATIC
269
- ssize_t jent_read_entropy_safe (struct rand_data * * ec , char * data , size_t len )
270
- {
271
- char * p = data ;
272
- size_t orig_len = len ;
273
- ssize_t ret = 0 ;
274
-
275
- if (!ec )
276
- return -1 ;
277
-
278
- while (len > 0 ) {
279
- unsigned int osr , flags , max_mem_set ;
280
-
281
- ret = jent_read_entropy (* ec , p , len );
282
-
283
- switch (ret ) {
284
- case -1 :
285
- case -4 :
286
- return ret ;
287
- case -2 :
288
- case -3 :
289
- case -5 :
290
- osr = (* ec )-> osr + 1 ;
291
- flags = (* ec )-> flags ;
292
- max_mem_set = (* ec )-> max_mem_set ;
293
-
294
- /* generic arbitrary cutoff */
295
- if (osr > 20 )
296
- return ret ;
297
-
298
- /*
299
- * If the caller did not set any specific maximum value
300
- * let the Jitter RNG increase the maximum memory by
301
- * one step.
302
- */
303
- if (!max_mem_set )
304
- flags = jent_update_memsize (flags );
305
-
306
- /*
307
- * re-allocate entropy collector with higher OSR and
308
- * memory size
309
- */
310
- jent_entropy_collector_free (* ec );
311
-
312
- /* Perform new health test with updated OSR */
313
- if (jent_entropy_init_ex (osr , flags ))
314
- return -1 ;
315
-
316
- * ec = _jent_entropy_collector_alloc (osr , flags );
317
- if (!* ec )
318
- return -1 ;
319
-
320
- /* Remember whether caller configured memory size */
321
- (* ec )-> max_mem_set = !!max_mem_set ;
322
-
323
- break ;
324
-
325
- default :
326
- len -= (size_t )ret ;
327
- p += (size_t )ret ;
328
- }
329
- }
330
-
331
- return (ssize_t )orig_len ;
332
- }
333
-
334
245
/***************************************************************************
335
246
* Initialization logic
336
247
***************************************************************************/
0 commit comments