blib/lib/Net/SSH/Perl/Cipher/Blowfish.pm

filter: Statementstmt 94.8% 37 / 39 Branchbran 50.0% 5 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.6% 11 / 13 Podpod 50.0% 3 / 6 totaltotal 82.3% 56 / 68 CC 6 SCAR 5.9
CC
6
Cov
86%
init
3.1
encrypt
2.1
decrypt
2.1
CRAP 1.8
« blib/lib/Net/SSH/Perl/Cipher/CFB.pm ↑ Summary blib/lib/Net/SSH/Perl/Cipher/AES128_CTR.pm »
1 package Net::SSH::Perl::Cipher::Blowfish;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Net::SSH::Perl::Cipher;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use base qw( Net::SSH::Perl::Cipher );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Crypt::Cipher::Blowfish;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Net::SSH::Perl::Cipher::CBC;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 6 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
13 6 my $class = shift;
14 6 my $ciph = bless { }, $class;
15 6 ▶ $ciph->init(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 6 0 6
16 6 $ciph;
17 }
18  
19 0 ▶sub keysize { 16 }
Subroutine keysize: not called CC=1 SCAR=6.9
Pod undocumented
20 0 ▶sub blocksize { 8 }
Subroutine blocksize: not called CC=1 SCAR=6.9
Pod undocumented
21  
22 6 ▶sub init {
Subroutine init: called CC=3 SCAR=11.2
Pod undocumented
23 6 my $ciph = shift;
24 6 my($key, $iv, $is_ssh2) = @_;
25 6 $key = substr($key, 0, 16);
26 6 my $blow = Crypt::Cipher::Blowfish->new($key);
27 6 ▶ $ciph->{cbc} = Net::SSH::Perl::Cipher::CBC->new($blow,
Branch: 1 branch
BranchTrueFalseTotal
$iv ? : 0 6 6
28 $iv ? substr($iv, 0, 8) : undef);
29 6 ▶ $ciph->{is_ssh2} = defined $is_ssh2 ? $is_ssh2 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $is_ssh2 ? : 0 6 6
30 }
31  
32 3 ▶sub encrypt {
Subroutine encrypt: called CC=2 SCAR=7.2
Pod documented
33 3 my($ciph, $text) = @_;
34 $ciph->{is_ssh2} ?
35 $ciph->{cbc}->encrypt($text) :
36 3 ▶ _swap_bytes($ciph->{cbc}->encrypt(_swap_bytes($text)));
Branch: 1 branch
BranchTrueFalseTotal
$ciph->{'is_ssh2'} ? : 0 3 3
37 }
38  
39 3 ▶sub decrypt {
Subroutine decrypt: called CC=2 SCAR=7.2
Pod documented
40 3 my($ciph, $text) = @_;
41 $ciph->{is_ssh2} ?
42 $ciph->{cbc}->decrypt($text) :
43 3 ▶ _swap_bytes($ciph->{cbc}->decrypt(_swap_bytes($text)));
Branch: 1 branch
BranchTrueFalseTotal
$ciph->{'is_ssh2'} ? : 0 3 3
44 }
45  
46 12 ▶sub _swap_bytes {
Subroutine _swap_bytes: called CC=1 SCAR=0.0
47 12 my $str = $_[0];
48 12 $str =~ s/(.{4})/reverse $1/sge;
49 12 $str;
50 }
51  
52 1 1;
53 __END__
« blib/lib/Net/SSH/Perl/Cipher/CFB.pm ↑ Summary blib/lib/Net/SSH/Perl/Cipher/AES128_CTR.pm »