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 SCAR 18.1
CC
6
Cov
86%
init
3.1
encrypt
2.1
decrypt
2.1
CRAP 6.1
« blib/lib/Net/SSH/Perl/Comp.pm ↑ Summary blib/lib/Net/SSH/Perl/Kex/C25519.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 sub new {
13 6 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=7.0
Pod documented
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 sub init {
23 6 ▶ my $ciph = shift;
Subroutine init: called CC=3 SCAR=11.2
Pod undocumented
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 sub encrypt {
33 3 ▶ my($ciph, $text) = @_;
Subroutine encrypt: called CC=2 SCAR=7.2
Pod documented
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 sub decrypt {
40 3 ▶ my($ciph, $text) = @_;
Subroutine decrypt: called CC=2 SCAR=7.2
Pod documented
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 sub _swap_bytes {
47 12 ▶ my $str = $_[0];
Subroutine _swap_bytes: called CC=1 SCAR=0.0
48 12 $str =~ s/(.{4})/reverse $1/sge;
49 12 $str;
50 }
51  
52 1 1;
53 __END__
« blib/lib/Net/SSH/Perl/Comp.pm ↑ Summary blib/lib/Net/SSH/Perl/Kex/C25519.pm »