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).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for UsmConfig
impl RefUnwindSafe for UsmConfig
impl Send for UsmConfig
impl Sync for UsmConfig
impl Unpin for UsmConfig
impl UnsafeUnpin for UsmConfig
impl UnwindSafe for UsmConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more