Functions | Variables
rbg.c File Reference

RBG mechanism. More...

#include <stdint.h>
#include <string.h>
#include <ipxe/init.h>
#include <ipxe/settings.h>
#include <ipxe/uuid.h>
#include <ipxe/crypto.h>
#include <ipxe/drbg.h>
#include <ipxe/rbg.h>

Go to the source code of this file.


static int rbg_startup (void)
 Start up RBG.
static void rbg_shutdown (void)
 Shut down RBG.
static void rbg_startup_fn (void)
 RBG startup function.
static void rbg_shutdown_fn (int booting __unused)
 RBG shutdown function.
struct startup_fn startup_rbg __startup_fn (STARTUP_NORMAL)
 RBG startup table entry.


struct random_bit_generator rbg
 The RBG.

Detailed Description

RBG mechanism.

This mechanism is designed to comply with ANS X9.82 Part 4 (April 2011 Draft) Section 10. This standard is unfortunately not freely available.

The chosen RBG design is that of a DRBG with a live entropy source with no conditioning function. Only a single security strength is supported. No seedfile is used since there may be no non-volatile storage available. The system UUID is used as the personalisation string.

Definition in file rbg.c.

Function Documentation

static int rbg_startup ( void  ) [static]

Start up RBG.

Return values:
rcReturn status code

This is the RBG_Startup function defined in ANS X9.82 Part 4 (April 2011 Draft) Section

Definition at line 73 of file rbg.c.

References DBGC, drbg_instantiate(), fetch_uuid_setting(), len, NULL, rbg, rc, random_bit_generator::state, and strerror().

Referenced by rbg_startup_fn().

        union uuid uuid;
        int len;
        int rc;

        /* Try to obtain system UUID for use as personalisation
         * string, in accordance with ANS X9.82 Part 3-2007 Section
         * 8.5.2.  If no UUID is available, proceed without a
         * personalisation string.
        if ( ( len = fetch_uuid_setting ( NULL, &uuid_setting, &uuid ) ) < 0 ) {
                rc = len;
                DBGC ( &rbg, "RBG could not fetch personalisation string: "
                       "%s\n", strerror ( rc ) );
                len = 0;

        /* Instantiate DRBG */
        if ( ( rc = drbg_instantiate ( &rbg.state, &uuid, len ) ) != 0 ) {
                DBGC ( &rbg, "RBG could not instantiate DRBG: %s\n",
                       strerror ( rc ) );
                return rc;

        return 0;
static void rbg_shutdown ( void  ) [static]

Shut down RBG.

Definition at line 104 of file rbg.c.

References drbg_uninstantiate(), rbg, and random_bit_generator::state.

Referenced by rbg_shutdown_fn().


        /* Uninstantiate DRBG */
        drbg_uninstantiate ( &rbg.state );
static void rbg_startup_fn ( void  ) [static]

RBG startup function.

Definition at line 111 of file rbg.c.

References rbg_startup().


        /* Start up RBG.  There is no way to report an error at this
         * stage, but a failed startup will result in an invalid DRBG
         * that refuses to generate bits.
static void rbg_shutdown_fn ( int booting  __unused) [static]

RBG shutdown function.

Definition at line 121 of file rbg.c.

References rbg_shutdown().


        /* Shut down RBG */
struct startup_fn startup_rbg __startup_fn ( STARTUP_NORMAL  ) [read]

RBG startup table entry.

Variable Documentation

The RBG.

Definition at line 63 of file rbg.c.

Referenced by rbg_generate(), rbg_shutdown(), and rbg_startup().