pub struct V3SecurityConfig {
pub username: Bytes,
pub auth: Option<(AuthProtocol, Vec<u8>)>,
pub privacy: Option<(PrivProtocol, Vec<u8>)>,
pub master_keys: Option<MasterKeys>,
}Expand description
SNMPv3 security configuration.
Stores the credentials needed for authenticated and/or encrypted communication. Keys are derived when the engine ID is discovered.
§Master Key Caching
For high-throughput polling of many engines with shared credentials, use
MasterKeys to cache the expensive password-to-key
derivation. When master_keys is set, passwords are ignored and keys are
derived from the cached master keys.
Fields§
§username: BytesUsername for USM authentication
auth: Option<(AuthProtocol, Vec<u8>)>Authentication protocol and password
privacy: Option<(PrivProtocol, Vec<u8>)>Privacy protocol and password
master_keys: Option<MasterKeys>Pre-computed master keys for efficient key derivation
Implementations§
Source§impl V3SecurityConfig
impl V3SecurityConfig
Sourcepub fn new(username: impl Into<Bytes>) -> Self
pub fn new(username: impl Into<Bytes>) -> Self
Create a new V3 security config with just a username (noAuthNoPriv).
Sourcepub fn auth(self, protocol: AuthProtocol, password: impl Into<Vec<u8>>) -> Self
pub fn auth(self, protocol: AuthProtocol, password: impl Into<Vec<u8>>) -> Self
Add authentication (authNoPriv or authPriv).
Sourcepub fn privacy(
self,
protocol: PrivProtocol,
password: impl Into<Vec<u8>>,
) -> Self
pub fn privacy( self, protocol: PrivProtocol, password: impl Into<Vec<u8>>, ) -> Self
Add privacy/encryption (authPriv).
Sourcepub fn with_master_keys(self, master_keys: MasterKeys) -> Self
pub fn with_master_keys(self, master_keys: MasterKeys) -> Self
Use pre-computed master keys for efficient key derivation.
When set, passwords are ignored and keys are derived from the cached master keys. This avoids the expensive ~850μs password expansion for each engine.
Sourcepub fn security_level(&self) -> SecurityLevel
pub fn security_level(&self) -> SecurityLevel
Get the security level based on configured auth/privacy.
Sourcepub fn derive_keys(&self, engine_id: &[u8]) -> V3DerivedKeys
pub fn derive_keys(&self, engine_id: &[u8]) -> V3DerivedKeys
Derive localized keys for a specific engine ID.
If master keys are configured, uses the cached master keys for efficient localization (~1μs). Otherwise, performs full password-to-key derivation (~850μs for SHA-256).
Trait Implementations§
Source§impl Clone for V3SecurityConfig
impl Clone for V3SecurityConfig
Source§fn clone(&self) -> V3SecurityConfig
fn clone(&self) -> V3SecurityConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more