2 * Produce a "generalized CRC" table. Assumes a platform with
3 * /dev/urandom -- otherwise reimplement get_random_byte().
13 static uint8_t get_random_byte(void)
20 fd
= open("/dev/urandom", O_RDONLY
);
24 rv
= read(fd
, &buf
, 1);
25 if (rv
< 1 && errno
!= EAGAIN
)
32 static void random_permute(uint8_t *buf
)
37 for (i
= 0; i
< 256; i
++)
41 for (i
= 255; i
> 0; i
--) {
45 j
= get_random_byte() & m
;
53 static void xcrc_table(uint64_t *buf
)
58 memset(buf
, 0, 8*256); /* Make static checkers happy */
60 for (i
= 0; i
< 8; i
++) {
62 for (j
= 0; j
< 256; j
++)
63 buf
[j
] = (buf
[j
] << 8) | perm
[j
];
74 for (i
= 0; i
< 256; i
++) {
75 printf("%016"PRIx64
"\n", buf
[i
]);