Branch Coverage

lib/Crypt/CBC.pm
Criterion Covered Total %
branch 161 242 66.5


line true false branch
42 1 42 unless eval { do { $class->_validate_options($options) } }
57 7 32 if $pbkdf eq 'none'
61 2 37 if defined $iv and length $iv != $bs
65 0 37 unless $class->can("_${chain_mode}_encrypt")
69 2 35 if (defined $key and length $key != $ks)
74 25 10 if ($header_mode eq 'salt') { }
3 7 elsif ($header_mode eq 'randomiv') { }
75 0 25 if $literal_key
79 1 2 unless $bs == 8
83 0 34 if $pbkdf eq 'none' and not defined $key && defined $iv
86 1 33 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 1761 unless $operation =~ /^[ed]/i
161 0 5338 unless +(shift())->{'chain_mode'}
169 3223 39 if exists $self->{'chaining_method'}{$decrypt}
172 20 19 $decrypt ? :
173 0 39 unless $code
185 0 1761 unless exists $self->{'buffer'}
189 1761 0 unless ($self->{'civ'})
190 880 881 if $d
191 881 880 unless $d
201 0 1702 if $self->_needs_padding and $self->{'padding'} eq \&Crypt::CBC::_no_padding and length($data) % $bs
206 0 1702 if $self->_needs_padding and $self->{'padding'} eq \&Crypt::CBC::_rijndael_compat and length($data) % $bs
209 260 1501 unless length $self->{'buffer'} >= $bs
215 864 637 if ($d) { }
218 575 62 if length $blocks[-1] < $bs
238 0 1761 if (length $block == 0 and $self->{'padding'} eq \&Crypt::CBC::_rijndael_compat)
249 880 881 if ($self->{'decrypt'}) { }
251 851 29 if $self->_needs_padding
253 851 30 if $self->_needs_padding
254 878 3 unless length $block == 0 and not $self->_needs_padding
269 1 42 if (ref $_[0] eq 'HASH') { }
42 0 elsif ($_[0] =~ /^-[a-zA-Z_]{1,20}$/) { }
294 0 42 unless $cipher
296 40 2 unless (ref $cipher)
297 27 13 $cipher =~ /^Crypt::/ ? :
298 0 40 unless $cipher->can('encrypt') or eval "require $cipher; 1"
300 0 40 unless $cipher->can('keysize')
311 1 184 unless $valid_options{$o}
323 0 42 if exists $options->{'prepend_iv'} and not $options->{'prepend_iv'}
324 0 42 if exists $options->{'add_header'} and not $options->{'add_header'}
325 7 35 if $options->{'literal_key'} or exists $options->{'pbkdf'} and $options->{'pbkdf'} eq 'none'
327 1 41 unless $valid_modes{$header_mode}
338 0 39 if ($padding and ref $padding eq 'CODE') { }
342 0 0 unless $rbs == $bs
346 31 0 $padding eq 'standard' ? :
0 31 $padding eq 'rijndael_compat' ? :
3 31 $padding eq 'oneandzeroes' ? :
2 34 $padding eq 'space' ? :
2 36 $padding eq 'null' ? :
1 38 $padding eq 'none' ? :
363 0 41 unless my $ks = $options->{'keysize'} || eval { do { $cipher->keysize } } || eval { do { $cipher->max_keysize } }
366 0 41 unless my $bs = eval { do { $cipher->blocksize } }
381 2 39 if ($cipher_object_provided)
382 0 2 if defined $pass
387 1 40 unless defined $pass
393 0 2 if exists $options->{'literal_key'} and exists $options->{'regenerate_key'}
395 2 38 if $options->{'literal_key'}
396 0 40 if exists $options->{'regenerate_key'} and not $options->{'regenerate_key'}
400 33 7 unless defined $salt and $salt ne '1'
401 1 7 if defined $salt and length $salt != 8 and $salt ne '1'
405 28 11 unless defined $iv
408 2 37 if $literal_key
427 0 39 unless $iter =~ /[\d_]+/ and $iter >= 1
428 0 39 unless $iter =~ /[\d_]+/ and $iter >= 1
441 0 37 $options->{'pcbc'} ? :
2 37 $options->{'chain_mode'} ? :
449 0 0 if $@
455 13 1748 if $self->nodeprecate
456 874 874 if $self->{'decrypt'}
458 0 874 if $pbkdf =~ /^(opensslv1|randomiv)$/
469 5123 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', q['net_to_int128','int128_to_net'])
607 2 1 ref $hc ? :
3 1759 $hc ? :
624 885 3 if (not $self->{'literal_key'}) { }
627 881 4 if $self->{'make_random_iv'}
629 0 3 if $self->{'make_random_iv'}
632 0 888 unless length $self->{'salt'} == 8
633 0 888 unless length $self->{'iv'} == $self->{'blocksize'}
645 4 876 if ($header_mode eq 'none') { }
875 1 elsif ($header_mode eq 'salt') { }
1 0 elsif ($header_mode eq 'randomiv') { }
652 0 875 unless defined $self->{'salt'}
659 0 1 unless defined $self->{'iv'}
660 0 1 unless $self->blocksize == 8
684 0 880 unless $self->{'key'} and $self->{'civ'}
689 30 850 ref $self->{'cipher'} ? :
0 880 unless $self->{'crypt'} = ref $self->{'cipher'} ? $self->{'cipher'} : $self->{'cipher'}->new($self->{'key'})
696 881 0 if $self->{'make_random_salt'}
703 876 5 if ($header_mode eq 'salt') { }
2 3 elsif ($header_mode eq 'randomiv') { }
712 0 881 unless defined $self->{'key'} and defined $self->{'civ'}
717 30 851 ref $self->{'cipher'} ? :
0 881 unless $self->{'crypt'} = ref $self->{'cipher'} ? $self->{'cipher'} : $self->{'cipher'}->new($self->{'key'})
724 881 0 unless ${^TAINT}
730 0 0 if ($has_scalar_util) { }
739 0 0 if $tainted
746 0 0 if ($self->{'digest_obj'})
752 0 0 if ref $alg and $alg->can('digest')
754 0 0 if $@
761 0 2 unless my $bytes = shift()
770 888 0 if (-r '/dev/urandom' and open F, '/dev/urandom') { }
778 0 888 unless length $1 == $length
785 283 283 if ($decrypt eq 'd')
796 189 189 if ($decrypt eq 'd') { }
811 13 365 unless length $b
812 365 0 length $b ? :
813 189 176 if ($decrypt eq 'd')
822 190 190 if ($decrypt eq 'd')
832 0 0 unless length $b
833 0 0 if ($decrypt eq 'd')
849 0 0 unless length $iv == $bs
856 0 11 if @_
863 0 15 if @_
870 0 15 if @_
877 1 3 if (@_)
887 0 0 if @_