line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*- |
2
|
|
|
|
|
|
|
# DES_PP.pm - Pure perl implementation of DES. |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# The master file for the module is DES_PP.m4 which needs to be run through |
5
|
|
|
|
|
|
|
# the m4. Please edit DES_PP.m4 if you need to modify! |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Crypt::DES_PP; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
4938
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
160
|
|
10
|
4
|
|
|
4
|
|
23
|
use Carp; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
363
|
|
11
|
4
|
|
|
4
|
|
14694
|
use integer; |
|
4
|
|
|
|
|
63
|
|
|
4
|
|
|
|
|
24
|
|
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
166
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
651
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
require Exporter; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
@ISA = qw (Exporter); |
18
|
|
|
|
|
|
|
@EXPORT = qw (); |
19
|
|
|
|
|
|
|
@EXPORT_OK = qw (); |
20
|
|
|
|
|
|
|
$VERSION = '1.00'; |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
4
|
|
24
|
use constant BLKSIZE => 8; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
3224
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Stolen from Crypt::DES. |
25
|
|
|
|
|
|
|
sub usage { |
26
|
0
|
|
|
0
|
0
|
0
|
my ($package, $filename, $line, $subr) = caller (1); |
27
|
0
|
|
|
|
|
0
|
$Carp::CarpLevel = 2; |
28
|
0
|
|
|
|
|
0
|
croak "Usage: $subr (@_)"; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub blocksize () { BLKSIZE }; |
32
|
|
|
|
|
|
|
sub keysize () { BLKSIZE }; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub expand_key ($); |
35
|
|
|
|
|
|
|
sub crypt ($$$); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
38
|
5343
|
50
|
|
5343
|
0
|
97041
|
usage ("new Crypt::DES_PP key") |
39
|
|
|
|
|
|
|
unless @_ == 2; |
40
|
5343
|
|
|
|
|
8637
|
my ($package, $key) = @_; |
41
|
|
|
|
|
|
|
|
42
|
5343
|
|
|
|
|
29999
|
bless { ks => Crypt::DES_PP::expand_key ($key) }, $package; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub encrypt { |
46
|
10171
|
50
|
|
10171
|
0
|
105451
|
usage ("encrypt data[8 bytes]") unless @_ == 2; |
47
|
|
|
|
|
|
|
|
48
|
10171
|
|
|
|
|
16151
|
my ($self,$data) = @_; |
49
|
10171
|
|
|
|
|
26250
|
return Crypt::DES_PP::crypt ($data, $self->{ks}, 1); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub decrypt { |
53
|
10171
|
50
|
|
10171
|
0
|
52610
|
usage("decrypt data[8 bytes]") unless @_ == 2; |
54
|
|
|
|
|
|
|
|
55
|
10171
|
|
|
|
|
19888
|
my ($self,$data) = @_; |
56
|
10171
|
|
|
|
|
35007
|
return Crypt::DES_PP::crypt ($data, $self->{ks}, 0); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
4
|
|
|
4
|
|
29
|
use constant ITERATIONS => 16; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
388
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# These used to be a single reference to an array of array references. |
62
|
|
|
|
|
|
|
# Splitting them up into distinct constants slightly improves performance. |
63
|
4
|
|
|
|
|
1631
|
use constant des_SPtrans_0 => |
64
|
|
|
|
|
|
|
[ # Nibble 0 |
65
|
|
|
|
|
|
|
0x00820200, 0x00020000, 0x80800000, 0x80820200, |
66
|
|
|
|
|
|
|
0x00800000, 0x80020200, 0x80020000, 0x80800000, |
67
|
|
|
|
|
|
|
0x80020200, 0x00820200, 0x00820000, 0x80000200, |
68
|
|
|
|
|
|
|
0x80800200, 0x00800000, 0x00000000, 0x80020000, |
69
|
|
|
|
|
|
|
0x00020000, 0x80000000, 0x00800200, 0x00020200, |
70
|
|
|
|
|
|
|
0x80820200, 0x00820000, 0x80000200, 0x00800200, |
71
|
|
|
|
|
|
|
0x80000000, 0x00000200, 0x00020200, 0x80820000, |
72
|
|
|
|
|
|
|
0x00000200, 0x80800200, 0x80820000, 0x00000000, |
73
|
|
|
|
|
|
|
0x00000000, 0x80820200, 0x00800200, 0x80020000, |
74
|
|
|
|
|
|
|
0x00820200, 0x00020000, 0x80000200, 0x00800200, |
75
|
|
|
|
|
|
|
0x80820000, 0x00000200, 0x00020200, 0x80800000, |
76
|
|
|
|
|
|
|
0x80020200, 0x80000000, 0x80800000, 0x00820000, |
77
|
|
|
|
|
|
|
0x80820200, 0x00020200, 0x00820000, 0x80800200, |
78
|
|
|
|
|
|
|
0x00800000, 0x80000200, 0x80020000, 0x00000000, |
79
|
|
|
|
|
|
|
0x00020000, 0x00800000, 0x80800200, 0x00820200, |
80
|
|
|
|
|
|
|
0x80000000, 0x80820000, 0x00000200, 0x80020200, |
81
|
4
|
|
|
4
|
|
20
|
]; |
|
4
|
|
|
|
|
8
|
|
82
|
4
|
|
|
|
|
459
|
use constant des_SPtrans_1 => |
83
|
|
|
|
|
|
|
[ # Nibble 1 |
84
|
|
|
|
|
|
|
0x10042004, 0x00000000, 0x00042000, 0x10040000, |
85
|
|
|
|
|
|
|
0x10000004, 0x00002004, 0x10002000, 0x00042000, |
86
|
|
|
|
|
|
|
0x00002000, 0x10040004, 0x00000004, 0x10002000, |
87
|
|
|
|
|
|
|
0x00040004, 0x10042000, 0x10040000, 0x00000004, |
88
|
|
|
|
|
|
|
0x00040000, 0x10002004, 0x10040004, 0x00002000, |
89
|
|
|
|
|
|
|
0x00042004, 0x10000000, 0x00000000, 0x00040004, |
90
|
|
|
|
|
|
|
0x10002004, 0x00042004, 0x10042000, 0x10000004, |
91
|
|
|
|
|
|
|
0x10000000, 0x00040000, 0x00002004, 0x10042004, |
92
|
|
|
|
|
|
|
0x00040004, 0x10042000, 0x10002000, 0x00042004, |
93
|
|
|
|
|
|
|
0x10042004, 0x00040004, 0x10000004, 0x00000000, |
94
|
|
|
|
|
|
|
0x10000000, 0x00002004, 0x00040000, 0x10040004, |
95
|
|
|
|
|
|
|
0x00002000, 0x10000000, 0x00042004, 0x10002004, |
96
|
|
|
|
|
|
|
0x10042000, 0x00002000, 0x00000000, 0x10000004, |
97
|
|
|
|
|
|
|
0x00000004, 0x10042004, 0x00042000, 0x10040000, |
98
|
|
|
|
|
|
|
0x10040004, 0x00040000, 0x00002004, 0x10002000, |
99
|
|
|
|
|
|
|
0x10002004, 0x00000004, 0x10040000, 0x00042000, |
100
|
4
|
|
|
4
|
|
30
|
]; |
|
4
|
|
|
|
|
8
|
|
101
|
4
|
|
|
|
|
435
|
use constant des_SPtrans_2 => |
102
|
|
|
|
|
|
|
[ # Nibble 2 |
103
|
|
|
|
|
|
|
0x41000000, 0x01010040, 0x00000040, 0x41000040, |
104
|
|
|
|
|
|
|
0x40010000, 0x01000000, 0x41000040, 0x00010040, |
105
|
|
|
|
|
|
|
0x01000040, 0x00010000, 0x01010000, 0x40000000, |
106
|
|
|
|
|
|
|
0x41010040, 0x40000040, 0x40000000, 0x41010000, |
107
|
|
|
|
|
|
|
0x00000000, 0x40010000, 0x01010040, 0x00000040, |
108
|
|
|
|
|
|
|
0x40000040, 0x41010040, 0x00010000, 0x41000000, |
109
|
|
|
|
|
|
|
0x41010000, 0x01000040, 0x40010040, 0x01010000, |
110
|
|
|
|
|
|
|
0x00010040, 0x00000000, 0x01000000, 0x40010040, |
111
|
|
|
|
|
|
|
0x01010040, 0x00000040, 0x40000000, 0x00010000, |
112
|
|
|
|
|
|
|
0x40000040, 0x40010000, 0x01010000, 0x41000040, |
113
|
|
|
|
|
|
|
0x00000000, 0x01010040, 0x00010040, 0x41010000, |
114
|
|
|
|
|
|
|
0x40010000, 0x01000000, 0x41010040, 0x40000000, |
115
|
|
|
|
|
|
|
0x40010040, 0x41000000, 0x01000000, 0x41010040, |
116
|
|
|
|
|
|
|
0x00010000, 0x01000040, 0x41000040, 0x00010040, |
117
|
|
|
|
|
|
|
0x01000040, 0x00000000, 0x41010000, 0x40000040, |
118
|
|
|
|
|
|
|
0x41000000, 0x40010040, 0x00000040, 0x01010000, |
119
|
4
|
|
|
4
|
|
20
|
]; |
|
4
|
|
|
|
|
6
|
|
120
|
4
|
|
|
|
|
534
|
use constant des_SPtrans_3 => |
121
|
|
|
|
|
|
|
[ # Nibble 3 |
122
|
|
|
|
|
|
|
0x00100402, 0x04000400, 0x00000002, 0x04100402, |
123
|
|
|
|
|
|
|
0x00000000, 0x04100000, 0x04000402, 0x00100002, |
124
|
|
|
|
|
|
|
0x04100400, 0x04000002, 0x04000000, 0x00000402, |
125
|
|
|
|
|
|
|
0x04000002, 0x00100402, 0x00100000, 0x04000000, |
126
|
|
|
|
|
|
|
0x04100002, 0x00100400, 0x00000400, 0x00000002, |
127
|
|
|
|
|
|
|
0x00100400, 0x04000402, 0x04100000, 0x00000400, |
128
|
|
|
|
|
|
|
0x00000402, 0x00000000, 0x00100002, 0x04100400, |
129
|
|
|
|
|
|
|
0x04000400, 0x04100002, 0x04100402, 0x00100000, |
130
|
|
|
|
|
|
|
0x04100002, 0x00000402, 0x00100000, 0x04000002, |
131
|
|
|
|
|
|
|
0x00100400, 0x04000400, 0x00000002, 0x04100000, |
132
|
|
|
|
|
|
|
0x04000402, 0x00000000, 0x00000400, 0x00100002, |
133
|
|
|
|
|
|
|
0x00000000, 0x04100002, 0x04100400, 0x00000400, |
134
|
|
|
|
|
|
|
0x04000000, 0x04100402, 0x00100402, 0x00100000, |
135
|
|
|
|
|
|
|
0x04100402, 0x00000002, 0x04000400, 0x00100402, |
136
|
|
|
|
|
|
|
0x00100002, 0x00100400, 0x04100000, 0x04000402, |
137
|
|
|
|
|
|
|
0x00000402, 0x04000000, 0x04000002, 0x04100400, |
138
|
4
|
|
|
4
|
|
57
|
]; |
|
4
|
|
|
|
|
7
|
|
139
|
4
|
|
|
|
|
386
|
use constant des_SPtrans_4 => |
140
|
|
|
|
|
|
|
[ # Nibble 4 |
141
|
|
|
|
|
|
|
0x02000000, 0x00004000, 0x00000100, 0x02004108, |
142
|
|
|
|
|
|
|
0x02004008, 0x02000100, 0x00004108, 0x02004000, |
143
|
|
|
|
|
|
|
0x00004000, 0x00000008, 0x02000008, 0x00004100, |
144
|
|
|
|
|
|
|
0x02000108, 0x02004008, 0x02004100, 0x00000000, |
145
|
|
|
|
|
|
|
0x00004100, 0x02000000, 0x00004008, 0x00000108, |
146
|
|
|
|
|
|
|
0x02000100, 0x00004108, 0x00000000, 0x02000008, |
147
|
|
|
|
|
|
|
0x00000008, 0x02000108, 0x02004108, 0x00004008, |
148
|
|
|
|
|
|
|
0x02004000, 0x00000100, 0x00000108, 0x02004100, |
149
|
|
|
|
|
|
|
0x02004100, 0x02000108, 0x00004008, 0x02004000, |
150
|
|
|
|
|
|
|
0x00004000, 0x00000008, 0x02000008, 0x02000100, |
151
|
|
|
|
|
|
|
0x02000000, 0x00004100, 0x02004108, 0x00000000, |
152
|
|
|
|
|
|
|
0x00004108, 0x02000000, 0x00000100, 0x00004008, |
153
|
|
|
|
|
|
|
0x02000108, 0x00000100, 0x00000000, 0x02004108, |
154
|
|
|
|
|
|
|
0x02004008, 0x02004100, 0x00000108, 0x00004000, |
155
|
|
|
|
|
|
|
0x00004100, 0x02004008, 0x02000100, 0x00000108, |
156
|
|
|
|
|
|
|
0x00000008, 0x00004108, 0x02004000, 0x02000008, |
157
|
4
|
|
|
4
|
|
20
|
]; |
|
4
|
|
|
|
|
7
|
|
158
|
4
|
|
|
|
|
364
|
use constant des_SPtrans_5 => |
159
|
|
|
|
|
|
|
[ # Nibble 5 |
160
|
|
|
|
|
|
|
0x20000010, 0x00080010, 0x00000000, 0x20080800, |
161
|
|
|
|
|
|
|
0x00080010, 0x00000800, 0x20000810, 0x00080000, |
162
|
|
|
|
|
|
|
0x00000810, 0x20080810, 0x00080800, 0x20000000, |
163
|
|
|
|
|
|
|
0x20000800, 0x20000010, 0x20080000, 0x00080810, |
164
|
|
|
|
|
|
|
0x00080000, 0x20000810, 0x20080010, 0x00000000, |
165
|
|
|
|
|
|
|
0x00000800, 0x00000010, 0x20080800, 0x20080010, |
166
|
|
|
|
|
|
|
0x20080810, 0x20080000, 0x20000000, 0x00000810, |
167
|
|
|
|
|
|
|
0x00000010, 0x00080800, 0x00080810, 0x20000800, |
168
|
|
|
|
|
|
|
0x00000810, 0x20000000, 0x20000800, 0x00080810, |
169
|
|
|
|
|
|
|
0x20080800, 0x00080010, 0x00000000, 0x20000800, |
170
|
|
|
|
|
|
|
0x20000000, 0x00000800, 0x20080010, 0x00080000, |
171
|
|
|
|
|
|
|
0x00080010, 0x20080810, 0x00080800, 0x00000010, |
172
|
|
|
|
|
|
|
0x20080810, 0x00080800, 0x00080000, 0x20000810, |
173
|
|
|
|
|
|
|
0x20000010, 0x20080000, 0x00080810, 0x00000000, |
174
|
|
|
|
|
|
|
0x00000800, 0x20000010, 0x20000810, 0x20080800, |
175
|
|
|
|
|
|
|
0x20080000, 0x00000810, 0x00000010, 0x20080010, |
176
|
4
|
|
|
4
|
|
17
|
]; |
|
4
|
|
|
|
|
7
|
|
177
|
4
|
|
|
|
|
1094
|
use constant des_SPtrans_6 => |
178
|
|
|
|
|
|
|
[ # Nibble 6 |
179
|
|
|
|
|
|
|
0x00001000, 0x00000080, 0x00400080, 0x00400001, |
180
|
|
|
|
|
|
|
0x00401081, 0x00001001, 0x00001080, 0x00000000, |
181
|
|
|
|
|
|
|
0x00400000, 0x00400081, 0x00000081, 0x00401000, |
182
|
|
|
|
|
|
|
0x00000001, 0x00401080, 0x00401000, 0x00000081, |
183
|
|
|
|
|
|
|
0x00400081, 0x00001000, 0x00001001, 0x00401081, |
184
|
|
|
|
|
|
|
0x00000000, 0x00400080, 0x00400001, 0x00001080, |
185
|
|
|
|
|
|
|
0x00401001, 0x00001081, 0x00401080, 0x00000001, |
186
|
|
|
|
|
|
|
0x00001081, 0x00401001, 0x00000080, 0x00400000, |
187
|
|
|
|
|
|
|
0x00001081, 0x00401000, 0x00401001, 0x00000081, |
188
|
|
|
|
|
|
|
0x00001000, 0x00000080, 0x00400000, 0x00401001, |
189
|
|
|
|
|
|
|
0x00400081, 0x00001081, 0x00001080, 0x00000000, |
190
|
|
|
|
|
|
|
0x00000080, 0x00400001, 0x00000001, 0x00400080, |
191
|
|
|
|
|
|
|
0x00000000, 0x00400081, 0x00400080, 0x00001080, |
192
|
|
|
|
|
|
|
0x00000081, 0x00001000, 0x00401081, 0x00400000, |
193
|
|
|
|
|
|
|
0x00401080, 0x00000001, 0x00001001, 0x00401081, |
194
|
|
|
|
|
|
|
0x00400001, 0x00401080, 0x00401000, 0x00001001, |
195
|
4
|
|
|
4
|
|
19
|
]; |
|
4
|
|
|
|
|
6
|
|
196
|
4
|
|
|
|
|
401
|
use constant des_SPtrans_7 => |
197
|
|
|
|
|
|
|
[ # Nibble 7 |
198
|
|
|
|
|
|
|
0x08200020, 0x08208000, 0x00008020, 0x00000000, |
199
|
|
|
|
|
|
|
0x08008000, 0x00200020, 0x08200000, 0x08208020, |
200
|
|
|
|
|
|
|
0x00000020, 0x08000000, 0x00208000, 0x00008020, |
201
|
|
|
|
|
|
|
0x00208020, 0x08008020, 0x08000020, 0x08200000, |
202
|
|
|
|
|
|
|
0x00008000, 0x00208020, 0x00200020, 0x08008000, |
203
|
|
|
|
|
|
|
0x08208020, 0x08000020, 0x00000000, 0x00208000, |
204
|
|
|
|
|
|
|
0x08000000, 0x00200000, 0x08008020, 0x08200020, |
205
|
|
|
|
|
|
|
0x00200000, 0x00008000, 0x08208000, 0x00000020, |
206
|
|
|
|
|
|
|
0x00200000, 0x00008000, 0x08000020, 0x08208020, |
207
|
|
|
|
|
|
|
0x00008020, 0x08000000, 0x00000000, 0x00208000, |
208
|
|
|
|
|
|
|
0x08200020, 0x08008020, 0x08008000, 0x00200020, |
209
|
|
|
|
|
|
|
0x08208000, 0x00000020, 0x00200020, 0x08008000, |
210
|
|
|
|
|
|
|
0x08208020, 0x00200000, 0x08200000, 0x08000020, |
211
|
|
|
|
|
|
|
0x00208000, 0x00008020, 0x08008020, 0x08200000, |
212
|
|
|
|
|
|
|
0x00000020, 0x08208000, 0x00208020, 0x00000000, |
213
|
|
|
|
|
|
|
0x08000000, 0x08200020, 0x00008000, 0x00208020, |
214
|
4
|
|
|
4
|
|
23
|
]; |
|
4
|
|
|
|
|
7
|
|
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
# These have also been split up. |
217
|
4
|
|
|
|
|
386
|
use constant des_skb_0 => |
218
|
|
|
|
|
|
|
[ # For C bits (numbered as per FIPS 46) 1 2 3 4 5 6. |
219
|
|
|
|
|
|
|
0x00000000, 0x00000010, 0x20000000, 0x20000010, |
220
|
|
|
|
|
|
|
0x00010000, 0x00010010, 0x20010000, 0x20010010, |
221
|
|
|
|
|
|
|
0x00000800, 0x00000810, 0x20000800, 0x20000810, |
222
|
|
|
|
|
|
|
0x00010800, 0x00010810, 0x20010800, 0x20010810, |
223
|
|
|
|
|
|
|
0x00000020, 0x00000030, 0x20000020, 0x20000030, |
224
|
|
|
|
|
|
|
0x00010020, 0x00010030, 0x20010020, 0x20010030, |
225
|
|
|
|
|
|
|
0x00000820, 0x00000830, 0x20000820, 0x20000830, |
226
|
|
|
|
|
|
|
0x00010820, 0x00010830, 0x20010820, 0x20010830, |
227
|
|
|
|
|
|
|
0x00080000, 0x00080010, 0x20080000, 0x20080010, |
228
|
|
|
|
|
|
|
0x00090000, 0x00090010, 0x20090000, 0x20090010, |
229
|
|
|
|
|
|
|
0x00080800, 0x00080810, 0x20080800, 0x20080810, |
230
|
|
|
|
|
|
|
0x00090800, 0x00090810, 0x20090800, 0x20090810, |
231
|
|
|
|
|
|
|
0x00080020, 0x00080030, 0x20080020, 0x20080030, |
232
|
|
|
|
|
|
|
0x00090020, 0x00090030, 0x20090020, 0x20090030, |
233
|
|
|
|
|
|
|
0x00080820, 0x00080830, 0x20080820, 0x20080830, |
234
|
|
|
|
|
|
|
0x00090820, 0x00090830, 0x20090820, 0x20090830, |
235
|
4
|
|
|
4
|
|
17
|
]; |
|
4
|
|
|
|
|
7
|
|
236
|
4
|
|
|
|
|
978
|
use constant des_skb_1 => |
237
|
|
|
|
|
|
|
[ # For C bits (numbered as per FIPS 46) 7 8 10 11 12 13 |
238
|
|
|
|
|
|
|
0x00000000, 0x02000000, 0x00002000, 0x02002000, |
239
|
|
|
|
|
|
|
0x00200000, 0x02200000, 0x00202000, 0x02202000, |
240
|
|
|
|
|
|
|
0x00000004, 0x02000004, 0x00002004, 0x02002004, |
241
|
|
|
|
|
|
|
0x00200004, 0x02200004, 0x00202004, 0x02202004, |
242
|
|
|
|
|
|
|
0x00000400, 0x02000400, 0x00002400, 0x02002400, |
243
|
|
|
|
|
|
|
0x00200400, 0x02200400, 0x00202400, 0x02202400, |
244
|
|
|
|
|
|
|
0x00000404, 0x02000404, 0x00002404, 0x02002404, |
245
|
|
|
|
|
|
|
0x00200404, 0x02200404, 0x00202404, 0x02202404, |
246
|
|
|
|
|
|
|
0x10000000, 0x12000000, 0x10002000, 0x12002000, |
247
|
|
|
|
|
|
|
0x10200000, 0x12200000, 0x10202000, 0x12202000, |
248
|
|
|
|
|
|
|
0x10000004, 0x12000004, 0x10002004, 0x12002004, |
249
|
|
|
|
|
|
|
0x10200004, 0x12200004, 0x10202004, 0x12202004, |
250
|
|
|
|
|
|
|
0x10000400, 0x12000400, 0x10002400, 0x12002400, |
251
|
|
|
|
|
|
|
0x10200400, 0x12200400, 0x10202400, 0x12202400, |
252
|
|
|
|
|
|
|
0x10000404, 0x12000404, 0x10002404, 0x12002404, |
253
|
|
|
|
|
|
|
0x10200404, 0x12200404, 0x10202404, 0x12202404, |
254
|
4
|
|
|
4
|
|
18
|
]; |
|
4
|
|
|
|
|
8
|
|
255
|
4
|
|
|
|
|
370
|
use constant des_skb_2 => |
256
|
|
|
|
|
|
|
[ # For C bits (numbered as per FIPS 46) 14 15 16 17 19 20 |
257
|
|
|
|
|
|
|
0x00000000, 0x00000001, 0x00040000, 0x00040001, |
258
|
|
|
|
|
|
|
0x01000000, 0x01000001, 0x01040000, 0x01040001, |
259
|
|
|
|
|
|
|
0x00000002, 0x00000003, 0x00040002, 0x00040003, |
260
|
|
|
|
|
|
|
0x01000002, 0x01000003, 0x01040002, 0x01040003, |
261
|
|
|
|
|
|
|
0x00000200, 0x00000201, 0x00040200, 0x00040201, |
262
|
|
|
|
|
|
|
0x01000200, 0x01000201, 0x01040200, 0x01040201, |
263
|
|
|
|
|
|
|
0x00000202, 0x00000203, 0x00040202, 0x00040203, |
264
|
|
|
|
|
|
|
0x01000202, 0x01000203, 0x01040202, 0x01040203, |
265
|
|
|
|
|
|
|
0x08000000, 0x08000001, 0x08040000, 0x08040001, |
266
|
|
|
|
|
|
|
0x09000000, 0x09000001, 0x09040000, 0x09040001, |
267
|
|
|
|
|
|
|
0x08000002, 0x08000003, 0x08040002, 0x08040003, |
268
|
|
|
|
|
|
|
0x09000002, 0x09000003, 0x09040002, 0x09040003, |
269
|
|
|
|
|
|
|
0x08000200, 0x08000201, 0x08040200, 0x08040201, |
270
|
|
|
|
|
|
|
0x09000200, 0x09000201, 0x09040200, 0x09040201, |
271
|
|
|
|
|
|
|
0x08000202, 0x08000203, 0x08040202, 0x08040203, |
272
|
|
|
|
|
|
|
0x09000202, 0x09000203, 0x09040202, 0x09040203, |
273
|
4
|
|
|
4
|
|
23
|
]; |
|
4
|
|
|
|
|
6
|
|
274
|
4
|
|
|
|
|
433
|
use constant des_skb_3 => |
275
|
|
|
|
|
|
|
[ # For C bits (numbered as per FIPS 46) 21 23 24 26 27 28 |
276
|
|
|
|
|
|
|
0x00000000, 0x00100000, 0x00000100, 0x00100100, |
277
|
|
|
|
|
|
|
0x00000008, 0x00100008, 0x00000108, 0x00100108, |
278
|
|
|
|
|
|
|
0x00001000, 0x00101000, 0x00001100, 0x00101100, |
279
|
|
|
|
|
|
|
0x00001008, 0x00101008, 0x00001108, 0x00101108, |
280
|
|
|
|
|
|
|
0x04000000, 0x04100000, 0x04000100, 0x04100100, |
281
|
|
|
|
|
|
|
0x04000008, 0x04100008, 0x04000108, 0x04100108, |
282
|
|
|
|
|
|
|
0x04001000, 0x04101000, 0x04001100, 0x04101100, |
283
|
|
|
|
|
|
|
0x04001008, 0x04101008, 0x04001108, 0x04101108, |
284
|
|
|
|
|
|
|
0x00020000, 0x00120000, 0x00020100, 0x00120100, |
285
|
|
|
|
|
|
|
0x00020008, 0x00120008, 0x00020108, 0x00120108, |
286
|
|
|
|
|
|
|
0x00021000, 0x00121000, 0x00021100, 0x00121100, |
287
|
|
|
|
|
|
|
0x00021008, 0x00121008, 0x00021108, 0x00121108, |
288
|
|
|
|
|
|
|
0x04020000, 0x04120000, 0x04020100, 0x04120100, |
289
|
|
|
|
|
|
|
0x04020008, 0x04120008, 0x04020108, 0x04120108, |
290
|
|
|
|
|
|
|
0x04021000, 0x04121000, 0x04021100, 0x04121100, |
291
|
|
|
|
|
|
|
0x04021008, 0x04121008, 0x04021108, 0x04121108, |
292
|
4
|
|
|
4
|
|
20
|
]; |
|
4
|
|
|
|
|
5
|
|
293
|
4
|
|
|
|
|
338
|
use constant des_skb_4 => |
294
|
|
|
|
|
|
|
[ # For D bits (numbered as per FIPS 46) 1 2 3 4 5 6 |
295
|
|
|
|
|
|
|
0x00000000, 0x10000000, 0x00010000, 0x10010000, |
296
|
|
|
|
|
|
|
0x00000004, 0x10000004, 0x00010004, 0x10010004, |
297
|
|
|
|
|
|
|
0x20000000, 0x30000000, 0x20010000, 0x30010000, |
298
|
|
|
|
|
|
|
0x20000004, 0x30000004, 0x20010004, 0x30010004, |
299
|
|
|
|
|
|
|
0x00100000, 0x10100000, 0x00110000, 0x10110000, |
300
|
|
|
|
|
|
|
0x00100004, 0x10100004, 0x00110004, 0x10110004, |
301
|
|
|
|
|
|
|
0x20100000, 0x30100000, 0x20110000, 0x30110000, |
302
|
|
|
|
|
|
|
0x20100004, 0x30100004, 0x20110004, 0x30110004, |
303
|
|
|
|
|
|
|
0x00001000, 0x10001000, 0x00011000, 0x10011000, |
304
|
|
|
|
|
|
|
0x00001004, 0x10001004, 0x00011004, 0x10011004, |
305
|
|
|
|
|
|
|
0x20001000, 0x30001000, 0x20011000, 0x30011000, |
306
|
|
|
|
|
|
|
0x20001004, 0x30001004, 0x20011004, 0x30011004, |
307
|
|
|
|
|
|
|
0x00101000, 0x10101000, 0x00111000, 0x10111000, |
308
|
|
|
|
|
|
|
0x00101004, 0x10101004, 0x00111004, 0x10111004, |
309
|
|
|
|
|
|
|
0x20101000, 0x30101000, 0x20111000, 0x30111000, |
310
|
|
|
|
|
|
|
0x20101004, 0x30101004, 0x20111004, 0x30111004, |
311
|
4
|
|
|
4
|
|
21
|
]; |
|
4
|
|
|
|
|
6
|
|
312
|
4
|
|
|
|
|
404
|
use constant des_skb_5 => |
313
|
|
|
|
|
|
|
[ # For D bits (numbered as per FIPS 46) 8 9 11 12 13 14 |
314
|
|
|
|
|
|
|
0x00000000, 0x08000000, 0x00000008, 0x08000008, |
315
|
|
|
|
|
|
|
0x00000400, 0x08000400, 0x00000408, 0x08000408, |
316
|
|
|
|
|
|
|
0x00020000, 0x08020000, 0x00020008, 0x08020008, |
317
|
|
|
|
|
|
|
0x00020400, 0x08020400, 0x00020408, 0x08020408, |
318
|
|
|
|
|
|
|
0x00000001, 0x08000001, 0x00000009, 0x08000009, |
319
|
|
|
|
|
|
|
0x00000401, 0x08000401, 0x00000409, 0x08000409, |
320
|
|
|
|
|
|
|
0x00020001, 0x08020001, 0x00020009, 0x08020009, |
321
|
|
|
|
|
|
|
0x00020401, 0x08020401, 0x00020409, 0x08020409, |
322
|
|
|
|
|
|
|
0x02000000, 0x0A000000, 0x02000008, 0x0A000008, |
323
|
|
|
|
|
|
|
0x02000400, 0x0A000400, 0x02000408, 0x0A000408, |
324
|
|
|
|
|
|
|
0x02020000, 0x0A020000, 0x02020008, 0x0A020008, |
325
|
|
|
|
|
|
|
0x02020400, 0x0A020400, 0x02020408, 0x0A020408, |
326
|
|
|
|
|
|
|
0x02000001, 0x0A000001, 0x02000009, 0x0A000009, |
327
|
|
|
|
|
|
|
0x02000401, 0x0A000401, 0x02000409, 0x0A000409, |
328
|
|
|
|
|
|
|
0x02020001, 0x0A020001, 0x02020009, 0x0A020009, |
329
|
|
|
|
|
|
|
0x02020401, 0x0A020401, 0x02020409, 0x0A020409, |
330
|
4
|
|
|
4
|
|
19
|
]; |
|
4
|
|
|
|
|
7
|
|
331
|
4
|
|
|
|
|
550
|
use constant des_skb_6 => |
332
|
|
|
|
|
|
|
[ # For D bits (numbered as per FIPS 46) 16 17 18 19 20 21 |
333
|
|
|
|
|
|
|
0x00000000, 0x00000100, 0x00080000, 0x00080100, |
334
|
|
|
|
|
|
|
0x01000000, 0x01000100, 0x01080000, 0x01080100, |
335
|
|
|
|
|
|
|
0x00000010, 0x00000110, 0x00080010, 0x00080110, |
336
|
|
|
|
|
|
|
0x01000010, 0x01000110, 0x01080010, 0x01080110, |
337
|
|
|
|
|
|
|
0x00200000, 0x00200100, 0x00280000, 0x00280100, |
338
|
|
|
|
|
|
|
0x01200000, 0x01200100, 0x01280000, 0x01280100, |
339
|
|
|
|
|
|
|
0x00200010, 0x00200110, 0x00280010, 0x00280110, |
340
|
|
|
|
|
|
|
0x01200010, 0x01200110, 0x01280010, 0x01280110, |
341
|
|
|
|
|
|
|
0x00000200, 0x00000300, 0x00080200, 0x00080300, |
342
|
|
|
|
|
|
|
0x01000200, 0x01000300, 0x01080200, 0x01080300, |
343
|
|
|
|
|
|
|
0x00000210, 0x00000310, 0x00080210, 0x00080310, |
344
|
|
|
|
|
|
|
0x01000210, 0x01000310, 0x01080210, 0x01080310, |
345
|
|
|
|
|
|
|
0x00200200, 0x00200300, 0x00280200, 0x00280300, |
346
|
|
|
|
|
|
|
0x01200200, 0x01200300, 0x01280200, 0x01280300, |
347
|
|
|
|
|
|
|
0x00200210, 0x00200310, 0x00280210, 0x00280310, |
348
|
|
|
|
|
|
|
0x01200210, 0x01200310, 0x01280210, 0x01280310, |
349
|
4
|
|
|
4
|
|
19
|
]; |
|
4
|
|
|
|
|
7
|
|
350
|
4
|
|
|
|
|
863
|
use constant des_skb_7 => |
351
|
|
|
|
|
|
|
[ # For D bits (numbered as per FIPS 46) 22 23 24 25 27 28 |
352
|
|
|
|
|
|
|
0x00000000, 0x04000000, 0x00040000, 0x04040000, |
353
|
|
|
|
|
|
|
0x00000002, 0x04000002, 0x00040002, 0x04040002, |
354
|
|
|
|
|
|
|
0x00002000, 0x04002000, 0x00042000, 0x04042000, |
355
|
|
|
|
|
|
|
0x00002002, 0x04002002, 0x00042002, 0x04042002, |
356
|
|
|
|
|
|
|
0x00000020, 0x04000020, 0x00040020, 0x04040020, |
357
|
|
|
|
|
|
|
0x00000022, 0x04000022, 0x00040022, 0x04040022, |
358
|
|
|
|
|
|
|
0x00002020, 0x04002020, 0x00042020, 0x04042020, |
359
|
|
|
|
|
|
|
0x00002022, 0x04002022, 0x00042022, 0x04042022, |
360
|
|
|
|
|
|
|
0x00000800, 0x04000800, 0x00040800, 0x04040800, |
361
|
|
|
|
|
|
|
0x00000802, 0x04000802, 0x00040802, 0x04040802, |
362
|
|
|
|
|
|
|
0x00002800, 0x04002800, 0x00042800, 0x04042800, |
363
|
|
|
|
|
|
|
0x00002802, 0x04002802, 0x00042802, 0x04042802, |
364
|
|
|
|
|
|
|
0x00000820, 0x04000820, 0x00040820, 0x04040820, |
365
|
|
|
|
|
|
|
0x00000822, 0x04000822, 0x00040822, 0x04040822, |
366
|
|
|
|
|
|
|
0x00002820, 0x04002820, 0x00042820, 0x04042820, |
367
|
|
|
|
|
|
|
0x00002822, 0x04002822, 0x00042822, 0x04042822, |
368
|
4
|
|
|
4
|
|
18
|
]; |
|
4
|
|
|
|
|
8
|
|
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
sub expand_key ($) { |
378
|
5343
|
|
|
5343
|
0
|
18116
|
my ($c, $d) = unpack "VV", shift; |
379
|
|
|
|
|
|
|
|
380
|
5343
|
50
|
|
|
|
12904
|
usage ("at least 8 byte key") unless defined $d; |
381
|
5343
|
|
|
|
|
8253
|
my @k = (); |
382
|
|
|
|
|
|
|
|
383
|
5343
|
|
|
|
|
5663
|
my ($t, $s); |
384
|
5343
|
|
|
|
|
19018
|
$t = (($d >> 4) ^ $c) & 0x0f0f0f0f; |
385
|
5343
|
|
|
|
|
6518
|
$c ^= $t; |
386
|
5343
|
|
|
|
|
7222
|
$d ^= $t << 4; |
387
|
5343
|
|
|
|
|
7079
|
$t = (($c << 18) ^ $c) & 0xcccc0000; |
388
|
5343
|
|
|
|
|
8444
|
$c = $c ^ $t ^ (($t >> 18) & 0x00003fff); |
389
|
5343
|
|
|
|
|
6222
|
$t = (($d << 18) ^ $d) & 0xcccc0000; |
390
|
5343
|
|
|
|
|
7355
|
$d = $d ^ $t ^ (($t >> 18) & 0x00003fff); |
391
|
5343
|
|
|
|
|
11323
|
$t = (($d >> 1) ^ $c) & 0x55555555; |
392
|
5343
|
|
|
|
|
6576
|
$c ^= $t; |
393
|
5343
|
|
|
|
|
6290
|
$d ^= $t << 1; |
394
|
5343
|
|
|
|
|
9792
|
$t = (($c >> 8) ^ $d) & 0x00ff00ff; |
395
|
5343
|
|
|
|
|
5146
|
$d ^= $t; |
396
|
5343
|
|
|
|
|
19013
|
$c ^= $t << 8; |
397
|
5343
|
|
|
|
|
9386
|
$t = (($d >> 1) ^ $c) & 0x55555555; |
398
|
5343
|
|
|
|
|
5342
|
$c ^= $t; |
399
|
5343
|
|
|
|
|
6071
|
$d ^= $t << 1; |
400
|
5343
|
|
|
|
|
9289
|
$d = ((($d & 0x000000ff) << 16) | ($d & 0x0000ff00) | |
401
|
|
|
|
|
|
|
(($d >> 16) & 0x000000ff) | (($c >> 4) & 0x0f000000)); |
402
|
5343
|
|
|
|
|
6157
|
$c &= 0x0fffffff; |
403
|
|
|
|
|
|
|
|
404
|
4
|
|
|
|
|
6131
|
use constant shifts2 => [0, 0, 1, 1, 1, 1, 1, 1, |
405
|
4
|
|
|
4
|
|
22
|
0, 1, 1, 1, 1, 1, 1, 0]; |
|
4
|
|
|
|
|
8
|
|
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
# Do not try to unroll any of the loops (not this one and not the |
408
|
|
|
|
|
|
|
# one in crypt(). It will make things slower (about 30 %!). |
409
|
5343
|
|
|
|
|
9909
|
foreach my $i (0 .. ITERATIONS - 1) { |
410
|
|
|
|
|
|
|
# No need to mask out the sign here because only the |
411
|
|
|
|
|
|
|
# lower 28 bits are used. |
412
|
85488
|
100
|
|
|
|
174068
|
if (shifts2->[$i]) { |
413
|
64116
|
|
|
|
|
101870
|
$c = (($c >> 2) | ($c << 26)); |
414
|
64116
|
|
|
|
|
88673
|
$d = (($d >> 2) | ($d << 26)); |
415
|
|
|
|
|
|
|
} else { |
416
|
21372
|
|
|
|
|
30380
|
$c= (($c >> 1) | ($c << 27)); |
417
|
21372
|
|
|
|
|
27972
|
$d= (($d >> 1) | ($d << 27)); |
418
|
|
|
|
|
|
|
} |
419
|
85488
|
|
|
|
|
116153
|
$c &= 0x0fffffff; |
420
|
85488
|
|
|
|
|
96030
|
$d &= 0x0fffffff; |
421
|
|
|
|
|
|
|
|
422
|
85488
|
|
|
|
|
271664
|
$s = (des_skb_0->[($c) & 0x3f] | |
423
|
|
|
|
|
|
|
des_skb_1->[(($c >> 6) & 0x03) | |
424
|
|
|
|
|
|
|
(($c >> 7) & 0x3c)] | |
425
|
|
|
|
|
|
|
des_skb_2->[(($c >> 13) & 0x0f) | |
426
|
|
|
|
|
|
|
(($c >> 14) & 0x30)] | |
427
|
|
|
|
|
|
|
des_skb_3->[(($c >> 20) & 0x01) | |
428
|
|
|
|
|
|
|
(($c >> 21) & 0x06) | |
429
|
|
|
|
|
|
|
(($c >> 22) & 0x38)]); |
430
|
85488
|
|
|
|
|
240565
|
$t = (des_skb_4->[($d) & 0x3f] | |
431
|
|
|
|
|
|
|
des_skb_5->[(($d >> 7) & 0x03) | |
432
|
|
|
|
|
|
|
(($d >> 8) & 0x3c)] | |
433
|
|
|
|
|
|
|
des_skb_6->[ ($d >> 15) & 0x3f] | |
434
|
|
|
|
|
|
|
des_skb_7->[(($d >> 21) & 0x0f) | |
435
|
|
|
|
|
|
|
(($d >> 22) & 0x30)]); |
436
|
|
|
|
|
|
|
|
437
|
85488
|
|
|
|
|
154405
|
$k[$i << 1] = (($t << 16) | ($s & 0x0000ffff)) & 0xffffffff; |
438
|
85488
|
|
|
|
|
115946
|
$s = ((($s >> 16) & 0x0000ffff) | ($t & 0xffff0000)); |
439
|
|
|
|
|
|
|
|
440
|
85488
|
|
|
|
|
139591
|
$s = ($s << 4) | (($s >> 28) & 0x0fffffff); |
441
|
85488
|
|
|
|
|
176618
|
$k[($i << 1) + 1] = $s & 0xffffffff; |
442
|
|
|
|
|
|
|
} |
443
|
5343
|
|
|
|
|
59979
|
pack ("V*", @k); |
444
|
|
|
|
|
|
|
} |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
sub crypt ($$$) { |
448
|
20342
|
|
|
20342
|
0
|
39280
|
my ($input, $ks, $encrypt) = @_; |
449
|
20342
|
|
|
|
|
25111
|
my $output; |
450
|
|
|
|
|
|
|
|
451
|
20342
|
|
|
|
|
22693
|
my ($t, $u); |
452
|
|
|
|
|
|
|
|
453
|
20342
|
|
|
|
|
48168
|
my ($l, $r) = unpack "VV", $input; |
454
|
20342
|
50
|
|
|
|
52114
|
usage ("at least 8 byte key") unless defined $r; |
455
|
|
|
|
|
|
|
|
456
|
20342
|
|
|
|
|
49328
|
$t = (($r >> 4) ^ $l) & 0x0f0f0f0f; |
457
|
20342
|
|
|
|
|
24616
|
$l ^= $t; |
458
|
20342
|
|
|
|
|
33409
|
$r ^= $t << 4; |
459
|
20342
|
|
|
|
|
26086
|
$t = (($l >> 16) ^ $r) & 0x0000ffff; |
460
|
20342
|
|
|
|
|
21678
|
$r ^= $t; |
461
|
20342
|
|
|
|
|
23304
|
$l ^= $t << 16; |
462
|
20342
|
|
|
|
|
27260
|
$t = (($r >> 2) ^ $l) & 0x33333333; |
463
|
20342
|
|
|
|
|
21458
|
$l ^= $t; |
464
|
20342
|
|
|
|
|
23670
|
$r ^= $t << 2; |
465
|
20342
|
|
|
|
|
25348
|
$t = (($l >> 8) ^ $r) & 0x00ff00ff; |
466
|
20342
|
|
|
|
|
28018
|
$r ^= $t; |
467
|
20342
|
|
|
|
|
22976
|
$l ^= $t << 8; |
468
|
20342
|
|
|
|
|
25625
|
$t = (($r >> 1) ^ $l) & 0x55555555; |
469
|
20342
|
|
|
|
|
21780
|
$l ^= $t; |
470
|
20342
|
|
|
|
|
23206
|
$r ^= $t << 1; |
471
|
|
|
|
|
|
|
|
472
|
20342
|
|
|
|
|
29480
|
$t = ($r << 1) | (($r >> 31) & 0x1); |
473
|
20342
|
|
|
|
|
33178
|
$r = ($l << 1) | (($l >> 31) & 0x1); |
474
|
20342
|
|
|
|
|
50823
|
$l = $t; |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
# Clear the top bits on machines with 8byte longs. |
477
|
20342
|
|
|
|
|
21352
|
$l &= 0xffffffff; |
478
|
20342
|
|
|
|
|
22841
|
$r &= 0xffffffff; |
479
|
|
|
|
|
|
|
|
480
|
20342
|
|
|
|
|
122145
|
my @s = unpack ("V32", $ks); |
481
|
20342
|
|
|
|
|
46426
|
my $i; |
482
|
|
|
|
|
|
|
|
483
|
20342
|
100
|
|
|
|
42564
|
if ($encrypt) { |
484
|
10171
|
|
|
|
|
32584
|
for ($i = 0; $i < 32; $i += 4) { |
485
|
81368
|
|
|
|
|
119801
|
$u = ($r ^ $s[($i + 0) ]); |
486
|
81368
|
|
|
|
|
105921
|
$t = $r ^ $s[($i + 0) + 1]; |
487
|
81368
|
|
|
|
|
110502
|
$t = (($t >> 4) & 0x0fffffff) | ($t << 28); |
488
|
81368
|
|
|
|
|
276109
|
$l ^= des_SPtrans_1->[($t ) & 0x3f]| |
489
|
|
|
|
|
|
|
des_SPtrans_3->[($t >> 8) & 0x3f]| |
490
|
|
|
|
|
|
|
des_SPtrans_5->[($t >> 16) & 0x3f]| |
491
|
|
|
|
|
|
|
des_SPtrans_7->[($t >> 24) & 0x3f]| |
492
|
|
|
|
|
|
|
des_SPtrans_0->[($u ) & 0x3f]| |
493
|
|
|
|
|
|
|
des_SPtrans_2->[($u >> 8) & 0x3f]| |
494
|
|
|
|
|
|
|
des_SPtrans_4->[($u >> 16) & 0x3f]| |
495
|
|
|
|
|
|
|
des_SPtrans_6->[($u >> 24) & 0x3f]; |
496
|
81368
|
|
|
|
|
107795
|
$u = ($l ^ $s[($i + 2) ]); |
497
|
81368
|
|
|
|
|
105265
|
$t = $l ^ $s[($i + 2) + 1]; |
498
|
81368
|
|
|
|
|
114565
|
$t = (($t >> 4) & 0x0fffffff) | ($t << 28); |
499
|
81368
|
|
|
|
|
404246
|
$r ^= des_SPtrans_1->[($t ) & 0x3f]| |
500
|
|
|
|
|
|
|
des_SPtrans_3->[($t >> 8) & 0x3f]| |
501
|
|
|
|
|
|
|
des_SPtrans_5->[($t >> 16) & 0x3f]| |
502
|
|
|
|
|
|
|
des_SPtrans_7->[($t >> 24) & 0x3f]| |
503
|
|
|
|
|
|
|
des_SPtrans_0->[($u ) & 0x3f]| |
504
|
|
|
|
|
|
|
des_SPtrans_2->[($u >> 8) & 0x3f]| |
505
|
|
|
|
|
|
|
des_SPtrans_4->[($u >> 16) & 0x3f]| |
506
|
|
|
|
|
|
|
des_SPtrans_6->[($u >> 24) & 0x3f]; |
507
|
|
|
|
|
|
|
} |
508
|
|
|
|
|
|
|
} else { |
509
|
10171
|
|
|
|
|
27872
|
for ($i = 30; $i > 0; $i -= 4) { |
510
|
81368
|
|
|
|
|
127637
|
$u = ($r ^ $s[($i - 0) ]); |
511
|
81368
|
|
|
|
|
131912
|
$t = $r ^ $s[($i - 0) + 1]; |
512
|
81368
|
|
|
|
|
155553
|
$t = (($t >> 4) & 0x0fffffff) | ($t << 28); |
513
|
81368
|
|
|
|
|
265049
|
$l ^= des_SPtrans_1->[($t ) & 0x3f]| |
514
|
|
|
|
|
|
|
des_SPtrans_3->[($t >> 8) & 0x3f]| |
515
|
|
|
|
|
|
|
des_SPtrans_5->[($t >> 16) & 0x3f]| |
516
|
|
|
|
|
|
|
des_SPtrans_7->[($t >> 24) & 0x3f]| |
517
|
|
|
|
|
|
|
des_SPtrans_0->[($u ) & 0x3f]| |
518
|
|
|
|
|
|
|
des_SPtrans_2->[($u >> 8) & 0x3f]| |
519
|
|
|
|
|
|
|
des_SPtrans_4->[($u >> 16) & 0x3f]| |
520
|
|
|
|
|
|
|
des_SPtrans_6->[($u >> 24) & 0x3f]; |
521
|
81368
|
|
|
|
|
117358
|
$u = ($l ^ $s[($i - 2) ]); |
522
|
81368
|
|
|
|
|
105459
|
$t = $l ^ $s[($i - 2) + 1]; |
523
|
81368
|
|
|
|
|
108387
|
$t = (($t >> 4) & 0x0fffffff) | ($t << 28); |
524
|
81368
|
|
|
|
|
386750
|
$r ^= des_SPtrans_1->[($t ) & 0x3f]| |
525
|
|
|
|
|
|
|
des_SPtrans_3->[($t >> 8) & 0x3f]| |
526
|
|
|
|
|
|
|
des_SPtrans_5->[($t >> 16) & 0x3f]| |
527
|
|
|
|
|
|
|
des_SPtrans_7->[($t >> 24) & 0x3f]| |
528
|
|
|
|
|
|
|
des_SPtrans_0->[($u ) & 0x3f]| |
529
|
|
|
|
|
|
|
des_SPtrans_2->[($u >> 8) & 0x3f]| |
530
|
|
|
|
|
|
|
des_SPtrans_4->[($u >> 16) & 0x3f]| |
531
|
|
|
|
|
|
|
des_SPtrans_6->[($u >> 24) & 0x3f]; |
532
|
|
|
|
|
|
|
} |
533
|
|
|
|
|
|
|
} |
534
|
|
|
|
|
|
|
|
535
|
20342
|
|
|
|
|
28580
|
$l = (($l >> 1) & 0x7fffffff) | ($l << 31); |
536
|
20342
|
|
|
|
|
26262
|
$r = (($r >> 1) & 0x7fffffff) | ($r << 31); |
537
|
|
|
|
|
|
|
# Clear the top bits on machines with 8byte longs. |
538
|
20342
|
|
|
|
|
22280
|
$l &= 0xffffffff; |
539
|
20342
|
|
|
|
|
22535
|
$r &= 0xffffffff; |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
# Swap $l and $r. |
542
|
|
|
|
|
|
|
# We will not do the swap so just remember they are |
543
|
|
|
|
|
|
|
# Reversed for the rest of the subroutine |
544
|
|
|
|
|
|
|
# Luckily FP fixes this problem :-) |
545
|
|
|
|
|
|
|
|
546
|
20342
|
|
|
|
|
26753
|
$t = (($r >> 1) ^ $l) & 0x55555555; |
547
|
20342
|
|
|
|
|
28048
|
$l ^= $t; |
548
|
20342
|
|
|
|
|
34920
|
$r ^= $t << 1; |
549
|
20342
|
|
|
|
|
24185
|
$t = (($l >> 8) ^ $r) & 0x00ff00ff; |
550
|
20342
|
|
|
|
|
32333
|
$r ^= $t; |
551
|
20342
|
|
|
|
|
22227
|
$l ^= $t << 8; |
552
|
20342
|
|
|
|
|
25277
|
$t = (($r >> 2) ^ $l) & 0x33333333; |
553
|
20342
|
|
|
|
|
21774
|
$l ^= $t; |
554
|
20342
|
|
|
|
|
28083
|
$r ^= $t << 2; |
555
|
20342
|
|
|
|
|
25357
|
$t = (($l >> 16) ^ $r) & 0x0000ffff; |
556
|
20342
|
|
|
|
|
20753
|
$r ^= $t; |
557
|
20342
|
|
|
|
|
26883
|
$l ^= $t << 16; |
558
|
20342
|
|
|
|
|
26577
|
$t = (($r >> 4) ^ $l) & 0x0f0f0f0f; |
559
|
20342
|
|
|
|
|
25082
|
$l ^= $t; |
560
|
20342
|
|
|
|
|
22034
|
$r ^= $t << 4; |
561
|
|
|
|
|
|
|
|
562
|
20342
|
|
|
|
|
141330
|
pack "VV", $l, $r; |
563
|
|
|
|
|
|
|
} |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
1; |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
__END__ |