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

filter: Statementstmt 100% 31 / 31 Branchbran 100% 4 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 3 totaltotal 85.4% 41 / 48 SCAR 13.9
CC
4
Cov
95%
new
2.3
encrypt
2.0
decrypt
2.0
CRAP 4.0
« blib/lib/Net/SSH/Perl/Cipher/CBC.pm ↑ Summary blib/lib/Net/SSH/Perl/Kex/DH1.pm »
1 # This code based in part on the Systemics Crypt::CFB.
2 # Parts Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/)
3 # All rights reserved.
4  
5 package Net::SSH::Perl::Cipher::CFB;
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub new {
10 6 ▶ my($class, $ciph, $iv) = @_;
Subroutine new: called CC=2 SCAR=8.1
Pod undocumented
11 6 ▶ bless {
Condition33%1/3
$iv || "\000" x $ciph->blocksize
l!l&&r!l&&!r
060
MC/DC0%0/2
$iv || "\000" x $ciph->blocksize
$iv "\000" x $ciph->blocksize
Truth table33%1/3
A || B
A= $ivB= "\000" x $ciph->blocksize
ABresult
1X1
011
000
12 cipher => $ciph,
13 iv => $iv || ("\0" x $ciph->blocksize),
14 }, $class;
15 }
16  
17 sub encrypt {
18 3 ▶ my $cfb = shift;
Subroutine encrypt: called CC=2 SCAR=6.9
Pod undocumented
19 3 my $data = shift;
20  
21 3 my $retval = "";
22 3 my $iv = $cfb->{iv};
23 3 my $size = $cfb->{cipher}->blocksize;
24  
25 3 ▶ while (length $data) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $data) 3 3 6
26 3 my $out = $cfb->{cipher}->encrypt($iv);
27 3 $iv = substr($data, 0, $size, '') ^ substr($out, 0, $size, '');
28 3 $retval .= $iv;
29 }
30  
31 3 $cfb->{iv} = $iv;
32 3 $retval;
33 }
34  
35 sub decrypt {
36 3 ▶ my $cfb = shift;
Subroutine decrypt: called CC=2 SCAR=6.9
Pod undocumented
37 3 my $data = shift;
38  
39 3 my $retval = "";
40 3 my $iv = $cfb->{iv};
41 3 my $size = $cfb->{cipher}->blocksize;
42  
43 3 ▶ while (length $data) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $data) 3 3 6
44 3 my $out = $cfb->{cipher}->encrypt($iv);
45 3 $iv = substr($data, 0, $size, '');
46 3 $retval .= $iv ^ substr($out, 0, $size);
47 }
48  
49 3 $cfb->{iv} = $iv;
50 3 $retval;
51 }
52  
53 1 1;
54 __END__
« blib/lib/Net/SSH/Perl/Cipher/CBC.pm ↑ Summary blib/lib/Net/SSH/Perl/Kex/DH1.pm »