RSA Security 4.3 Home Security System User Manual


 
Chapter 3 Using the Intel Random Number Generator 19
Generating Random Numbers
Step 6b: Free the Session Chooser
Free the session chooser. It is important to free the session chooser, so that any
handles to hardware and allocated memory are released.
Retrieving Hardware Error Codes
If the hardware fails or cannot return a seed, Crypto-C will return an error of
BE_HARDWARE or BE_NOT_SUPPORTED. BE_HARDWARE indicates that the Intel Random
Number Generator has returned an error. This error can be retrieved using
B_GetExtendedErrorInfo, as shown below:
For information about the Intel error codes returned by
B_GetExtendedErrorInfo,
consult Appendix B. An error of
BE_NOT_SUPPORTED may mean that there is a problem
accessing the BHAPI driver. See Appendix A for more information.
Generating Random Numbers in Software
Once you have a random seed, you can generate pseudo-random numbers in
if ((status = B_FreeSessionChooser (&CHOOSER, &oemTagList)) != 0)
break;
ITEM errorData;
POINTER am;
/* Call B_GetExtendedErrorInfo to retrieve the error information.
The data returned in the data field of errorData is a structure
of A_RSA_EXTENDED_ERROR type. The third parameter
will return a pointer to the algorithm method that was in
use when the error was encountered. */
B_GetExtendedErrorInfo(randomAlgorithm, &errorData, &am);
/* Print out the error information. */
if (am == &HW_INTEL_RANDOM) {
printf ("[Seed] Code: %d\n",
((A_RSA_EXTENDED_ERROR *)errorData.data)->errorCode);
printf ("[Seed] Message: %s",
((A_RSA_EXTENDED_ERROR *)errorData.data)->errorMsg);
}