This file is indexed.

/usr/share/nickle/prng.5c is in nickle 2.77-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * Use ARC4 to generate large random numbers
 *
 * Bart 1999/2
 *
 * Modified 2003/4 to support /dev/random
 */

autoload ARC4;

namespace PRNG {
  import File;

  global bool setkey = false;

  public void srandom(int s) 
    /*
     * Seed the PRNG with 's'
     */
  {
    ARC4::nsetkey(10, abs (s));
    setkey = true;
  }

  public void dev_srandom(int nbits) 
    /*
     * Use 'nbits' of /dev/urandom to seed the PRNG
     */
  {
    twixt(file f = open("/dev/urandom", "r"); close(f)) {
      int seed = 0;
      while (nbits >= 8) {
	seed = (seed << 8) | getb(f);
	nbits -= 8;
      }
      if (nbits > 0)
	seed = (seed << nbits) | (getb(f) & ((1 << nbits) - 1));
      srandom(seed);
    }
  }

  public int randbits(int n) 
    /*
     * returns an 'n'-*bit* random number in 0..(2**'n')-1 
     */
  {
    int q = n >> 3;
    int r = n & 7;
    if (!setkey)
      srandom(0);
    int acc = ARC4::streambyte() >> (8 - r);
    while (q > 0) {
      --q;
      acc += ARC4::streambyte() << (8 * q + r);
    }
    return acc;
  }

  public int randint(int n) 
    /* 
     * Returns a random integer in the range 0..'n'-1 
     */
  {
    return randbits(32 + bit_width (n)) % n;
  }

  public void shuffle(&poly[*] a) 
    /*
     * Randomly shuffle 'a' in place
     */
  {
    int na = dim(a);
    for (int i = 0; i < na - 1; i++) {
      int j = randint(na - i) + i;
      poly tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
    }
  }

}