Branch Coverage

lib/Crypt/CBC.pm
Criterion Covered Total %
branch 162 244 66.3


line true false branch
41 1 52 unless eval {
56 7 42 if $pbkdf eq "none"
60 2 47 if defined $iv and length $iv != $bs
64 0 47 unless $class->can("_${chain_mode}_encrypt")
68 2 45 if (defined $key and length $key != $ks)
73 34 11 if ($header_mode eq 'salt') { }
4 7 elsif ($header_mode eq 'randomiv') { }
74 0 34 if $literal_key
78 1 3 unless $bs == 8
82 0 44 if $pbkdf eq "none" and not defined $key && defined $iv
85 1 43 if $header_mode eq "randomiv" and $pbkdf ne "randomiv"
112 0 0 unless $self->_load_module("Crypt::FileHandle")
115 0 0 if (ref $self) { }
153 0 3333 unless $operation =~ /^[ed]/i
161 0 10098 unless +(shift())->{'chain_mode'}
169 6255 59 if exists $self->{'chaining_method'}{$decrypt}
172 30 29 $decrypt ? :
173 0 59 unless $code
185 0 3333 unless exists $self->{'buffer'}
189 3333 0 unless ($self->{'civ'})
190 1666 1667 if $d
191 1667 1666 unless $d
201 0 3274 if $self->_needs_padding and $self->{'padding'} eq \&Crypt::CBC::_no_padding and length($data) % $bs
206 0 3274 if $self->_needs_padding and $self->{'padding'} eq \&Crypt::CBC::_rijndael_compat and length($data) % $bs
209 352 2981 unless length $self->{'buffer'} >= $bs
215 1650 1331 if ($d) { }
218 1173 158 if length $blocks[-1] < $bs
238 0 3333 if (length $block == 0 and $self->{'padding'} eq \&Crypt::CBC::_rijndael_compat)
249 1666 1667 if ($self->{'decrypt'}) { }
251 1637 29 if $self->_needs_padding
253 1637 30 if $self->_needs_padding
254 1664 3 unless length $block == 0 and not $self->_needs_padding
269 2 51 if (ref $_[0] eq 'HASH') { }
51 0 elsif ($_[0] =~ /^-[a-zA-Z_]{1,20}$/) { }
294 0 52 unless $cipher
296 50 2 unless (ref $cipher)
297 27 23 $cipher =~ /^Crypt::/ ? :
298 0 50 unless $cipher->can("encrypt") or eval "require $cipher; 1"
300 0 50 unless $cipher->can("keysize")
311 1 223 unless $valid_options{$o}
323 0 52 if exists $options->{'prepend_iv'} and not $options->{'prepend_iv'}
324 0 52 if exists $options->{'add_header'} and not $options->{'add_header'}
325 7 45 if $options->{'literal_key'} or exists $options->{'pbkdf'} and $options->{'pbkdf'} eq "none"
327 1 51 unless $valid_modes{$header_mode}
338 0 49 if ($padding and ref $padding eq 'CODE') { }
342 0 0 unless $rbs == $bs
346 35 0 $padding eq 'standard' ? :
0 35 $padding eq 'rijndael_compat' ? :
5 35 $padding eq 'oneandzeroes' ? :
4 40 $padding eq 'space' ? :
4 44 $padding eq 'null' ? :
1 48 $padding eq 'none' ? :
363 0 51 unless my $ks = $options->{'keysize'} || eval {
366 0 51 unless my $bs = eval {
381 2 49 if ($cipher_object_provided)
382 0 2 if defined $pass
387 1 50 unless defined $pass
393 0 2 if exists $options->{'literal_key'} and exists $options->{'regenerate_key'}
395 2 48 if $options->{'literal_key'}
396 0 50 if exists $options->{'regenerate_key'} and not $options->{'regenerate_key'}
400 43 7 unless defined $salt and $salt ne 1
401 1 7 if defined $salt and length $salt != 8 and $salt ne 1
405 38 11 unless defined $iv
408 2 47 if $literal_key
427 0 49 unless $iter =~ /[\d_]+/ and $iter >= 1
428 0 49 unless $iter =~ /[\d_]+/ and $iter >= 1
441 0 47 $options->{'pcbc'} ? :
2 47 $options->{'chain_mode'} ? :
449 0 0 if $@
455 73 3260 if $self->nodeprecate
456 1630 1630 if $self->{'decrypt'}
458 0 1630 if $pbkdf =~ /^(opensslv1|randomiv)$/
469 9863 176 if $self->chain_mode =~ /^p?cbc$/
570 0 0 if ($bs > length $bytes)
588 0 0 if ref $$iv
590 0 0 unless $self->_load_module("Math::Int128", "'net_to_int128','int128_to_net'")
607 2 1 ref $hc ? :
3 3331 $hc ? :
623 3 1671 if ($self->pbkdf eq 'none' or $self->{'literal_key'}) { }
624 0 3 if $self->{'make_random_iv'}
628 1667 4 if $self->{'make_random_iv'}
631 0 1674 unless length $self->{'salt'} == 8
632 0 1674 unless length $self->{'iv'} == $self->{'blocksize'}
644 4 1662 if ($header_mode eq 'none') { }
1660 2 elsif ($header_mode eq 'salt') { }
2 0 elsif ($header_mode eq 'randomiv') { }
651 0 1660 unless defined $self->{'salt'}
654 1660 0 unless $self->{'literal_key'}
655 1660 0 unless $self->{'literal_iv'}
660 0 2 unless defined $self->{'iv'}
661 0 2 unless $self->blocksize == 8
685 0 1666 unless $self->{'key'} and $self->{'civ'}
690 30 1636 ref $self->{'cipher'} ? :
0 1666 unless $self->{'crypt'} = ref $self->{'cipher'} ? $self->{'cipher'} : $self->{'cipher'}->new($self->{'key'})
697 1667 0 if $self->{'make_random_salt'}
704 1661 6 if ($header_mode eq 'salt') { }
3 3 elsif ($header_mode eq 'randomiv') { }
713 0 1667 unless defined $self->{'key'} and defined $self->{'civ'}
718 30 1637 ref $self->{'cipher'} ? :
0 1667 unless $self->{'crypt'} = ref $self->{'cipher'} ? $self->{'cipher'} : $self->{'cipher'}->new($self->{'key'})
725 1667 0 unless ${^TAINT}
731 0 0 if ($has_scalar_util) { }
740 0 0 if $tainted
747 0 0 if ($self->{'digest_obj'})
753 0 0 if ref $alg and $alg->can("digest")
755 0 0 if $@
762 0 2 unless my $bytes = shift()
772 0 1676 unless length $1 == $length
779 502 502 if ($decrypt eq "d")
790 378 378 if ($decrypt eq 'd') { }
805 37 719 unless length $b
806 719 0 length $b ? :
807 378 341 if ($decrypt eq "d")
816 379 379 if ($decrypt eq "d")
826 0 0 unless length $b
827 0 0 if ($decrypt eq "d")
843 0 0 unless length $iv == $bs
850 0 11 if @_
857 0 15 if @_
864 0 15 if @_
871 1 3 if (@_)
881 0 0 if @_