Skip to content

Commit d2020f5

Browse files
committed
Remove internal test functions
1 parent f8be297 commit d2020f5

File tree

2 files changed

+0
-128
lines changed

2 files changed

+0
-128
lines changed

targets/TARGET_Silicon_Labs/TARGET_EFM32/trng/sl_trng.c

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,6 @@ void sl_trng_soft_reset( TRNG_TypeDef *device )
115115
device->CONTROL = ctrl;
116116
}
117117

118-
static inline
119-
void sl_trng_write_test_data( TRNG_TypeDef *device, uint32_t data )
120-
{
121-
/* Wait for TESTDATA register to become ready for next word. */
122-
while (device->STATUS & TRNG_STATUS_TESTDATABUSY);
123-
device->TESTDATA = data;
124-
}
125-
126118
static void sl_trng_clear_fifo( TRNG_TypeDef *device )
127119
{
128120
volatile uint32_t val32;
@@ -150,54 +142,6 @@ int sl_trng_set_key( TRNG_TypeDef *device, const unsigned char *key )
150142
return 0;
151143
}
152144

153-
int sl_trng_check_conditioning( TRNG_TypeDef *device )
154-
{
155-
uint32_t val32;
156-
int i, ret=0;
157-
uint32_t ctrl = device->CONTROL;
158-
159-
/* Setup control register */
160-
device->CONTROL = TRNG_CONTROL_ENABLE | TRNG_CONTROL_TESTEN |
161-
TRNG_CONTROL_BYPNIST | TRNG_CONTROL_BYPAIS31;
162-
163-
/* Apply software reset */
164-
sl_trng_soft_reset(device);
165-
166-
/* Write test vector to the key register. */
167-
sl_trng_set_key(device,
168-
(const unsigned char*)test_vector_conditioning_key);
169-
170-
/* Write test vector to the TESTDATA register */
171-
for (i=0; i<TEST_VECTOR_CONDITIONING_INPUT_SIZE; i++)
172-
{
173-
sl_trng_write_test_data(device,
174-
test_vector_conditioning_input[i]);
175-
}
176-
177-
for (i=0; i<TEST_VECTOR_CONDITIONING_OUTPUT_SIZE; i++)
178-
{
179-
/* Wait for data to become available in the FIFO. */
180-
while ( 0 == device->FIFOLEVEL );
181-
/* Read output from the conditioning function */
182-
val32 = device->FIFO;
183-
/* Compare with expected test vector. */
184-
if (val32 != test_vector_conditioning_output[i])
185-
{
186-
/*
187-
mbedtls_printf("Conditioning test failed. "
188-
"Test output word %d 0x%lx. Expected 0x%lx\n",
189-
i, val32, test_vector_conditioning_output[i]);
190-
*/
191-
ret = SL_TRNG_ERR_CONDITIONING_TEST_FAILED;
192-
}
193-
}
194-
195-
/* Restore initial value of control register */
196-
device->CONTROL = ctrl;
197-
198-
return ret;
199-
}
200-
201145
static int sl_trng_check_status( TRNG_TypeDef *device )
202146
{
203147
uint32_t status = device->STATUS;
@@ -246,57 +190,6 @@ static int sl_trng_check_status( TRNG_TypeDef *device )
246190
return 0;
247191
}
248192

249-
int sl_trng_check_entropy( TRNG_TypeDef *device )
250-
{
251-
volatile uint32_t val32;
252-
int i, ret = 0;
253-
uint32_t ctrl = device->CONTROL;
254-
255-
/* Setup control register */
256-
device->CONTROL =
257-
TRNG_CONTROL_ENABLE |
258-
TRNG_CONTROL_REPCOUNTIEN |
259-
TRNG_CONTROL_APT64IEN |
260-
TRNG_CONTROL_APT4096IEN |
261-
TRNG_CONTROL_PREIEN |
262-
TRNG_CONTROL_ALMIEN;
263-
264-
/* Apply software reset */
265-
sl_trng_soft_reset(device);
266-
267-
/* Check FIFO level is non-zero . */
268-
for (i=0; i<FIFO_LEVEL_RETRY; i++)
269-
{
270-
if ( device->FIFOLEVEL )
271-
{
272-
break;
273-
}
274-
}
275-
/* Check for no data within timeout (max retry count) */
276-
if (i>=FIFO_LEVEL_RETRY)
277-
{
278-
ret = SL_TRNG_ERR_NO_DATA;
279-
}
280-
else
281-
{
282-
/* Read at least 4097x2 bits (~257 x 32 bits) in order for the longest
283-
test to complete (adaptive proportion test of 4096 samples). */
284-
for (i=0; i<TEST_WORDS_MIN; i++)
285-
{
286-
val32 = device->FIFO;
287-
(void)val32;
288-
}
289-
290-
/* Check in status register for errors. */
291-
ret = sl_trng_check_status( device );
292-
}
293-
294-
/* Restore initial value of control register */
295-
device->CONTROL = ctrl;
296-
297-
return ret;
298-
}
299-
300193
static void sl_trng_read_chunk( TRNG_TypeDef *device,
301194
unsigned char *output,
302195
size_t len )

targets/TARGET_Silicon_Labs/TARGET_EFM32/trng/sl_trng.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -152,27 +152,6 @@ void sl_trng_free( TRNG_TypeDef *ctx );
152152
*/
153153
int sl_trng_set_key( TRNG_TypeDef *ctx, const unsigned char *key );
154154

155-
/**
156-
* \brief Check the TRNG conditioning function
157-
*
158-
* \param ctx TRNG device
159-
*
160-
* \return
161-
* 0 if success. \ref SL_TRNG_ERR_CONDITIONING_TEST_FAILED on failure.
162-
*/
163-
int sl_trng_check_conditioning( TRNG_TypeDef *ctx );
164-
165-
/**
166-
* \brief Check the TRNG entropy source is producing random data
167-
*
168-
* \param ctx TRNG device
169-
*
170-
* \return
171-
* 0 if success. Error code if failure. Note that this function can return
172-
* a \ref SL_TRNG_ERR_PRELIMINARY_NOISE_ALARM on some occasions.
173-
*/
174-
int sl_trng_check_entropy( TRNG_TypeDef *ctx );
175-
176155
/**
177156
* \brief Poll for entropy data
178157
*

0 commit comments

Comments
 (0)