X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/ac2fd5cd29bd9485c6d49badc4ed8287f908b799..d4bb7fded5f9a4b0db99f82e88f22effe94f2ff7:/rand.c diff --git a/rand.c b/rand.c index c3b777d..b004b3f 100644 --- a/rand.c +++ b/rand.c @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: rand.c,v 1.5 2000/06/17 11:53:55 mdw Exp $ + * $Id$ * * Secure random number generator * * (c) 1998 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,39 +15,18 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * Catacomb is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with Catacomb; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: rand.c,v $ - * Revision 1.5 2000/06/17 11:53:55 mdw - * Deprecate `rand_getgood'. Provide a new interface to ensure that a pool - * is well seeded. Use secure arena for memory allocation. - * - * Revision 1.4 1999/12/13 15:34:28 mdw - * Increase the entropy threshhold in rand_getgood. - * - * Revision 1.3 1999/12/10 23:28:07 mdw - * Bug fix: rand_getgood didn't update buffer pointer. - * - * Revision 1.2 1999/10/12 21:00:15 mdw - * Make pool and buffer sizes more sensible. - * - * Revision 1.1 1999/09/03 08:41:12 mdw - * Initial import. - * - */ - /*----- Header files ------------------------------------------------------*/ #include @@ -234,9 +213,9 @@ void rand_add(rand_pool *r, const void *p, size_t sz, unsigned goodbits) /* --- @rand_goodbits@ --- * * - * Arguments: @rand_pool *r@ = pointer to a randomness pool + * Arguments: @rand_pool *r@ = pointer to a randomness pool * - * Returns: Estimate of the number of good bits remaining in the pool. + * Returns: Estimate of the number of good bits remaining in the pool. */ unsigned rand_goodbits(rand_pool *r) @@ -485,6 +464,9 @@ static int gmisc(grand *r, unsigned op, ...) case RAND_KEY: case RAND_NOISESRC: case RAND_SEED: + case RAND_TIMER: + case RAND_GOODBITS: + case RAND_ADD: rc = 1; break; default: @@ -528,6 +510,18 @@ static int gmisc(grand *r, unsigned op, ...) case RAND_SEED: rand_seed(&g->p, va_arg(ap, unsigned)); break; + case RAND_TIMER: + TIMER(&g->p); + break; + case RAND_GOODBITS: + rc = rand_goodbits(&g->p); + break; + case RAND_ADD: { + const void *p = va_arg(ap, const void *); + size_t sz = va_arg(ap, size_t); + unsigned goodbits = va_arg(ap, unsigned); + rand_add(&g->p, p, sz, goodbits); + } break; default: GRAND_BADOP; break;