line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: DES_EDE3.pm,v 1.2 2001/09/15 03:41:09 btrott Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Crypt::DES_EDE3; |
4
|
1
|
|
|
1
|
|
16359
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
861
|
use Crypt::DES; |
|
1
|
|
|
|
|
1159
|
|
|
1
|
|
|
|
|
47
|
|
7
|
1
|
|
|
1
|
|
6
|
use vars qw( $VERSION ); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
580
|
|
8
|
|
|
|
|
|
|
$VERSION = '0.01'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
1
|
|
|
1
|
1
|
11
|
my $class = shift; |
12
|
1
|
|
|
|
|
4
|
my $ede3 = bless {}, $class; |
13
|
1
|
|
|
|
|
6
|
$ede3->init(@_); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
1
|
97
|
sub keysize { 24 } |
17
|
0
|
|
|
0
|
1
|
0
|
sub blocksize { 8 } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init { |
20
|
1
|
|
|
1
|
0
|
3
|
my $ede3 = shift; |
21
|
1
|
|
|
|
|
3
|
my($key) = @_; |
22
|
1
|
|
|
|
|
4
|
for my $i (1..3) { |
23
|
3
|
|
|
|
|
62
|
$ede3->{"des$i"} = Crypt::DES->new(substr $key, 8*($i-1), 8); |
24
|
|
|
|
|
|
|
} |
25
|
1
|
|
|
|
|
14
|
$ede3; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub encrypt { |
29
|
1
|
|
|
1
|
1
|
2
|
my($ede3, $block) = @_; |
30
|
1
|
|
|
|
|
6
|
$ede3->{des3}->encrypt( |
31
|
|
|
|
|
|
|
$ede3->{des2}->decrypt( |
32
|
|
|
|
|
|
|
$ede3->{des1}->encrypt($block) |
33
|
|
|
|
|
|
|
) |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub decrypt { |
38
|
1
|
|
|
1
|
1
|
74
|
my($ede3, $block) = @_; |
39
|
1
|
|
|
|
|
5
|
$ede3->{des1}->decrypt( |
40
|
|
|
|
|
|
|
$ede3->{des2}->encrypt( |
41
|
|
|
|
|
|
|
$ede3->{des3}->decrypt($block) |
42
|
|
|
|
|
|
|
) |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
__END__ |