Branch Coverage

lib/Crypt/CBC.pm
Criterion Covered Total %
branch 155 238 65.1


line true false branch
42 1 41 unless eval { do { $class->_validate_options($options) } }
57 6 32 if $pbkdf eq 'none'
61 2 36 if defined $iv and length $iv != $bs
65 0 36 unless $class->can("_${chain_mode}_encrypt")
69 2 34 if (defined $key and length $key != $ks)
74 25 9 if ($header_mode eq 'salt') { }
3 6 elsif ($header_mode eq 'randomiv') { }
75 0 25 if $literal_key
79 1 2 unless $bs == 8
83 0 33 if $pbkdf eq 'none' and not defined $key && defined $iv
86 1 32 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 1760 unless $operation =~ /^[ed]/i
161 0 5318 unless +(shift())->{'chain_mode'}
169 3222 38 if exists $self->{'chaining_method'}{$decrypt}
172 20 18 $decrypt ? :
173 0 38 unless $code
185 0 1760 unless exists $self->{'buffer'}
189 1760 0 unless ($self->{'civ'})
190 880 880 if $d
191 880 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 1500 unless length $self->{'buffer'} >= $bs
215 864 636 if ($d) { }
218 575 61 if length $blocks[-1] < $bs
238 0 1760 if (length $block == 0 and $self->{'padding'} eq \&Crypt::CBC::_rijndael_compat)
249 880 880 if ($self->{'decrypt'}) { }
251 851 29 if $self->_needs_padding
253 851 29 if $self->_needs_padding
269 0 42 if (ref $_[0] eq 'HASH') { }
42 0 elsif ($_[0] =~ /^-[a-zA-Z_]{1,20}$/) { }
294 0 41 unless $cipher
296 39 2 unless (ref $cipher)
297 27 12 $cipher =~ /^Crypt::/ ? :
298 0 39 unless $cipher->can('encrypt') or eval "require $cipher; 1"
300 0 39 unless $cipher->can('keysize')
311 1 176 unless $valid_options{$o}
323 0 41 if exists $options->{'prepend_iv'} and not $options->{'prepend_iv'}
324 0 41 if exists $options->{'add_header'} and not $options->{'add_header'}
325 6 35 if $options->{'literal_key'} or exists $options->{'pbkdf'} and $options->{'pbkdf'} eq 'none'
327 1 40 unless $valid_modes{$header_mode}
338 0 38 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' ? :
0 38 $padding eq 'none' ? :
363 0 40 unless my $ks = $options->{'keysize'} || eval { do { $cipher->keysize } } || eval { do { $cipher->max_keysize } }
366 0 40 unless my $bs = eval { do { $cipher->blocksize } }
381 2 38 if ($cipher_object_provided)
382 0 2 if defined $pass
387 1 39 unless defined $pass
393 0 1 if exists $options->{'literal_key'} and exists $options->{'regenerate_key'}
395 1 38 if $options->{'literal_key'}
396 0 39 if exists $options->{'regenerate_key'} and not $options->{'regenerate_key'}
400 32 7 unless defined $salt and $salt ne '1'
401 1 7 if defined $salt and length $salt != 8 and $salt ne '1'
405 28 10 unless defined $iv
408 1 37 if $literal_key
427 0 38 unless $iter =~ /[\d_]+/ and $iter >= 1
428 0 38 unless $iter =~ /[\d_]+/ and $iter >= 1
441 0 36 $options->{'pcbc'} ? :
2 36 $options->{'chain_mode'} ? :
449 0 0 if $@
455 12 1748 if $self->nodeprecate
456 874 874 if $self->{'decrypt'}
458 0 874 if $pbkdf =~ /^(opensslv1|randomiv)$/
569 0 0 if ($bs > length $bytes)
587 0 0 if ref $$iv
589 0 0 unless $self->_load_module('Math::Int128', q['net_to_int128','int128_to_net'])
606 2 1 ref $hc ? :
3 1759 $hc ? :
623 885 2 if (not $self->{'literal_key'}) { }
626 881 4 if $self->{'make_random_iv'}
628 0 2 if $self->{'make_random_iv'}
631 0 887 unless length $self->{'salt'} == 8
632 0 887 unless length $self->{'iv'} == $self->{'blocksize'}
644 4 876 if ($header_mode eq 'none') { }
875 1 elsif ($header_mode eq 'salt') { }
1 0 elsif ($header_mode eq 'randomiv') { }
651 0 875 unless defined $self->{'salt'}
658 0 1 unless defined $self->{'iv'}
659 0 1 unless $self->blocksize == 8
683 0 880 unless $self->{'key'} and $self->{'civ'}
688 30 850 ref $self->{'cipher'} ? :
0 880 unless $self->{'crypt'} = ref $self->{'cipher'} ? $self->{'cipher'} : $self->{'cipher'}->new($self->{'key'})
695 880 0 if $self->{'make_random_salt'}
702 876 4 if ($header_mode eq 'salt') { }
2 2 elsif ($header_mode eq 'randomiv') { }
711 0 880 unless defined $self->{'key'} and defined $self->{'civ'}
716 30 850 ref $self->{'cipher'} ? :
0 880 unless $self->{'crypt'} = ref $self->{'cipher'} ? $self->{'cipher'} : $self->{'cipher'}->new($self->{'key'})
723 880 0 unless ${^TAINT}
729 0 0 if ($has_scalar_util) { }
738 0 0 if $tainted
745 0 0 if ($self->{'digest_obj'})
751 0 0 if ref $alg and $alg->can('digest')
753 0 0 if $@
760 0 2 unless my $bytes = shift()
769 887 0 if (-r '/dev/urandom' and open F, '/dev/urandom') { }
777 0 887 unless length $1 == $length
784 283 283 if ($decrypt eq 'd')
795 189 189 if ($decrypt eq 'd') { }
810 13 365 unless length $b
811 365 0 length $b ? :
812 189 176 if ($decrypt eq 'd')
821 190 190 if ($decrypt eq 'd')
831 0 0 unless length $b
832 0 0 if ($decrypt eq 'd')
848 0 0 unless length $iv == $bs
855 0 11 if @_
862 0 15 if @_
869 0 15 if @_
876 1 3 if (@_)
886 0 0 if @_