/*
- silcrng.c
+ silcrng.c
- Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+ Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2001 Pekka Riikonen
+ Copyright (C) 1997 - 2002 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program 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
64 bits of output and hard noise every 160 bits of output.
*/
-typedef struct SilcRngObjectStruct {
+struct SilcRngStruct {
unsigned char pool[SILC_RNG_POOLSIZE];
unsigned char key[64];
SilcRngState state;
uint8 threshhold;
char *devrandom;
int fd_devurandom;
-} SilcRngObject;
+};
/* Allocates new RNG object. */
-SilcRng silc_rng_alloc()
+SilcRng silc_rng_alloc(void)
{
SilcRng new;
/* Returns random byte. */
-unsigned char silc_rng_get_byte(SilcRng rng)
+uint8 silc_rng_get_byte(SilcRng rng)
{
rng->threshhold++;
/* Initialize global RNG. If `rng' is provided it is set as the global
RNG object (it can be allocated by the application for example). */
-int silc_rng_global_init(SilcRng rng)
+bool silc_rng_global_init(SilcRng rng)
{
if (rng)
global_rng = rng;
/* Uninitialize global RNG */
-int silc_rng_global_uninit()
+bool silc_rng_global_uninit(void)
{
if (global_rng) {
silc_rng_free(global_rng);
/* These are analogous to the functions above. */
-unsigned char silc_rng_global_get_byte()
+uint8 silc_rng_global_get_byte(void)
{
return global_rng ? silc_rng_get_byte(global_rng) : 0;
}
/* Return random byte as fast as possible. Reads from /dev/urandom if
available. If not then return from normal RNG (not so fast). */
-unsigned char silc_rng_global_get_byte_fast()
+uint8 silc_rng_global_get_byte_fast(void)
{
#ifndef SILC_WIN32
unsigned char buf[1];
#endif
}
-uint16 silc_rng_global_get_rn16()
+uint16 silc_rng_global_get_rn16(void)
{
return global_rng ? silc_rng_get_rn16(global_rng) : 0;
}
-uint32 silc_rng_global_get_rn32()
+uint32 silc_rng_global_get_rn32(void)
{
return global_rng ? silc_rng_get_rn32(global_rng) : 0;
}