|
|
1.1 root 1: /*
2: * Generate Key-dependent Permutation of 128 Characters
3: * D.P.Mitchell 83/06/28.
4: */
5:
6: #include "crypt.h"
7:
8: extern Block xkey[];
9: Block tempkey[SUPERSIZE];
10:
11: int permutation[128] = {
12: 89,126,112, 71, 4, 60, 22, 37, 6, 39, 41, 75, 77, 94, 40, 84,
13: 124, 59, 92, 96, 51, 26, 31, 52,127, 65, 63, 38, 68, 69,101, 36,
14: 99,122,100, 19, 72, 61, 44, 73, 24,111, 25, 88, 7, 28,106, 32,
15: 14, 98, 30, 0,104, 33, 78, 67,107, 74, 13,116, 15,103, 34, 3,
16: 80,110, 91, 17,120,115, 46,119, 82, 57, 8, 76,105, 18, 43,109,
17: 85, 95, 42,125,117, 87, 55, 54, 5, 29, 81, 1, 35,121, 10, 21,
18: 11, 56, 20,102, 86, 47, 49, 83, 58, 70, 23, 12, 9, 2, 97, 53,
19: 93, 45, 79, 27, 90, 62,113, 50, 48,118, 16,114, 66,123, 64,108,
20: };
21:
22: shuffle_permutation()
23: {
24: int temp, i, j;
25: int bnum;
26: long x;
27:
28: for (i = 0; i < SUPERSIZE; i++)
29: tempkey[i] = xkey[i];
30: for (i = 128; i > 0; ) {
31: bnum = (i / 2) % SUPERSIZE;
32: x = tempkey[bnum].left & 0x7fffffff;
33: j = x % i;
34: x = x / i;
35: --i;
36: temp = permutation[i];
37: permutation[i] = permutation[j];
38: permutation[j] = temp;
39: tempkey[bnum].left = x;
40: x = tempkey[bnum].right & 0x7fffffff;
41: j = x % i;
42: x = x / i;
43: --i;
44: temp = permutation[i];
45: permutation[i] = permutation[j];
46: permutation[j] = temp;
47: tempkey[bnum].right = x;
48: }
49: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.