line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::SSH::Perl::Cipher::Blowfish; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Net::SSH::Perl::Cipher; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
7
|
1
|
|
|
1
|
|
5
|
use base qw( Net::SSH::Perl::Cipher ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
103
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
468
|
use Crypt::Cipher::Blowfish; |
|
1
|
|
|
|
|
311
|
|
|
1
|
|
|
|
|
26
|
|
10
|
1
|
|
|
1
|
|
6
|
use Net::SSH::Perl::Cipher::CBC; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
375
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
6
|
|
|
6
|
1
|
14
|
my $class = shift; |
14
|
6
|
|
|
|
|
18
|
my $ciph = bless { }, $class; |
15
|
6
|
50
|
|
|
|
30
|
$ciph->init(@_) if @_; |
16
|
6
|
|
|
|
|
15
|
$ciph; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
0
|
0
|
0
|
sub keysize { 16 } |
20
|
0
|
|
|
0
|
0
|
0
|
sub blocksize { 8 } |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub init { |
23
|
6
|
|
|
6
|
0
|
10
|
my $ciph = shift; |
24
|
6
|
|
|
|
|
14
|
my($key, $iv, $is_ssh2) = @_; |
25
|
6
|
|
|
|
|
15
|
$key = substr($key, 0, 16); |
26
|
6
|
|
|
|
|
396
|
my $blow = Crypt::Cipher::Blowfish->new($key); |
27
|
6
|
50
|
|
|
|
44
|
$ciph->{cbc} = Net::SSH::Perl::Cipher::CBC->new($blow, |
28
|
|
|
|
|
|
|
$iv ? substr($iv, 0, 8) : undef); |
29
|
6
|
50
|
|
|
|
21
|
$ciph->{is_ssh2} = defined $is_ssh2 ? $is_ssh2 : 0; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub encrypt { |
33
|
3
|
|
|
3
|
1
|
1879
|
my($ciph, $text) = @_; |
34
|
|
|
|
|
|
|
$ciph->{is_ssh2} ? |
35
|
|
|
|
|
|
|
$ciph->{cbc}->encrypt($text) : |
36
|
3
|
50
|
|
|
|
14
|
_swap_bytes($ciph->{cbc}->encrypt(_swap_bytes($text))); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub decrypt { |
40
|
3
|
|
|
3
|
1
|
23
|
my($ciph, $text) = @_; |
41
|
|
|
|
|
|
|
$ciph->{is_ssh2} ? |
42
|
|
|
|
|
|
|
$ciph->{cbc}->decrypt($text) : |
43
|
3
|
50
|
|
|
|
11
|
_swap_bytes($ciph->{cbc}->decrypt(_swap_bytes($text))); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _swap_bytes { |
47
|
12
|
|
|
12
|
|
19
|
my $str = $_[0]; |
48
|
12
|
|
|
|
|
65
|
$str =~ s/(.{4})/reverse $1/sge; |
|
24
|
|
|
|
|
76
|
|
49
|
12
|
|
|
|
|
49
|
$str; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
__END__ |