User's Manual

Generating Random Numbers
20 RSA BSAFE Crypto-C Intel Hardware User’s Guide
software. After the seed has been passed to the software algorithm info type, this is
similar to any Crypto-C PRNG implementation. The only difference is the fast, truly
random, seed operation. For this example, you will use Crypto-C’s SHA1 PRNG to
generate random numbers.
Note:
This example will work whether the seed was gathered from the Intel RNG or
via another, backup method.
The example in this section is almost identical to the example in the Crypto-C Users
Manual, “Generating Random Numbers.” Steps 1, 2, 3, and 6 are identical; the only
difference is in the seeding of the PRNG in Step 4 and the random number generation
in Step 5.
Note:
For this software call, you do not need to create a special session chooser. A
standard Crypto-C software chooser is sufficient.
Step 1: Create an Algorithm Object
As before, you need to start by creating an algorithm object. This is identical to the
software implementation
Step 2: Set the Algorithm Object
To set the random algorithm object to use Crypto-C’s SHA1 random number
generator, you need to supply the appropriate algorithm info type. For SHA1, this is
AI_X962Random_V0. Again, this is identical to a software implementation.
Note:
This algorithm info type is named after the standard where the pseudo-
random number generator is defined. Because SHA1 is considered one of the
most secure implementations for creating pseudo-random numbers, there are
a number of SHA1 random number generators in the literature. All of them
use SHA1, but may differ in certain implementation details. Therefore, the AI
is named after the standard for clarity and precision.
if ((status = B_CreateAlgorithmObject (&randomAlgorithm)) != 0)
break;
if ((status = B_SetAlgorithmInfo
(randomAlgorithm, AI_X962Random_V0, NULL_PTR)) != 0)
break;