pub struct UsmConfig {
pub username: Bytes,
pub auth: Option<(AuthProtocol, Vec<u8>)>,
pub privacy: Option<(PrivProtocol, Vec<u8>)>,
pub master_keys: Option<MasterKeys>,
}Expand description
USM user credentials for SNMPv3 authentication.
Stores the credentials needed for authenticated and/or encrypted communication. Keys are derived when the engine ID is discovered.
§Master Key Caching
When polling 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 UsmConfig
impl UsmConfig
Sourcepub fn new(username: impl Into<Bytes>) -> Self
pub fn new(username: impl Into<Bytes>) -> Self
Create a new USM config with just a username (noAuthNoPriv).
Sourcepub fn auth(self, protocol: AuthProtocol, password: impl AsRef<[u8]>) -> Self
pub fn auth(self, protocol: AuthProtocol, password: impl AsRef<[u8]>) -> Self
Add authentication (authNoPriv or authPriv).
Sourcepub fn privacy(self, protocol: PrivProtocol, password: impl AsRef<[u8]>) -> Self
pub fn privacy(self, protocol: PrivProtocol, password: impl AsRef<[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 ~850us 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]) -> DerivedKeys
pub fn derive_keys(&self, engine_id: &[u8]) -> DerivedKeys
Derive localized keys for a specific engine ID.
If master keys are configured, uses the cached master keys for efficient localization (~1us). Otherwise, performs full password-to-key derivation (~850us for SHA-256).