X-Git-Url: https://git.distorted.org.uk/~mdw/become/blobdiff_plain/c4f2d992e4a0fc068281376d89ec38de56dc2f58..b80cbed5cd59d00d18120d8fd2a6b66212d8373e:/src/keygen.c diff --git a/src/keygen.c b/src/keygen.c index 17bf93c..eba38d9 100644 --- a/src/keygen.c +++ b/src/keygen.c @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: keygen.c,v 1.1 1997/07/21 13:47:48 mdw Exp $ + * $Id: keygen.c,v 1.3 1997/09/17 15:29:28 mdw Exp $ * * Key generation * * (c) 1997 EBI */ -/*----- Licencing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of `become' * @@ -22,14 +22,21 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with `become'; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with `become'; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /*----- Revision history --------------------------------------------------* * * $Log: keygen.c,v $ - * Revision 1.1 1997/07/21 13:47:48 mdw + * Revision 1.3 1997/09/17 15:29:28 mdw + * Mix the noise from the key timings with some other environmental noise + * (obtained from `noise_acquire') for a little bit more randomness. + * + * Revision 1.2 1997/08/04 10:24:23 mdw + * Sources placed under CVS control. + * + * Revision 1.1 1997/07/21 13:47:48 mdw * Initial revision * */ @@ -57,8 +64,10 @@ /* --- Local headers --- */ #include "config.h" -#include "tx.h" #include "mdwopt.h" +#include "noise.h" +#include "rand.h" +#include "tx.h" #include "utils.h" /*----- Static variables --------------------------------------------------*/ @@ -245,9 +254,9 @@ static void kg__gen(unsigned char *ui, size_t sz) unsigned long fact = 1000000 / CLOCKS_PER_SEC; fprintf(kg__ttyfp, -"I need to get %i random bits; I'll do this by timing your keypresses.\n" +"I need to get %lu random bits; I'll do this by timing your keypresses.\n" "Please type some arbitrary text until I say `done'.\n", - sz); + (unsigned long)sz); { struct timeval tv; @@ -261,7 +270,7 @@ static void kg__gen(unsigned char *ui, size_t sz) /* --- Print current status --- */ - fprintf(kg__ttyfp, "\r%5i...", sz); + fprintf(kg__ttyfp, "\r%5lu...", (unsigned long)sz); fflush(kg__ttyfp); /* --- Read the next character --- */ @@ -564,6 +573,14 @@ int main(int argc, char *argv[]) kg__gen(uip, sz); kg__crepair(); + /* --- Find some noise from the environment too --- */ + + rand_clear(); + noise_acquire(); + rand_add(uip, sz / 8); + rand_churn(); + rand_extract(uip, sz / 8); + /* --- Now write the number and exit --- */ D( fputs("*** ", fp); tx_putBits(uip, sz, stdout); ) @@ -571,6 +588,7 @@ int main(int argc, char *argv[]) if (file) fclose(fp); memset(uip, 0, sz / 8); /* Burn temporary buffer */ + rand_clear(); return (0); }