]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chanservcrypto.c
4 #include "../core/error.h"
5 #include "../lib/prng.h"
9 void chanservcryptoinit(void) {
12 FILE *e
= fopen(ENTROPYSOURCE
, "rb");
14 Error("chanserv",ERR_STOP
,"Unable to open entropy source.");
15 /* shouldn't be running now... */
18 ret
= fread(rng
.randrsl
, 1, sizeof(rng
.randrsl
), e
);
21 if(ret
!= sizeof(rng
.randrsl
)) {
22 Error("chanserv",ERR_STOP
,"Unable to read entropy.");
23 /* shouldn't be running now... */
29 ub4
cs_getrandint(void) {
33 void cs_getrandbytes(unsigned char *buf
, size_t bytes
) {
36 for(;bytes
>0;bytes
-=4,buf
+=4) {
37 ub4 b
= cs_getrandint();