A SERVICE OF

logo

B_RandomInit
328 RSA BSAFE Crypto-C Library Reference Manual
B_RandomInit
Description
B_RandomInit initializes
randomAlgorithm
for generating random bytes using the
algorithm specified by a previous call to
B_SetAlgorithmInfo.
randomAlgorithm
is
ready to generate bytes after the call to
B_RandomInit. However, it is necessary to mix
in random seed values with
B_RandomUpdate. Otherwise, without seed values, the
bytes generated by the algorithm follow a default unseeded byte sequence. The
chooser for selecting the algorithm method is
algorithmChooser
. The surrender context
for processing and canceling during lengthy operations is
surrenderContext
; if its
value is
(A_SURRENDER_CTX *)NULL_PTR, Crypto-C does not use it.
B_RandomInit is called once to create the generator, then B_RandomUpdate is called one
or more times to add “seed” bytes (values that are hard for an attacker to predict) to
the generator. After enough seed is added, for example, at least 128 bytes, then
B_GenerateRandomBytes can be called one or more times to generate blocks of
pseudo-random data. If
B_RandomUpdate is only called once before
B_GenerateRandomBytes, then the BSAFE 2 algorithms will be used. Two or more calls
to
B_RandomUpdate will cause the improved BSAFE 3 algorithms to be used. It is also
possible to call
B_RandomUpdate after calling B_GenerateRandomBytes in order to add
more hard-to-predict values to the generator. There is no need to call
B_RandomInit
again.
Return value
int B_RandomInit (
B_ALGORITHM_OBJ randomAlgorithm, /* random algorithm object */
B_ALGORITHM_CHOOSER algorithmChooser, * algorithm chooser */
A_SURRENDER_CTX *surrenderContext /* surrender context */
);
Value Description
0 Operation was successful.
non-zero see Appendix A, ”Crypto-C Error Types”