* Do a fast modular exponation, returned value will be in the range * of 0 - (mod-1) */
| 155 | * of 0 - (mod-1) |
| 156 | */ |
| 157 | static u_int32_t |
| 158 | pmod(u_int32_t gen, u_int32_t expo, u_int32_t mod) |
| 159 | { |
| 160 | u_int64_t s, t, u; |
| 161 | |
| 162 | s = 1; |
| 163 | t = gen; |
| 164 | u = expo; |
| 165 | |
| 166 | while (u) { |
| 167 | if (u & 1) |
| 168 | s = (s * t) % mod; |
| 169 | u >>= 1; |
| 170 | t = (t * t) % mod; |
| 171 | } |
| 172 | return (s); |
| 173 | } |
| 174 | |
| 175 | /* |
| 176 | * Initializes the seed and chooses a suitable generator. Also toggles |