B_RandomInit

B_RandomInit

B_RandomInit

int B_RandomInit (

 

 

 

 

B_ALGORITHM_OBJ

randomAlgorithm,

/* random algorithm object */

B_ALGORITHM_CHOOSER algorithmChooser,

*

algorithm

chooser */

A_SURRENDER_CTX

*surrenderContext

/*

surrender

context */

);

 

 

 

 

 

 

 

 

 

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

again.

Return value

Value

Description

0

Operation was successful.

non-zero

see Appendix A, ”Crypto-C Error Types”

 

 

3 2 8

R S A B S A F E C r y p t o - C L i b r a r y R e f e r e n c e M a n u a l

Page 338
Image 338
RSA Security 5 manual Int BRandomInit