Branch Coverage

lib/Crypt/CBC.pm
Criterion Covered Total %
branch 163 246 66.2


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'
113 0 0 unless $self->_load_module('Crypt::FileHandle')
116 0 0 if (ref $self) { }
154 0 1761 unless $operation =~ /^[ed]/i
162 0 5338 unless +(shift())->{'chain_mode'}
170 3223 39 if exists $self->{'chaining_method'}{$decrypt}
173 20 19 $decrypt ? :
174 0 39 unless $code
186 0 1761 unless exists $self->{'buffer'}
190 1761 0 unless ($self->{'civ'})
191 880 881 if $d
192 881 880 unless $d
202 0 1702 if $self->_needs_padding and $self->{'padding'} eq \&Crypt::CBC::_no_padding and length($data) % $bs
207 0 1702 if $self->_needs_padding and $self->{'padding'} eq \&Crypt::CBC::_rijndael_compat and length($data) % $bs
210 260 1501 unless length $self->{'buffer'} >= $bs
216 864 637 if ($d) { }
219 575 62 if length $blocks[-1] < $bs
239 0 1761 if (length $block == 0 and $self->{'padding'} eq \&Crypt::CBC::_rijndael_compat)
250 880 881 if ($self->{'decrypt'}) { }
252 851 29 if $self->_needs_padding
254 851 30 if $self->_needs_padding
255 878 3 unless length $block == 0 and not $self->_needs_padding
270 1 42 if (ref $_[0] eq 'HASH') { }
42 0 elsif ($_[0] =~ /^-[a-zA-Z_]{1,20}$/) { }
295 0 42 unless $cipher
297 40 2 unless (ref $cipher)
298 27 13 $cipher =~ /^Crypt::/ ? :
299 0 40 unless $cipher->can('encrypt') or eval "require $cipher; 1"
301 0 40 unless $cipher->can('keysize')
312 1 183 unless $valid_options{$o}
324 0 42 if exists $options->{'prepend_iv'} and not $options->{'prepend_iv'}
325 0 42 if exists $options->{'add_header'} and not $options->{'add_header'}
326 7 35 if $options->{'literal_key'} or exists $options->{'pbkdf'} and $options->{'pbkdf'} eq 'none'
328 1 41 unless $valid_modes{$header_mode}
339 0 39 if ($padding and ref $padding eq 'CODE') { }
343 0 0 unless $rbs == $bs
347 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' ? :
364 0 41 unless my $ks = $options->{'keysize'} || eval { do { $cipher->keysize } } || eval { do { $cipher->max_keysize } }
367 0 41 unless my $bs = eval { do { $cipher->blocksize } }
382 2 39 if ($cipher_object_provided)
383 0 2 if defined $pass
388 1 40 unless defined $pass
394 0 2 if exists $options->{'literal_key'} and exists $options->{'regenerate_key'}
396 2 38 if $options->{'literal_key'}
397 0 40 if exists $options->{'regenerate_key'} and not $options->{'regenerate_key'}
401 33 7 unless defined $salt and $salt ne '1'
402 1 7 if defined $salt and length $salt != 8 and $salt ne '1'
406 28 11 unless defined $iv
409 2 37 if $literal_key
428 0 39 unless $iter =~ /[\d_]+/ and $iter >= 1
429 0 39 unless $iter =~ /[\d_]+/ and $iter >= 1
442 0 37 $options->{'pcbc'} ? :
2 37 $options->{'chain_mode'} ? :
450 0 0 if $@
456 13 1748 if $self->nodeprecate
457 874 874 if $self->{'decrypt'}
459 0 874 if $pbkdf =~ /^(opensslv1|randomiv)$/
470 5123 176 if $self->chain_mode =~ /^p?cbc$/
571 0 0 if ($bs > length $bytes)
589 0 0 if ref $$iv
591 0 0 unless $self->_load_module('Math::Int128', q['net_to_int128','int128_to_net'])
608 2 1 ref $hc ? :
3 1759 $hc ? :
625 885 3 if (not $self->{'literal_key'}) { }
628 881 4 if $self->{'make_random_iv'}
630 0 3 if $self->{'make_random_iv'}
633 0 888 unless length $self->{'salt'} == 8
634 0 888 unless length $self->{'iv'} == $self->{'blocksize'}
646 4 876 if ($header_mode eq 'none') { }
875 1 elsif ($header_mode eq 'salt') { }
1 0 elsif ($header_mode eq 'randomiv') { }
653 0 875 unless defined $self->{'salt'}
656 875 0 unless $self->{'literal_key'}
657 875 0 unless $self->{'literal_iv'}
662 0 1 unless defined $self->{'iv'}
663 0 1 unless $self->blocksize == 8
687 0 880 unless $self->{'key'} and $self->{'civ'}
692 30 850 ref $self->{'cipher'} ? :
0 880 unless $self->{'crypt'} = ref $self->{'cipher'} ? $self->{'cipher'} : $self->{'cipher'}->new($self->{'key'})
699 881 0 if $self->{'make_random_salt'}
706 876 5 if ($header_mode eq 'salt') { }
2 3 elsif ($header_mode eq 'randomiv') { }
715 0 881 unless defined $self->{'key'} and defined $self->{'civ'}
720 30 851 ref $self->{'cipher'} ? :
0 881 unless $self->{'crypt'} = ref $self->{'cipher'} ? $self->{'cipher'} : $self->{'cipher'}->new($self->{'key'})
727 881 0 unless ${^TAINT}
733 0 0 if ($has_scalar_util) { }
742 0 0 if $tainted
749 0 0 if ($self->{'digest_obj'})
755 0 0 if ref $alg and $alg->can('digest')
757 0 0 if $@
764 0 2 unless my $bytes = shift()
773 888 0 if (-r '/dev/urandom' and open F, '/dev/urandom') { }
781 0 888 unless length $1 == $length
788 283 283 if ($decrypt eq 'd')
799 189 189 if ($decrypt eq 'd') { }
814 13 365 unless length $b
815 365 0 length $b ? :
816 189 176 if ($decrypt eq 'd')
825 190 190 if ($decrypt eq 'd')
835 0 0 unless length $b
836 0 0 if ($decrypt eq 'd')
852 0 0 unless length $iv == $bs
859 0 11 if @_
866 0 15 if @_
873 0 15 if @_
880 1 3 if (@_)
890 0 0 if @_