diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2016-10-16 15:47:32 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2016-10-16 15:47:32 +0000 |
commit | 85d3f29ce384dea6cfbaa80215ce86d2d0358eba (patch) | |
tree | ad3c759c61699b6a0d8b872565d7c1044e0afb7b /src/libs6/ftrig1_make.c | |
parent | 4a90dd1f9063fd5a91431ee6873c25c5c8229805 (diff) | |
download | s6-85d3f29ce384dea6cfbaa80215ce86d2d0358eba.tar.xz |
Unconditionally switch s6-ftrigrd to surf (avoid boot stalling problems, and nobody cares about that RNG not being CS)
Diffstat (limited to 'src/libs6/ftrig1_make.c')
-rw-r--r-- | src/libs6/ftrig1_make.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/libs6/ftrig1_make.c b/src/libs6/ftrig1_make.c index 83ffca9..8352e64 100644 --- a/src/libs6/ftrig1_make.c +++ b/src/libs6/ftrig1_make.c @@ -9,9 +9,26 @@ #include <skalibs/tai.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> +#include <skalibs/surf.h> #include <skalibs/random.h> #include "ftrig1.h" +static SURFSchedule surf_ctx = SURFSCHEDULE_ZERO ; + +void ftrig1_init (void) +{ + char seed[160] ; + random_makeseed(seed) ; + surf_init(&surf_ctx, seed) ; +} + +static inline void surfname (char *s, unsigned int n) +{ + static char const oklist[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZghijklmnopqrstuvwxyz-_0123456789abcdef" ; + surf(&surf_ctx, s, n) ; + while (n--) s[n] = oklist[s[n] & 63] ; +} + int ftrig1_make (ftrig1_t *f, char const *path) { ftrig1_t ff = FTRIG1_ZERO ; @@ -25,7 +42,7 @@ int ftrig1_make (ftrig1_t *f, char const *path) tmp[pathlen + 2 + FTRIG1_PREFIXLEN] = ':' ; if (!timestamp(tmp + pathlen + 3 + FTRIG1_PREFIXLEN)) return 0 ; tmp[pathlen + 28 + FTRIG1_PREFIXLEN] = ':' ; - random_name(tmp + pathlen + 29 + FTRIG1_PREFIXLEN, 16) ; + surfname(tmp + pathlen + 29 + FTRIG1_PREFIXLEN, 16) ; tmp[pathlen + 45 + FTRIG1_PREFIXLEN] = 0 ; { |