* used for orderly printing to screen, currently only used by the two of
the services: generator_service and seed_file_manager_service
* lock the mutex in a unique_lock only when printing to screen, unlock
it immediately after printing is done
* use proper chrono type for sleep_time (instead of uint)
* also, generator_service is no longer a static method
a couple of fixes/necessary additions were made along the way, namely:
* add a default constructor for DoTask
* rework of the mutex/lock_guard/unique_lock logic in generator/fortuna
* add .fortuna.seed to the list of the ignored (.gitignore)
* add helper function to util for convertin bytes to blocks (16b==block)
* add a wrapper for around the SeedFileManager instance and a way to see
if it's dead or alive (so that it can be restarted if needed)
* the timeout for saving of the seed file has been decreased to a more
reasonable value than 10 minutes (I wouldn't want to lose potentially
up to 10 minutes worth of entropy)
* actually clear out entropy of the pools before a reseed
* correctly prepare the seed for the reseed
* add a couple of helper methods to Pool that assist with getting
length, retrieving and clearing of the collected entropy
* catch exceptions in main(), handle them gracefully
* rm duplicate do_sha() code, consolidate in Util
* make reseed() public so that it can be called from outside
* rm reseed() from do_crypto() where it has no place
* handle the PRNG state with R_state nested class
* add a private property R holding PRNG state to Fortuna
* add R_state properties as defined in Cryptography Engineering:
* a generator instance
* a reseed counter
* 32 pools that the collected entropy is to be distributed over
* add initial definition of the Pool object and its initialization
* attempt to initialize PRNG in Fortuna constructor. wrap the
initialization call in a try-catch block like a cultured person
* erase the string used to print data from random_data() after it's been
used
commit a64b52e5a4
Author: surtur <a_mirre@utb.cz>
Date: Sun Nov 21 23:39:30 2021 +0100
finalise generator
this commit adds a (nearly) complete implementation of the generator.
* wrap calls to generator in a fortuna class method random_data
* calls generator's method generate_random_data, that internally calls
generate_blocks
* use a proper 256bit key in G_state
* add reseed method implementation
* call a reseed in initialize_generator
* do_sha returns proper digest now
* add proper do_crypto implementation
* call generate_blocks internally
* handle re-keying
* optimise header includes
TODO: there are still many commented (enabled on demand) debugging statements
-> TO BE REMOVED
* initialize_generator() is now a private method
* call initialize_generator() inside the constructor of the Generator
* move full struct declaration to generator.h
* have a private field named G of type G_state
* remove explicit instantiation of Generator from fortuna constructor -
Generator is a private field of fortuna
* remove direct initialize_generator() call from fortuna constructor
* remove get_state() calls as G_state G is now a private field
* refactor get_state() to simply return the *private field G_state G*
* refactor do_crypto() - I know, this should have been split to a
separate commit - remove function parameters and useless assignments
inside its body to reflect that once it accesses k and ctr (of the
G_state G), it won't be necessary for them to be passed as parameters,
since *G_state G is now a private field*...
switch to fmt - "A modern formatting library" - for fun and profit,
currently in header-only configuration.
ref: https://github.com/fmtlib/fmtcloses#5closes#4
operate on a fixed string with randomly generated key and iv block on
each run.
this is neither finished nor correct implementation, it currently also
calls the Decryption routine to prove that it's working properly with
the input given ("Oh, I am fortune's fool!" seemed fitting for fortuna).