iPXE
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)
 FILE_SECBOOT (PERMITTED)
int get_random_nz (void *data, size_t len)
 Get random non-zero bytes.

Detailed Description

HMAC_DRBG algorithm.

Definition in file random_nz.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

References data, and len.

◆ get_random_nz()

int get_random_nz ( void * data,
size_t len )
extern

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 63 of file random_nz.c.

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

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

Referenced by rsa_encrypt().