remove gcc34
[dragonfly.git] / crypto / heimdal-0.6.3 / lib / des / doPC1
blob096afd8c4614e4f6475e73d9df37cd7863ce3953
1 #!/usr/local/bin/perl
3 @l=(
4 0, 1, 2, 3, 4, 5, 6, 7,
5 8, 9,10,11,12,13,14,15,
6 16,17,18,19,20,21,22,23,
7 24,25,26,27,28,29,30,31
8 );
9 @r=(
10 32,33,34,35,36,37,38,39,
11 40,41,42,43,44,45,46,47,
12 48,49,50,51,52,53,54,55,
13 56,57,58,59,60,61,62,63
16 require 'shifts.pl';
18 sub PERM_OP
20 local(*a,*b,*t,$n,$m)=@_;
22 @z=&shift(*a,-$n);
23 @z=&xor(*b,*z);
24 @z=&and(*z,$m);
25 @b=&xor(*b,*z);
26 @z=&shift(*z,$n);
27 @a=&xor(*a,*z);
30 sub HPERM_OP2
32 local(*a,*t,$n,$m)=@_;
33 local(@x,@y,$i);
35 @z=&shift(*a,16-$n);
36 @z=&xor(*a,*z);
37 @z=&and(*z,$m);
38 @a=&xor(*a,*z);
39 @z=&shift(*z,$n-16);
40 @a=&xor(*a,*z);
43 sub HPERM_OP
45 local(*a,*t,$n,$m)=@_;
46 local(@x,@y,$i);
48 for ($i=0; $i<16; $i++)
50 $x[$i]=$a[$i];
51 $y[$i]=$a[16+$i];
53 @z=&shift(*x,-$n);
54 @z=&xor(*y,*z);
55 @z=&and(*z,$m);
56 @y=&xor(*y,*z);
57 @z=&shift(*z,$n);
58 @x=&xor(*x,*z);
59 for ($i=0; $i<16; $i++)
61 $a[$i]=$x[$i];
62 $a[16+$i]=$y[$i];
66 @L=@l;
67 @R=@r;
69 print "---\n"; &printit(@R);
70 &PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
71 print "---\n"; &printit(@R);
72 &HPERM_OP2(*L,*T,-2,0xcccc0000);
73 &HPERM_OP2(*R,*T,-2,0xcccc0000);
74 print "---\n"; &printit(@R);
75 &PERM_OP(*R,*L,*T,1,0x55555555);
76 print "---\n"; &printit(@R);
77 &PERM_OP(*L,*R,*T,8,0x00ff00ff);
78 print "---\n"; &printit(@R);
79 &PERM_OP(*R,*L,*T,1,0x55555555);
80 print "---\n"; &printit(@R);
81 # &printit(@L);
82 &printit(@R);
83 print <<"EOF";
84 ==============================
85 63 55 47 39 31 23 15 7
86 62 54 46 38 30 22 14 6
87 61 53 45 37 29 21 13 5
88 60 52 44 36 -- -- -- --
90 57 49 41 33 25 17 9 1
91 58 50 42 34 26 18 10 2
92 59 51 43 35 27 19 11 3
93 28 20 12 4 -- -- -- --
94 EOF
95 exit(1);
96 @A=&and(*R,0x000000ff);
97 @A=&shift(*A,16);
98 @B=&and(*R,0x0000ff00);
99 @C=&and(*R,0x00ff0000);
100 @C=&shift(*C,-16);
101 @D=&and(*L,0xf0000000);
102 @D=&shift(*D,-4);
103 @A=&or(*A,*B);
104 @B=&or(*D,*C);
105 @R=&or(*A,*B);
106 @L=&and(*L,0x0fffffff);
108 &printit(@L);
109 &printit(@R);