Branch Coverage

blib/lib/Net/SNMP/Security/USM.pm
Criterion Covered Total %
branch 103 404 25.5


line true false branch
143 0 9 if (/^-?authoritative$/i) { }
1 8 elsif (/^-?authprotocol$/i) { }
2 6 elsif (/^-?privprotocol$/i) { }
144 0 0 delete $argv{$_} ? :
151 0 9 if (defined $$this{'_error'})
152 0 0 wantarray ? :
160 0 6 if (/^-?version$/i) { }
0 6 elsif (/^-?debug$/i) { }
0 6 elsif (/^-?engineid$/i and $$this{'_authoritative'}) { }
2 4 elsif (/^-?username$/i) { }
0 4 elsif (/^-?authkey$/i) { }
2 2 elsif (/^-?authpassword$/i) { }
0 2 elsif (/^-?privkey$/i) { }
2 0 elsif (/^-?privpassword$/i) { }
180 0 6 if (defined $$this{'_error'})
181 0 0 wantarray ? :
189 0 2 if ($$this{'_authoritative'})
194 0 2 unless (defined $this->_security_params)
195 0 0 wantarray ? :
199 2 0 wantarray ? :
209 0 0 if (@_ < 3)
214 0 0 if ($pdu->version != $$this{'_version'})
222 0 0 if ($pdu->security_level > $$this{'_security_level'})
230 0 0 if ($pdu->expect_response) { }
231 0 0 if ($$this{'_authoritative'})
238 0 0 unless ($$this{'_authoritative'})
264 0 0 if ($pdu->security_level > SECURITY_LEVEL_AUTHNOPRIV())
265 0 0 unless (defined $this->_encrypt_data($msg, $priv_params, $pdu_buffer))
271 0 0 unless (defined $msg->prepare(OCTET_STRING(), $priv_params))
280 0 0 if ($pdu->security_level > SECURITY_LEVEL_NOAUTHNOPRIV())
289 0 0 unless (defined $msg->prepare(OCTET_STRING(), $auth_params))
294 0 0 unless (defined $msg->prepare(OCTET_STRING(), $pdu->security_name))
299 0 0 unless (defined $msg->prepare(INTEGER(), $msg_engine_time))
304 0 0 unless (defined $msg->prepare(INTEGER(), $msg_engine_boots))
309 0 0 unless (defined $msg->prepare(OCTET_STRING(), $this->_engine_id))
314 0 0 unless (defined $msg->prepare(SEQUENCE()))
319 0 0 unless (defined $msg->prepare(OCTET_STRING(), $msg->clear))
324 0 0 unless (defined $msg->append($pdu_buffer))
329 0 0 unless (defined $msg->prepend($msg_global_data))
334 0 0 unless (defined $msg->prepare(INTEGER(), $$this{'_version'}))
339 0 0 unless (defined $msg->prepare(SEQUENCE()))
344 0 0 if ($pdu->security_level > SECURITY_LEVEL_NOAUTHNOPRIV())
345 0 0 unless (defined $this->_authenticate_outgoing_msg($msg, $auth_location))
361 0 0 if @_ < 2
366 0 0 unless defined $msg_params
374 0 0 unless defined $msg->process(SEQUENCE())
378 0 0 unless (defined($msg_engine_id = $msg->process(OCTET_STRING())))
384 0 0 unless (defined($msg_engine_boots = $msg->process(INTEGER())))
387 0 0 if ($msg_engine_boots < 0 or $msg_engine_boots > 2147483647)
396 0 0 unless (defined($msg_engine_time = $msg->process(INTEGER())))
399 0 0 if ($msg_engine_time < 0 or $msg_engine_time > 2147483647)
407 0 0 unless (defined $msg->security_name($msg->process(OCTET_STRING())))
413 0 0 unless (defined($auth_params = $msg->process(OCTET_STRING())))
420 0 0 if (my $len = length $auth_params)
421 0 0 if ($len != 12)
431 0 0 unless (defined($priv_params = $msg->process(OCTET_STRING())))
437 0 0 if ($$this{'_discovered'}) { }
439 0 0 if ($msg_engine_id ne $this->_engine_id)
447 0 0 if ($msg->security_name ne $this->_user_name)
457 0 0 unless (defined $this->_engine_id_discovery($msg_engine_id))
467 0 0 if ($security_level > $$this{'_security_level'})
474 0 0 if ($security_level > SECURITY_LEVEL_NOAUTHNOPRIV())
477 0 0 unless (defined $this->_authenticate_incoming_msg($msg, $auth_params))
482 0 0 unless ($this->_synchronize($msg_engine_boots, $msg_engine_time))
487 0 0 unless (defined $this->_timeliness($msg_engine_boots, $msg_engine_time))
491 0 0 if ($security_level > SECURITY_LEVEL_AUTHNOPRIV())
495 0 0 if (length $priv_params != 8)
509 0 0 if ($$this{'_priv_protocol'} eq PRIV_PROTOCOL_AESCFB128() or $$this{'_priv_protocol'} eq PRIV_PROTOCOL_DRAFT_AESCFB192() or $$this{'_priv_protocol'} eq PRIV_PROTOCOL_DRAFT_AESCFB256())
539 0 0 if ($$this{'_security_level'} > SECURITY_LEVEL_NOAUTHNOPRIV())
555 0 0 if ($$this{'_security_level'} > SECURITY_LEVEL_AUTHNOPRIV())
603 0 0 if ($$this{'_security_level'} > SECURITY_LEVEL_NOAUTHNOPRIV())
616 0 0 if ($version != SNMP_VERSION_3())
627 0 0 if (@_ < 2)
631 0 0 if ($engine_id =~ /^(?:0x)?([A-F0-9]+)$/i) { }
632 0 0 length($1) % 2 ? :
634 0 0 if ($len < 5 or $len > 32)
655 2 0 if (@_ == 2)
656 0 2 if ($user_name eq '') { }
0 2 elsif (length $user_name > 32) { }
669 0 2 $$this{'_discovered'} ? :
676 0 0 if ($$this{'_engine_id'} eq '')
687 0 0 unless (defined $ENGINE_ID)
694 0 0 if ($@)
714 0 0 if (@_ == 2)
715 0 0 if ($auth_key =~ /^(?:0x)?([A-F0-9]+)$/i) { }
716 0 0 length($1) % 2 ? :
717 0 0 unless (defined $this->_auth_key_validate)
734 2 0 if (@_ == 2)
735 0 2 if ($auth_password eq '')
756 0 1 if (@_ < 2)
760 0 1 if ($proto eq '')
765 1 1 if ($proto =~ /^$_$/i)
779 0 0 if (@_ == 2)
780 0 0 if ($priv_key =~ /^(?:0x)?([A-F0-9]+)$/i) { }
781 0 0 length($1) % 2 ? :
782 0 0 unless (defined $this->_priv_key_validate)
799 2 0 if (@_ == 2)
800 0 2 if ($priv_password eq '')
828 0 2 if (@_ < 2)
832 0 2 if ($proto eq '')
839 2 16 if ($proto =~ /^$_$/i)
845 0 2 unless (defined $priv_proto)
853 0 2 if ($priv_proto eq PRIV_PROTOCOL_AESCFB128() or $priv_proto eq PRIV_PROTOCOL_DRAFT_AESCFB192() or $priv_proto eq PRIV_PROTOCOL_DRAFT_AESCFB256())
857 0 0 if (defined(my $error = load_module('Crypt::Rijndael')))
871 0 2 $_[0]{'_synchronized'} ? :
878 0 0 unless $$this{'_synchronized'}
882 0 0 if ($$this{'_engine_time'} > 2147483647)
884 0 0 if (++$$this{'_engine_boots'} == 2147483647)
889 0 0 unless ($$this{'_authoritative'})
895 0 0 if ($$this{'_engine_time'} < 0)
910 0 6 if ($$this{'_user_name'} eq '')
916 2 4 if (defined $$this{'_auth_password'} and $$this{'_discovered'})
917 2 0 unless (defined $$this{'_auth_key'})
918 0 2 unless defined $this->_auth_key_generate
923 4 2 if (defined $$this{'_auth_key'})
926 0 4 unless (defined $this->_auth_key_validate)
931 0 4 unless (defined $this->_auth_data_init)
935 4 0 if ($$this{'_discovered'})
943 0 2 unless (defined $$this{'_auth_key'} or defined $$this{'_auth_password'})
944 0 0 if (defined $$this{'_priv_key'} or defined $$this{'_priv_password'})
953 2 4 if (defined $$this{'_priv_password'} and $$this{'_discovered'})
954 2 0 unless (defined $$this{'_priv_key'})
955 0 2 unless defined $this->_priv_key_generate
960 4 2 if (defined $$this{'_priv_key'})
963 0 4 unless (defined $this->_priv_key_validate)
968 0 4 unless (defined $this->_priv_data_init)
972 4 0 if ($$this{'_discovered'})
987 0 2 if $$this{'_authoritative'}
991 0 2 if (length $engine_id < 5 or length $engine_id > 32)
1001 0 2 unless (defined $this->_security_params)
1013 0 2 if $$this{'_authoritative'}
1014 0 2 if $$this{'_security_level'} < SECURITY_LEVEL_AUTHNOPRIV()
1016 2 0 if ($msg_boots > $this->_engine_boots or $msg_boots == $this->_engine_boots and $msg_time > $$this{'_latest_engine_time'})
1028 2 0 unless ($$this{'_synchronized'})
1030 0 2 unless (defined $this->_security_params)
1052 0 0 if $$this{'_security_level'} < SECURITY_LEVEL_AUTHNOPRIV()
1061 0 0 if ($engine_boots == 2147483647)
1066 0 0 if (not $$this{'_authoritative'}) { }
1068 0 0 if ($msg_boots < $engine_boots)
1071 0 0 if ($msg_boots == $engine_boots and $msg_time < $engine_time - 150)
1077 0 0 if ($msg_boots != $engine_boots)
1080 0 0 if ($msg_time < $engine_time - 150 or $msg_time > $engine_time + 150)
1095 0 0 unless ($auth_location)
1112 0 0 if ($auth_params ne $this->_auth_hmac($msg))
1125 0 4 unless defined $$this{'_auth_data'} and defined $msg
1135 0 4 unless (defined $$this{'_auth_key'})
1139 2 2 if defined $$this{'_auth_data'}
1141 1 1 if ($$this{'_auth_protocol'} eq AUTH_PROTOCOL_HMACMD5()) { }
1 0 elsif ($$this{'_auth_protocol'} eq AUTH_PROTOCOL_HMACSHA()) { }
1176 0 2 unless (exists $$encrypt{$_[0]{'_priv_protocol'}})
1180 0 2 unless (defined $_[1]->prepare(OCTET_STRING(), $_[0]->${\$$encrypt{$_[0]{'_priv_protocol'}};}($_[2], $_[3])))
1210 0 2 unless (defined $_[3])
1214 0 2 unless (exists $$decrypt{$_[0]{'_priv_protocol'}})
1222 0 2 unless (defined $_[1]->prepend($_[0]->${\$$decrypt{$_[0]{'_priv_protocol'}};}($_[2], $_[3])))
1230 0 2 unless $_[1]->length
1236 0 2 if (not defined $msglen or $msglen > $_[1]->length)
1251 0 4 unless (defined $$this{'_priv_key'})
1255 2 2 if defined $$this{'_priv_data'}
1266 0 2 unless (exists $$init{$$this{'_priv_protocol'}})
1279 0 2 unless (defined $$this{'_priv_key'})
1300 0 2 unless (defined $_[0]{'_priv_data'})
1314 0 2 if ($_[0]{'_priv_data'}{'salt'}++ == 18446744073709551615)
1336 0 2 unless (defined $_[0]{'_priv_data'})
1340 0 2 if (length $_[1] != 8)
1346 0 2 if (length($_[2]) % 8)
1370 0 0 unless (defined $$this{'_priv_key'})
1391 0 0 if ($$this{'_auth_protocol'} eq AUTH_PROTOCOL_HMACMD5()) { }
0 0 elsif ($$this{'_auth_protocol'} eq AUTH_PROTOCOL_HMACSHA()) { }
1404 0 0 unless (defined $_[0]{'_priv_data'})
1413 0 0 if ($_[0]{'_priv_data'}{'salt'}++ == 18446744073709551615)
1422 0 0 if (exists $_[0]{'_priv_data'}{'hash'})
1448 0 0 unless (defined $_[0]{'_priv_data'})
1452 0 0 if (length $_[1] != 8)
1458 0 0 if (length($_[2]) % 8)
1487 0 0 unless (defined $$this{'_priv_key'})
1512 0 0 unless (defined $_[0]{'_priv_data'})
1518 0 0 if ($length <= 16)
1525 0 0 if ($_[0]{'_priv_data'}{'salt1'}++ == 18446744073709551615)
1527 0 0 if ($_[0]{'_priv_data'}{'salt2'}++ == 18446744073709551615)
1564 0 0 unless (defined $_[0]{'_priv_data'})
1573 0 0 if (length $_[1] != 16)
1581 0 0 if ($length <= 16)
1613 0 2 unless (defined $$this{'_engine_id'} and defined $$this{'_auth_password'})
1632 0 4 unless (exists $$key_len{$$this{'_auth_protocol'}})
1638 0 4 if (length $$this{'_auth_key'} != $$key_len{$$this{'_auth_protocol'}}[0])
1654 0 2 unless (defined $$this{'_engine_id'} and defined $$this{'_priv_password'})
1660 0 2 unless defined $$this{'_priv_key'}
1662 0 2 if ($$this{'_priv_protocol'} eq PRIV_PROTOCOL_DRAFT_3DESEDE()) { }
0 2 elsif ($$this{'_priv_protocol'} eq PRIV_PROTOCOL_DRAFT_AESCFB192() or $$this{'_priv_protocol'} eq PRIV_PROTOCOL_DRAFT_AESCFB256()) { }
1681 0 0 if ($$this{'_auth_protocol'} eq AUTH_PROTOCOL_HMACMD5()) { }
0 0 elsif ($$this{'_auth_protocol'} eq AUTH_PROTOCOL_HMACSHA()) { }
1706 0 2 unless (exists $$key_len{$$this{'_priv_protocol'}})
1731 0 4 unless (exists $$key_len{$$this{'_priv_protocol'}})
1737 0 4 if (length $$this{'_priv_key'} != $$key_len{$$this{'_priv_protocol'}}[0])
1746 0 4 if ($$this{'_priv_protocol'} eq PRIV_PROTOCOL_DRAFT_3DESEDE())
1753 0 0 if (substr($$this{'_priv_key'}, 0, 8) eq substr($$this{'_priv_key'}, 8, 8))
1760 0 0 if (substr($$this{'_priv_key'}, 8, 8) eq substr($$this{'_priv_key'}, 16, 8))
1767 0 0 if (substr($$this{'_priv_key'}, 0, 8) eq substr($$this{'_priv_key'}, 16, 8))
1789 0 4 unless (exists $$digests{$$this{'_auth_protocol'}})
1829 0 0 if exists $modules{$module}
1831 0 0 if (not eval "require $module") { }
1832 0 0 if ($@ =~ /locate (\S+\.pm)/) { }