line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: DES.pm,v 1.7 2001/05/02 21:59:33 btrott Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Net::SSH::Perl::Cipher::DES; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
6
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
8
|
use Net::SSH::Perl::Cipher; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
9
|
1
|
|
|
1
|
|
7
|
use base qw( Net::SSH::Perl::Cipher ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
91
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
9
|
use Net::SSH::Perl::Cipher::CBC; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
12
|
1
|
|
|
1
|
|
8
|
use Crypt::Cipher::DES; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
299
|
|
13
|
|
|
|
|
|
|
|
14
|
6
|
|
|
6
|
0
|
16
|
sub keysize { 8 } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
6
|
|
|
6
|
1
|
14
|
my $class = shift; |
18
|
6
|
|
|
|
|
18
|
my $ciph = bless { }, $class; |
19
|
6
|
50
|
|
|
|
31
|
$ciph->init(@_) if @_; |
20
|
6
|
|
|
|
|
91
|
$ciph; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub init { |
24
|
6
|
|
|
6
|
0
|
13
|
my $ciph = shift; |
25
|
6
|
|
|
|
|
17
|
my($key, $iv) = @_; |
26
|
6
|
|
|
|
|
16
|
$key = substr($key,0,$ciph->keysize); |
27
|
6
|
|
|
|
|
58
|
my $des = Crypt::Cipher::DES->new($key); |
28
|
6
|
|
|
|
|
331
|
$ciph->{cbc} = Net::SSH::Perl::Cipher::CBC->new($des, $iv); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub encrypt { |
32
|
3
|
|
|
3
|
1
|
3457
|
my($ciph, $text) = @_; |
33
|
3
|
|
|
|
|
70
|
$ciph->{cbc}->encrypt($text); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub decrypt { |
37
|
3
|
|
|
3
|
1
|
19
|
my($ciph, $text) = @_; |
38
|
3
|
|
|
|
|
12
|
$ciph->{cbc}->decrypt($text); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
__END__ |