iPXE
Macros | Functions | Variables
entropy_sample.c File Reference

Entropy sampling. More...

#include <stdio.h>
#include <ipxe/entropy.h>
#include <ipxe/test.h>

Go to the source code of this file.

Macros

#define SAMPLE_COUNT   65536
 Total number of test samples. More...
 
#define SAMPLE_BLOCKSIZE   256
 Number of samples per block. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static void entropy_sample_test_exec (void)
 Generate entropy samples for external testing. More...
 

Variables

struct self_test entropy_sample_test __self_test
 Entropy sampling self-test. More...
 

Detailed Description

Entropy sampling.

Definition in file entropy_sample.c.

Macro Definition Documentation

◆ SAMPLE_COUNT

#define SAMPLE_COUNT   65536

Total number of test samples.

Definition at line 37 of file entropy_sample.c.

◆ SAMPLE_BLOCKSIZE

#define SAMPLE_BLOCKSIZE   256

Number of samples per block.

Definition at line 40 of file entropy_sample.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ entropy_sample_test_exec()

static void entropy_sample_test_exec ( void  )
static

Generate entropy samples for external testing.

Definition at line 46 of file entropy_sample.c.

46  {
47  static noise_sample_t samples[SAMPLE_BLOCKSIZE];
48  unsigned int i;
49  unsigned int j;
50  int rc;
51 
52  /* Collect and print blocks of samples */
53  for ( i = 0 ; i < ( SAMPLE_COUNT / SAMPLE_BLOCKSIZE ) ; i++ ) {
54 
55  /* Collect one block of samples */
56  rc = entropy_enable();
57  ok ( rc == 0 );
58  for ( j = 0 ; j < SAMPLE_BLOCKSIZE ; j++ ) {
59  rc = get_noise ( &samples[j] );
60  ok ( rc == 0 );
61  }
63 
64  /* Print out sample values */
65  for ( j = 0 ; j < SAMPLE_BLOCKSIZE ; j++ ) {
66  printf ( "SAMPLE %d %d\n", ( i * SAMPLE_BLOCKSIZE + j ),
67  samples[j] );
68  }
69  }
70 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void entropy_disable(void)
Disable entropy gathering.
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
int get_noise(noise_sample_t *noise)
Get noise sample.
#define SAMPLE_COUNT
Total number of test samples.
int entropy_enable(void)
Enable entropy gathering.
#define SAMPLE_BLOCKSIZE
Number of samples per block.
uint8_t noise_sample_t
A noise sample.
Definition: entropy.h:50
#define ok(success)
Definition: test.h:46

References entropy_disable(), entropy_enable(), get_noise(), ok, printf(), rc, SAMPLE_BLOCKSIZE, and SAMPLE_COUNT.

Variable Documentation

◆ __self_test

struct self_test entropy_sample_test __self_test
Initial value:
= {
.name = "entropy_sample",
}
static void entropy_sample_test_exec(void)
Generate entropy samples for external testing.

Entropy sampling self-test.

Definition at line 73 of file entropy_sample.c.