diff options
author | cvs2svn <admin@example.com> | 1998-10-05 20:13:17 +0000 |
---|---|---|
committer | cvs2svn <admin@example.com> | 1998-10-05 20:13:17 +0000 |
commit | e82f18fab47b698d93971f576f962a3068132912 (patch) | |
tree | 681519717892864935c3d0533cf171098afa649a /src/lib/libcrypto/des/doPC1 | |
parent | 536c76cbb863bab152f19842ab88772c01e922c7 (diff) | |
download | openbsd-SSLeay_0_9_0b.tar.gz openbsd-SSLeay_0_9_0b.tar.bz2 openbsd-SSLeay_0_9_0b.zip |
This commit was manufactured by cvs2git to create tag 'SSLeay_0_9_0b'.SSLeay_0_9_0b
Diffstat (limited to 'src/lib/libcrypto/des/doPC1')
-rw-r--r-- | src/lib/libcrypto/des/doPC1 | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/lib/libcrypto/des/doPC1 b/src/lib/libcrypto/des/doPC1 new file mode 100644 index 0000000000..096afd8c46 --- /dev/null +++ b/src/lib/libcrypto/des/doPC1 | |||
@@ -0,0 +1,110 @@ | |||
1 | #!/usr/local/bin/perl | ||
2 | |||
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 | ||
14 | ); | ||
15 | |||
16 | require 'shifts.pl'; | ||
17 | |||
18 | sub PERM_OP | ||
19 | { | ||
20 | local(*a,*b,*t,$n,$m)=@_; | ||
21 | |||
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); | ||
28 | } | ||
29 | |||
30 | sub HPERM_OP2 | ||
31 | { | ||
32 | local(*a,*t,$n,$m)=@_; | ||
33 | local(@x,@y,$i); | ||
34 | |||
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); | ||
41 | } | ||
42 | |||
43 | sub HPERM_OP | ||
44 | { | ||
45 | local(*a,*t,$n,$m)=@_; | ||
46 | local(@x,@y,$i); | ||
47 | |||
48 | for ($i=0; $i<16; $i++) | ||
49 | { | ||
50 | $x[$i]=$a[$i]; | ||
51 | $y[$i]=$a[16+$i]; | ||
52 | } | ||
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++) | ||
60 | { | ||
61 | $a[$i]=$x[$i]; | ||
62 | $a[16+$i]=$y[$i]; | ||
63 | } | ||
64 | } | ||
65 | |||
66 | @L=@l; | ||
67 | @R=@r; | ||
68 | |||
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 -- -- -- -- | ||
89 | |||
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); | ||
107 | |||
108 | &printit(@L); | ||
109 | &printit(@R); | ||
110 | |||