iPXE
Defines | 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.

Defines

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

Functions

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

Variables

struct self_test
entropy_sample_test 
__self_test
 Entropy sampling self-test.

Detailed Description

Entropy sampling.

Definition in file entropy_sample.c.


Define Documentation

#define SAMPLE_COUNT   65536

Total number of test samples.

Definition at line 37 of file entropy_sample.c.

Referenced by entropy_sample_test_exec().

#define SAMPLE_BLOCKSIZE   256

Number of samples per block.

Definition at line 40 of file entropy_sample.c.

Referenced by entropy_sample_test_exec().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static void entropy_sample_test_exec ( void  ) [static]

Generate entropy samples for external testing.

Definition at line 46 of file entropy_sample.c.

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

                                              {
        static noise_sample_t samples[SAMPLE_BLOCKSIZE];
        unsigned int i;
        unsigned int j;
        int rc;

        /* Collect and print blocks of samples */
        for ( i = 0 ; i < ( SAMPLE_COUNT / SAMPLE_BLOCKSIZE ) ; i++ ) {

                /* Collect one block of samples */
                rc = entropy_enable();
                ok ( rc == 0 );
                for ( j = 0 ; j < SAMPLE_BLOCKSIZE ; j++ ) {
                        rc = get_noise ( &samples[j] );
                        ok ( rc == 0 );
                }
                entropy_disable();

                /* Print out sample values */
                for ( j = 0 ; j < SAMPLE_BLOCKSIZE ; j++ ) {
                        printf ( "SAMPLE %d %d\n", ( i * SAMPLE_BLOCKSIZE + j ),
                                 samples[j] );
                }
        }
}

Variable Documentation

struct self_test entropy_sample_test __self_test
Initial value:
 {
        .name = "entropy_sample",
        .exec = entropy_sample_test_exec,
}

Entropy sampling self-test.

Definition at line 73 of file entropy_sample.c.