RSA Security 4.3 manual Generating Random Numbers in Software, Retrieving Hardware Error Codes

Models: 4.3

1 38
Download 38 pages 55.71 Kb
Page 23
Image 23
Step 6b: Free the Session Chooser

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.

if ((status = B_FreeSessionChooser (&CHOOSER, &oemTagList)) != 0) break;

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:

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);

}

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

C h a p t e r 3 U s i n g t h e I n t e l R a n d o m N u m b e r G e n e r a t o r

1 9

Page 23
Image 23
RSA Security 4.3 manual Generating Random Numbers in Software, Retrieving Hardware Error Codes, b Free the Session Chooser