c - OpenSSL random - using ENGINE API to set random, what is the right way to do it? -


in openssl, using engine taking use of hardware, i'm trying make sure rand_bytes use engine , hardware. came across 2 functions:

engine_set_default_rand(engine*) rand_set_rand_engine(engine*) 

seemingly - same. why there 2 of them? 1 right way go?

i've further tested if set functions work disconnecting hardware , performing init, rand_bytes. using first function (engine_set_default_rand) suceeded - software implementation used (why?). when changed second failed on set rand_set_rand_engine function call (which great).

according to: https://www.openssl.org/docs/crypto/engine.html#application_requirements engine_set_default_(engine)* way go, e.g.:

engine_set_default_rand(myptrengine); 

which worked, causing engine implementation used. i've tested modifying custom engine code, injecting simple printfs(...) indicate flow (had problems debugging).

the other call:

rand_set_rand_engine(myptrengine); 

resulted in same (i not know internal differences).

the problem caused me ask, possibility of fallback-to-software mechanism. hardware disconnected , engine using set, random functions seemingly worked. therefore did not know whether engine_set_default_rand worked. after examining engine's code, however, turned out had fallback mechanism. that's why always worked.


Comments

Popular posts from this blog

Unable to open serial port using Putty to bluetooth device on windows 7 64 bit -

bash - How do you programmatically add a bats test? -

java - Getting exception in JDBC thin driver -