X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/b3f050848e5d285c2a1d7f8a4bea98984c201805..813390c45f438f411662b1a55678e63f11681eb4:/noise.h diff --git a/noise.h b/noise.h index d335448..48fe6bd 100644 --- a/noise.h +++ b/noise.h @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: noise.h,v 1.2 1999/12/10 23:29:48 mdw Exp $ + * $Id: noise.h,v 1.6 2004/04/08 01:36:15 mdw Exp $ * - * Acquisition of environmental noise (Unix specific) + * Acquisition of environmental noise (Unix-specific) * * (c) 1998 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,29 +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: noise.h,v $ - * Revision 1.2 1999/12/10 23:29:48 mdw - * Change header file guard names. - * - * Revision 1.1 1999/09/03 08:41:12 mdw - * Initial import. - * - */ - #ifndef CATACOMB_NOISE_H #define CATACOMB_NOISE_H @@ -55,7 +44,7 @@ /*----- Noise source definition -------------------------------------------*/ -extern rand_source noise_source; +extern const rand_source noise_source; /*----- Magic numbers -----------------------------------------------------*/ @@ -100,7 +89,7 @@ extern int noise_devrandom(rand_pool */*r*/); * Use: Sets the user and group ids to be used by @noise_filter@ * when running child processes. This is useful to avoid * giving shell commands (even carefully written ones) undue - * privileges. + * privileges. This interface is Unix-specific. */ extern void noise_setid(uid_t /*uid*/, gid_t /*gid*/); @@ -124,10 +113,38 @@ extern void noise_setid(uid_t /*uid*/, gid_t /*gid*/); * fails to complete within a short time period, it is killed. * Paranoid use of close-on-exec flags for file descriptors is * recommended. + * + * This interface is Unix-specific. */ extern int noise_filter(rand_pool */*r*/, int /*good*/, const char */*c*/); +/* --- @noise_freewheel@ --- * + * + * Arguments: @rand_pool *r@ = pointer to a randomness pool + * + * Returns: Nonzero if some randomness was contributed. + * + * Use: Runs a free counter for a short while as a desparate attempt + * to get randomness from somewhere. This is actually quite + * effective. + */ + +int noise_freewheel(rand_pool */*r*/); + +/* --- @noise_enquire@ --- * + * + * Arguments: @rand_pool *r@ = pointer to a randomness pool + * + * Returns: Nonzero if some randomness was contributed. + * + * Use: Runs some shell commands to enquire about the prevailing + * environment. This can gather quite a lot of low-quality + * entropy. + */ + +extern int noise_enquire(rand_pool */*r*/); + /* --- @noise_acquire@ --- * * * Arguments: @rand_pool *r@ = pointer to a randomness pool