pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod:2105:
#else /* Big endian. */ for (int i = 0; i < 8; i++) { ((p_wchar0 *)&THIS->int_buffer)[i] = STR0(Pike_sp[-1].u.string)[7-i]; } #endif THIS->buffer_bits = 64; pop_stack(); }
+
/* Generates a number 0<=c<limit from random bits taken from the
+
int_buffer. Follows the NIST SP800-90A method for converting bit
+
sequences into bound numbers, described in section B.5.1.1, and
+
summarized as "throw away attempts that are too large". */
static INT_TYPE read_int(INT_TYPE limit) { if(limit <= 1) return 0; int bits = my_log2(limit-1)+1; INT64 mask = (1L<<bits)-1; for(int i=0; i<1000; i++) { if(THIS->buffer_bits < bits) fill_int_buffer(); INT_TYPE ret = THIS->int_buffer&mask;