RSA Security 4.3 Home Security System User Manual


 
Generating Random Numbers
22 RSA BSAFE Crypto-C Intel Hardware User’s Guide
call would be identical in a software implementation:
Step 5: Generate Random Numbers
Before calling B_GenerateRandomBytes, prepare a buffer for receiving the random
bytes. This is a little different than the software implementation.
Now you can generate the random bytes. Since generating 128 bytes is quick, you can
use a
NULL_PTR for the surrender context:
Step 6: Destroy all Objects
Remember to destroy all objects when you are done with them, and free all memory.
Again, this is identical to the software implementation:
if ((status = B_RandomUpdate
(randomAlgorithm, randomSeed, randomSeedLen,
(A_SURRENDER_CTX *)NULL_PTR)) != 0)
break;
randomByteBuffer = T_malloc (BYTES_TO_GENERATE);
if ((status = (randomByteBuffer == NULL_PTR)) != 0)
break;
T_memset (randomByteBuffer, 0, BYTES_TO_GENERATE);
if ((status = B_GenerateRandomBytes
(randomAlgorithm, randomByteBuffer, BYTES_TO_GENERATE,
(A_SURRENDER_CTX *)NULL_PTR)) != 0)
break;
B_DestroyAlgorithmObject (&randomAlgorithm);
T_memset (randomSeed, 0, randomSeedLen);
T_free (randomSeed);
T_free (randomByteBuffer);