Generating Random Numbers
call would be identical in a software implementation:
if ((status = B_RandomUpdate (randomAlgorithm, randomSeed, randomSeedLen, (A_SURRENDER_CTX *)NULL_PTR)) != 0)
break;
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.
randomByteBuffer = T_malloc (BYTES_TO_GENERATE); if ((status = (randomByteBuffer == NULL_PTR)) != 0)
break;
T_memset (randomByteBuffer, 0, BYTES_TO_GENERATE);
Now you can generate the random bytes. Since generating 128 bytes is quick, you can use a NULL_PTR for the surrender context:
if ((status = B_GenerateRandomBytes
(randomAlgorithm, randomByteBuffer, BYTES_TO_GENERATE, (A_SURRENDER_CTX *)NULL_PTR)) != 0)
break;
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:
B_DestroyAlgorithmObject (&randomAlgorithm);
T_memset (randomSeed, 0, randomSeedLen);
T_free (randomSeed);
T_free (randomByteBuffer);
2 2 | R S A B S A F E C r y p t o - C I n t e l H a r d w a r e U s e r ’s G u i d e |