waywardgeek / infnoise

The world's easiest TRNG to get right
Creative Commons Zero v1.0 Universal
732 stars 100 forks source link

libinfnoise #55

Closed manuel-domke closed 6 years ago

manuel-domke commented 6 years ago

I made a big refactoring towards libinfnoise. Touched almost everything.

It compiles a shared lib "libinfnoise.so". Some examples are under software/examples/libinfnoise.

The infnoise driver still relies on one or two functions defined in libinfnoise_private.h and uses a static version of the lib, but almost all code is shared. Also wrote tests (using the added bats submodules) to ensure proper function of the binary.

To be able to return the data from the lib functions I added result arrays (which are only written to when noOutput==true and result!=NULL).

Some things to be improved later on:

  1. [cleanup] remove ftdi_context from interface methods
  2. [feature] provide better way to monitor health (still writes to stderr from within libinfnoise/healtcheck.c)
  3. [feature] listUSBDevices also still prints to stdout (should return a list of devices instead)
  4. [cleanup] make infnoise also use the shared lib (maybe not?)
  5. build it for Windows

The critical parts are done, but error handling needed some bigger changes. Please review.

manuel-domke commented 6 years ago

Another change worth a note: I've moved keccakState to a local variable in libinfnoise.c, so it doesn't have to be passed with each readData call.

Not to sure if this was a good idea - but from the point of a library user I would not want to carry around the keccakState all the time.

Same is for ftdi_context, which I plan to remove from the interface methods as well.

manuel-domke commented 6 years ago

All changes merged with #65