Commit Graph

81 Commits

Author SHA1 Message Date
surtur 1ec70d1161
fortuna,generator({fmt}) print with colours 2022-02-03 04:52:19 +01:00
surtur ffd0180578
chore(generator): collapse 2 try-catch blocks 2022-02-03 02:56:28 +01:00
surtur 348b921795
generator: add const qualifier to vars where sound 2022-02-03 02:41:47 +01:00
surtur c4dcab3046
generator: stop hex-encoding bytes in do_crypto()
in fortuna, print the random bytes as they come, without a newline, to
stdout. the idea is it can be directly piped to, say, dieharder, for,
e.g. testing purposes. also print info msg to stderr as is now customary
throughout the program.
2022-02-03 03:35:11 +01:00
surtur 1da24b13da
{,generate_}random_data: use const uint64_t 2022-02-03 01:53:53 +01:00
surtur a3daa722da
chore: print info msgs to stderr 2022-02-03 00:37:20 +01:00
surtur 80fcb13e8b
generator: use least-significant-byte-first ctr 2022-01-30 22:56:08 +01:00
surtur c6bf1c7f52
generator: use de_hex() 2022-01-30 22:40:21 +01:00
surtur 01238c805a
generator: change exit(1) -> throw 2022-01-30 00:00:20 +01:00
surtur 1a02256b2b
generator: add ctr_inc() fun 2022-01-27 22:54:53 +01:00
surtur a1beb2893d
generator: make sure not to return data unseeded 2022-01-26 22:59:37 +01:00
surtur 8f0f29d190
generator: make some internal vars const 2022-01-26 22:43:22 +01:00
surtur c40806e68d
generator: create permanent Serpent encryption obj 2022-01-26 22:35:45 +01:00
surtur 606527618d
gen: simplify time_to_reseed() return logic 2022-01-20 08:40:42 +01:00
surtur 674ceedc4a
gen: mtx -> mutable recursive_mtx to all functions 2022-01-20 08:36:02 +01:00
surtur 55659bd243
generator: pass param by const& 2022-01-17 07:22:19 +01:00
surtur b4d7cb3dfb
chore: rm trailing ; 2022-01-17 04:03:06 +01:00
surtur 7fca4481c8
generator: implement time_to_reseed() fun 2022-01-15 13:35:56 +01:00
surtur 57fae8f582
generate_random_data: return early on invalid arg 2022-01-14 05:44:37 +01:00
surtur 53cde1371f
generator: improve iteration 2022-01-14 05:40:22 +01:00
surtur e0448d6d08
fortuna,generator: better printing 2022-01-14 05:20:52 +01:00
surtur 0bac9f83d3
generator: fix generate_random_data() function 2022-01-14 01:09:24 +01:00
surtur a0df93c9ec
clang-format: BinPack{Arguments,Parameters}: false 2022-01-13 06:04:18 +01:00
surtur 2c3d5b4528
g: simplify generate_random_data() hexdecode block 2022-01-13 02:15:23 +01:00
surtur 4b216a6f6e
refactor: clang-format 2022-01-10 04:25:03 +01:00
surtur 67c2462c3a
fix: -Wtype-limits x2 2022-01-09 12:31:16 +01:00
surtur 795b9ffe54
add proper SeedFileManager implementation
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)
2022-01-09 11:58:38 +01:00
surtur 8827582f90
generator: rm using directives,use CryptoPP prefix 2022-01-08 07:30:31 +01:00
surtur f5563397ee
generator wip: add time_to_reseed() member function 2022-01-08 07:24:04 +01:00
surtur ee0fb01dc8
generator: use G.k_length var instead of .size() 2022-01-08 07:16:19 +01:00
surtur b3c1033e6a
generator: resize dst string to needed size 2022-01-08 07:12:42 +01:00
surtur 3d22b8de8b
generator: fix memmove UB warnings 2022-01-08 07:06:31 +01:00
surtur 408d783c37
chore(generator): comments clean-up 2022-01-08 06:34:30 +01:00
surtur 592d3aac47
generator: get rid of AutoSeededRandomPool et al. 2022-01-08 06:01:10 +01:00
surtur 51c0b1fc56
generator: rm misplaced G.k wipe 2022-01-07 05:51:25 +01:00
surtur 1cba4dea10
generator: make get_state() const 2022-01-06 16:47:46 +01:00
surtur 158545f401
generator: rm bogus reseed+add lock guards 2022-01-03 06:29:16 +01:00
surtur 9e6efc9d38
generator: get rid of an intermediary var 2022-01-03 05:17:29 +01:00
surtur 42a73a00af
style(generator) 2022-01-03 01:02:05 +01:00
surtur 65c476dbd6
add Util class + perform general refactor
* 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
2021-12-13 05:10:07 +01:00
surtur d907c9db6e
generator: tweak generate_random_data logic 2021-12-11 21:33:42 +01:00
surtur fb02ef9a23
generator: make dtor noexcept 2021-12-11 20:43:48 +01:00
surtur 25cbddf41f
generator: use a proper uin64_t literal 2021-12-11 01:13:01 +01:00
surtur b9676226c5
chore(generator): erase -> clear 2021-12-11 01:10:14 +01:00
surtur a7e8caa26e
generator: memcpy -> memmove 2021-12-11 01:04:57 +01:00
surtur 595245fbce
fix(generator): incorrect copying, no protections
* use try-catch whenever possible
* perform memcpy operations in the right direction
* make greater use of local constants
* use more of the braced initializations
* there were memcpy operations of incorrect sizes in place, particularly
  in regard to generator key (G.k) and counter (G.ctr), which resulted
  in key bytes being set to garbage
2021-12-10 20:02:30 +01:00
surtur 5557f0d9e6
refactor(generator): clean up includes a little 2021-12-06 00:08:32 +01:00
surtur 53645ea160
generator: add more try-catch blocks internally
one around initialization and another when calling reseed()
2021-12-05 03:13:47 +01:00
surtur 6f6b3cb8e2
generator: wrap the initialization in a try-catch 2021-12-05 02:00:25 +01:00
surtur 0c2a1c6744
finalise generator
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
2021-11-30 14:09:39 +01:00