RSA Security 4.3 Home Security System User Manual


 
Chapter 3 Using the Intel Random Number Generator 17
Generating Random Numbers
Step 1: Create an Algorithm Object
The next task is to create the algorithm object. This object will control the random byte
generation. Creating the object only allocates the memory needed for the process. It
does not initialize the object for random number generation.
Step 2: Set the Algorithm Object
Set the algorithm info. We will specify AI_HW_Random, which will point to the
hardware method that is associated to
AM_HW_RANDOM via B_CreateSessionChooser.
Step 3: Initialize the Random Object
Initialize
randomAlgorithm
to generate random bytes. Here we pass the
CHOOSER
that
was created via the call to
B_CreateSessionChooser above. This chooser contains
pointers to the hardware method that was associated with
AM_HW_RANDOM.
HW_TABLE_ENTRY *HARDWARE_CHOOSER[] = {
&HW_INTEL_RANDOM,
(HW_TABLE_ENTRY *)NULL_PTR
};
B_ALGORITHM_METHOD **CHOOSER = (B_ALGORITHM_METHOD **)NULL_PTR;
if ((status = B_CreateSessionChooser
(SOFTWARE_CHOOSER, &CHOOSER, (POINTER *)HARDWARE_CHOOSER,
(ITEM *)NULL_PTR, (POINTER *)NULL_PTR, &oemTagList)) != 0)
break;
B_ALGORITHM_OBJ randomAlgorithm = (B_ALGORITHM_OBJ)NULL_PTR;
if ((status = B_CreateAlgorithmObject (&randomAlgorithm)) != 0)
break;
if ((status = B_SetAlgorithmInfo
(randomAlgorithm, AI_HW_Random, NULL_PTR)) != 0)
break;