Skip to content

Commit 3031228

Browse files
committed
remove jent_read_entropy_safe
1 parent 8ff5cce commit 3031228

File tree

4 files changed

+2
-98
lines changed

4 files changed

+2
-98
lines changed

crypto/fipsmodule/rand/cpu_jitter_test.cc

-6
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ TEST(CPUJitterEntropyTest, Basic) {
4242
EXPECT_EQ(jent_read_entropy(jitter_ec.instance,
4343
(char*) data0, data_len), data_len);
4444

45-
// Draw some entropy with the "safe" API to check if it works.
46-
EXPECT_EQ(jent_read_entropy_safe(&jitter_ec.instance,
47-
(char*) data1, data_len), data_len);
48-
4945
// Basic check that the random data is not equal.
5046
EXPECT_NE(Bytes(data0), Bytes(data1));
5147

@@ -60,8 +56,6 @@ TEST(CPUJitterEntropyTest, Basic) {
6056
// Test drawing entropy from the Jitter object that was reset.
6157
EXPECT_EQ(jent_read_entropy(jitter_ec.instance,
6258
(char*) data0, data_len), data_len);
63-
EXPECT_EQ(jent_read_entropy_safe(&jitter_ec.instance,
64-
(char*) data1, data_len), data_len);
6559

6660
// Verify that the Jitter library version is v3.4.0.
6761
unsigned int jitter_version = 3040000;

third_party/jitterentropy/jitterentropy-base.c

-89
Original file line numberDiff line numberDiff line change
@@ -242,95 +242,6 @@ ssize_t jent_read_entropy(struct rand_data *ec, char *data, size_t len)
242242
static struct rand_data *_jent_entropy_collector_alloc(unsigned int osr,
243243
unsigned int flags);
244244

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-
334245
/***************************************************************************
335246
* Initialization logic
336247
***************************************************************************/

third_party/jitterentropy/jitterentropy.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,7 @@ struct rand_data
373373
/* get raw entropy */
374374
JENT_PRIVATE_STATIC
375375
ssize_t jent_read_entropy(struct rand_data *ec, char *data, size_t len);
376-
JENT_PRIVATE_STATIC
377-
ssize_t jent_read_entropy_safe(struct rand_data **ec, char *data, size_t len);
376+
378377
/* initialize an instance of the entropy collector */
379378
JENT_PRIVATE_STATIC
380379
struct rand_data *jent_entropy_collector_alloc(unsigned int osr,

tool/speed.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,7 @@ static bool SpeedJitter(size_t chunk_size) {
23562356

23572357
if (!TimeFunction(&results, [&jitter_ec, &input, chunk_size]() -> bool {
23582358
size_t bytes =
2359-
jent_read_entropy_safe(&jitter_ec, input.get(), chunk_size);
2359+
jent_read_entropy(jitter_ec, input.get(), chunk_size);
23602360
if (bytes != chunk_size) {
23612361
return false;
23622362
}

0 commit comments

Comments
 (0)