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

Functions

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

Variables

struct random_bit_generator rbg
 The RBG. More...
 

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

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ rbg_startup()

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 9.1.2.2.

Definition at line 73 of file rbg.c.

73  {
74  union uuid uuid;
75  int len;
76  int rc;
77 
78  /* Try to obtain system UUID for use as personalisation
79  * string, in accordance with ANS X9.82 Part 3-2007 Section
80  * 8.5.2. If no UUID is available, proceed without a
81  * personalisation string.
82  */
83  if ( ( len = fetch_uuid_setting ( NULL, &uuid_setting, &uuid ) ) < 0 ) {
84  rc = len;
85  DBGC ( &rbg, "RBG could not fetch personalisation string: "
86  "%s\n", strerror ( rc ) );
87  len = 0;
88  }
89 
90  /* Instantiate DRBG */
91  if ( ( rc = drbg_instantiate ( &rbg.state, &uuid, len ) ) != 0 ) {
92  DBGC ( &rbg, "RBG could not instantiate DRBG: %s\n",
93  strerror ( rc ) );
94  return rc;
95  }
96 
97  return 0;
98 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A universally unique ID.
Definition: uuid.h:15
#define DBGC(...)
Definition: compiler.h:505
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
int drbg_instantiate(struct drbg_state *state, const void *personal, size_t personal_len)
Instantiate DRBG.
Definition: drbg.c:78
struct random_bit_generator rbg
The RBG.
Definition: rbg.c:63
int fetch_uuid_setting(struct settings *settings, const struct setting *setting, union uuid *uuid)
Fetch value of UUID setting.
Definition: settings.c:1084
uint32_t len
Length.
Definition: ena.h:14
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
struct drbg_state state
DRBG state.
Definition: rbg.h:18

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

Referenced by rbg_startup_fn().

◆ rbg_shutdown()

static void rbg_shutdown ( void  )
static

Shut down RBG.

Definition at line 104 of file rbg.c.

104  {
105 
106  /* Uninstantiate DRBG */
108 }
struct random_bit_generator rbg
The RBG.
Definition: rbg.c:63
void drbg_uninstantiate(struct drbg_state *state)
Uninstantiate DRBG.
Definition: drbg.c:423
struct drbg_state state
DRBG state.
Definition: rbg.h:18

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

Referenced by rbg_shutdown_fn().

◆ rbg_startup_fn()

static void rbg_startup_fn ( void  )
static

RBG startup function.

Definition at line 111 of file rbg.c.

111  {
112 
113  /* Start up RBG. There is no way to report an error at this
114  * stage, but a failed startup will result in an invalid DRBG
115  * that refuses to generate bits.
116  */
117  rbg_startup();
118 }
static int rbg_startup(void)
Start up RBG.
Definition: rbg.c:73

References rbg_startup().

◆ rbg_shutdown_fn()

static void rbg_shutdown_fn ( int booting  __unused)
static

RBG shutdown function.

Definition at line 121 of file rbg.c.

121  {
122 
123  /* Shut down RBG */
124  rbg_shutdown();
125 }
static void rbg_shutdown(void)
Shut down RBG.
Definition: rbg.c:104

References rbg_shutdown().

◆ __startup_fn()

struct startup_fn startup_rbg __startup_fn ( STARTUP_NORMAL  )

RBG startup table entry.

Variable Documentation

◆ rbg

The RBG.

Definition at line 63 of file rbg.c.

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