/rust/registry/src/github.com-1ecc6299db9ec823/snmp-parser-0.6.0/src/usm.rs
Line | Count | Source (jump to first uncovered line) |
1 | | //! RFC2274 - User-based Security Model (USM) for version 3 of the Simple Network Management Protocol (SNMPv3) |
2 | | |
3 | | use crate::snmp::{parse_ber_octetstring_as_slice}; |
4 | | use der_parser::ber::{parse_ber_u32, BerTag}; |
5 | | use der_parser::error::BerError; |
6 | | use nom::IResult; |
7 | | use std::str; |
8 | | |
9 | 0 | #[derive(Debug, PartialEq)] Unexecuted instantiation: <snmp_parser::usm::UsmSecurityParameters as core::cmp::PartialEq>::eq Unexecuted instantiation: <snmp_parser::usm::UsmSecurityParameters as core::cmp::PartialEq>::ne |
10 | | pub struct UsmSecurityParameters<'a> { |
11 | | pub msg_authoritative_engine_id: &'a[u8], |
12 | | pub msg_authoritative_engine_boots: u32, |
13 | | pub msg_authoritative_engine_time: u32, |
14 | | pub msg_user_name: String, |
15 | | pub msg_authentication_parameters: &'a[u8], |
16 | | pub msg_privacy_parameters: &'a[u8], |
17 | | } |
18 | | |
19 | 9.02k | pub fn parse_usm_security_parameters(i:&[u8]) -> IResult<&[u8], UsmSecurityParameters, BerError> { |
20 | 9.02k | parse_der_struct!( |
21 | 15.5k | i, |
22 | 15.5k | TAG BerTag::Sequence, snmp_parser::usm::parse_usm_security_parameters::{closure#1} Line | Count | Source | 20 | 8.92k | parse_der_struct!( | 21 | | i, | 22 | 8.91k | TAG BerTag::Sequence, |
|
23 | 15.5k | eng_id: parse_ber_octetstring_as_slice >> |
24 | 15.5k | eng_b: parse_ber_u32 >> |
25 | 15.5k | eng_t: parse_ber_u32 >> |
26 | 15.5k | user: map_res!( |
27 | 15.5k | parse_ber_octetstring_as_slice, |
28 | 15.5k | str::from_utf8 |
29 | 15.5k | ) >> |
30 | 15.5k | auth_p: parse_ber_octetstring_as_slice >> |
31 | 15.5k | priv_p: parse_ber_octetstring_as_slice >> |
32 | 15.5k | ( |
33 | 15.5k | UsmSecurityParameters{ |
34 | 15.5k | msg_authoritative_engine_id: eng_id, |
35 | 15.5k | msg_authoritative_engine_boots: eng_b, |
36 | 15.5k | msg_authoritative_engine_time: eng_t, |
37 | 15.5k | msg_user_name: user.to_string(), |
38 | 15.5k | msg_authentication_parameters: auth_p, |
39 | 15.5k | msg_privacy_parameters: priv_p, |
40 | 15.5k | } |
41 | 15.5k | ) |
42 | 15.5k | ).map(|(rem,x)| (rem,x.1)) snmp_parser::usm::parse_usm_security_parameters::{closure#3} Line | Count | Source | 20 | 7.72k | parse_der_struct!( | 21 | 7.72k | i, | 22 | 7.72k | TAG BerTag::Sequence, | 23 | 7.72k | eng_id: parse_ber_octetstring_as_slice >> | 24 | 7.72k | eng_b: parse_ber_u32 >> | 25 | 7.72k | eng_t: parse_ber_u32 >> | 26 | 7.72k | user: map_res!( | 27 | 7.72k | parse_ber_octetstring_as_slice, | 28 | 7.72k | str::from_utf8 | 29 | 7.72k | ) >> | 30 | 7.72k | auth_p: parse_ber_octetstring_as_slice >> | 31 | 7.72k | priv_p: parse_ber_octetstring_as_slice >> | 32 | 7.72k | ( | 33 | 7.72k | UsmSecurityParameters{ | 34 | 7.72k | msg_authoritative_engine_id: eng_id, | 35 | 7.72k | msg_authoritative_engine_boots: eng_b, | 36 | 7.72k | msg_authoritative_engine_time: eng_t, | 37 | 7.72k | msg_user_name: user.to_string(), | 38 | 7.72k | msg_authentication_parameters: auth_p, | 39 | 7.72k | msg_privacy_parameters: priv_p, | 40 | 7.72k | } | 41 | 7.72k | ) | 42 | 7.72k | ).map(|(rem,x)| (rem,x.1)) |
snmp_parser::usm::parse_usm_security_parameters::{closure#2} Line | Count | Source | 20 | 7.78k | parse_der_struct!( | 21 | 7.78k | i, | 22 | 7.78k | TAG BerTag::Sequence, | 23 | 7.78k | eng_id: parse_ber_octetstring_as_slice >> | 24 | 7.78k | eng_b: parse_ber_u32 >> | 25 | 7.78k | eng_t: parse_ber_u32 >> | 26 | 7.78k | user: map_res!( | 27 | 7.78k | parse_ber_octetstring_as_slice, | 28 | 7.78k | str::from_utf8 | 29 | 7.78k | ) >> | 30 | 7.78k | auth_p: parse_ber_octetstring_as_slice >> | 31 | 7.78k | priv_p: parse_ber_octetstring_as_slice >> | 32 | 7.78k | ( | 33 | 7.78k | UsmSecurityParameters{ | 34 | 7.78k | msg_authoritative_engine_id: eng_id, | 35 | 7.78k | msg_authoritative_engine_boots: eng_b, | 36 | 7.78k | msg_authoritative_engine_time: eng_t, | 37 | 7.78k | msg_user_name: user.to_string(), | 38 | 7.78k | msg_authentication_parameters: auth_p, | 39 | 7.78k | msg_privacy_parameters: priv_p, | 40 | 7.78k | } | 41 | 7.78k | ) | 42 | 7.78k | ).map(|(rem,x)| (rem,x.1)) |
|
43 | 9.02k | } |