s->lenhi = s->lenlo = 0;
}
-void SHA_Bytes(SHA_State * s, void *p, int len)
+void SHA_Bytes(SHA_State * s, const void *p, int len)
{
unsigned char *q = (unsigned char *) p;
uint32 wordblock[16];
}
}
-void SHA_Simple(void *p, int len, unsigned char *output)
+void SHA_Simple(const void *p, int len, unsigned char *output)
{
SHA_State s;
int pos;
};
-random_state *random_init(char *seed, int len)
+random_state *random_new(const char *seed, int len)
{
random_state *state;
return state;
}
+random_state *random_copy(random_state *tocopy)
+{
+ random_state *result;
+ result = snew(random_state);
+ memcpy(result->seedbuf, tocopy->seedbuf, sizeof(result->seedbuf));
+ memcpy(result->databuf, tocopy->databuf, sizeof(result->databuf));
+ result->pos = tocopy->pos;
+ return result;
+}
+
unsigned long random_bits(random_state *state, int bits)
{
unsigned long ret = 0;
bits += 3;
assert(bits < 32);
- max = 1 << bits;
+ max = 1L << bits;
divisor = max / limit;
max = limit * divisor;
return dupstr(retbuf);
}
-random_state *random_state_decode(char *input)
+random_state *random_state_decode(const char *input)
{
random_state *state;
int pos, byte, digits;