From 1558e7dbbf3a37766f09616c53168c090a7d617e Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 23 Feb 2019 16:43:41 -0600 Subject: Promote mcookie --- toys/other/mcookie.c | 35 +++++++++++++++++++++++++++++++++++ toys/pending/mcookie.c | 35 ----------------------------------- 2 files changed, 35 insertions(+), 35 deletions(-) create mode 100644 toys/other/mcookie.c delete mode 100644 toys/pending/mcookie.c diff --git a/toys/other/mcookie.c b/toys/other/mcookie.c new file mode 100644 index 00000000..fb83f5e3 --- /dev/null +++ b/toys/other/mcookie.c @@ -0,0 +1,35 @@ +/* mcookie - generate a 128-bit random number (used for X "magic cookies") + * + * Copyright 2019 AD Isaac Dunham + * + * No standard. + * + * -f and -m are not supported: md5sums of arbitrary files are not a good + * source of entropy, just ask the system for 128 bits and print it. + +USE_MCOOKIE(NEWTOY(mcookie, "v(verbose)V(version)", TOYFLAG_USR|TOYFLAG_BIN)) + +config MCOOKIE + bool "mcookie" + default y + help + usage: mcookie [-vV] + + Generate a 128-bit strong random number. + + -v show entropy source (verbose) + -V show version +*/ + +#define FOR_mcookie +#include "toys.h" + +void mcookie_main(void) +{ + long long *ll = (void *)toybuf; + + if (FLAG(V)) return (void)puts("mcookie from toybox"); + xgetrandom(toybuf, 16, 0); + if (FLAG(v)) fputs("Got 16 bytes from xgetrandom()\n", stderr); + xprintf("%016llx%06llx\n", ll[0], ll[1]); +} diff --git a/toys/pending/mcookie.c b/toys/pending/mcookie.c deleted file mode 100644 index 12138b89..00000000 --- a/toys/pending/mcookie.c +++ /dev/null @@ -1,35 +0,0 @@ -/* mcookie - generate a 128-bit random number (used for X "magic cookies") - * - * Copyright 2019 AD Isaac Dunham - * - * No standard. - * - * -f and -m are not supported: md5sums of arbitrary files are not a good - * source of entropy, just ask the system for 128 bits and print it. - -USE_MCOOKIE(NEWTOY(mcookie, "v(verbose)V(version)", TOYFLAG_USR|TOYFLAG_BIN)) - -config MCOOKIE - bool "mcookie" - default n - help - usage: mcookie [-vV] - - Generate a 128-bit strong random number. - - -v show entropy source (verbose) - -V show version -*/ - -#define FOR_mcookie -#include "toys.h" - -void mcookie_main(void) -{ - long long *ll = (void *)toybuf; - - if (FLAG(V)) return (void)puts("mcookie from toybox"); - xgetrandom(toybuf, 16, 0); - if (FLAG(v)) fputs("Got 16 bytes from xgetrandom()\n", stderr); - xprintf("%016llx%06llx\n", ll[0], ll[1]); -} -- cgit v1.2.3