minix/servers/inet/generic/rand256.c
Lionel Sambuc f640210005 Removing obsolete _NBSD_LIBC define
Change-Id: Ia6ce84ccdf36cf6f64540b990baaa7d85c53533d
2013-02-26 09:44:24 +00:00

37 lines
594 B
C

/*
rand256.c
Created: Oct 2000 by Philip Homburg <philip@f-mnx.phicoh.com>
Generate 256-bit random numbers
*/
#include <sys/sha2.h>
#include "inet.h"
#include "rand256.h"
static u32_t base_bits[8];
void init_rand256(bits)
u8_t bits[32];
{
memcpy(base_bits, bits, sizeof(base_bits));
}
void rand256(bits)
u8_t bits[32];
{
u32_t a;
SHA256_CTX ctx;
a= ++base_bits[0];
if (a == 0)
base_bits[1]++;
SHA256_Init(&ctx);
SHA256_Update(&ctx, (unsigned char *)base_bits, sizeof(base_bits));
SHA256_Final(bits, &ctx);
}
/*
* $PchId: rand256.c,v 1.1 2005/06/28 14:13:43 philip Exp $
*/