iPXE
Functions
random_nz.h File Reference

HMAC_DRBG algorithm. More...

#include <stdint.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
int get_random_nz (void *data, size_t len)
 Get random non-zero bytes. More...
 

Detailed Description

HMAC_DRBG algorithm.

Definition in file random_nz.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ get_random_nz()

int get_random_nz ( void *  data,
size_t  len 
)

Get random non-zero bytes.

Parameters
dataOutput buffer
lenLength of output buffer
Return values
rcReturn status code

This algorithm is designed to be isomorphic to the Simple Discard Method described in ANS X9.82 Part 1-2006 Section 9.2.1 (NIST SP 800-90 Section B.5.1.1).

Definition at line 62 of file random_nz.c.

62  {
63  uint8_t *bytes = data;
64  int rc;
65 
66  while ( len ) {
67 
68  /* Generate random byte */
69  if ( ( rc = rbg_generate ( NULL, 0, 0, bytes, 1 ) ) != 0 )
70  return rc;
71 
72  /* Move to next byte if this byte is acceptable */
73  if ( *bytes != 0 ) {
74  bytes++;
75  len--;
76  }
77  }
78 
79  return 0;
80 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int rbg_generate(const void *additional, size_t additional_len, int prediction_resist, void *data, size_t len)
Generate bits using RBG.
Definition: rbg.h:36
unsigned char uint8_t
Definition: stdint.h:10
uint32_t len
Length.
Definition: ena.h:14
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint8_t bytes[64]
Definition: ib_mad.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References bytes, data, len, NULL, rbg_generate(), and rc.

Referenced by rsa_encrypt().