Skip to content

gufo.snmp.user

User structure definition.

Aes128Key

Bases: BasePrivKey

AES-128 Key.

BaseAuthKey

Bases: BaseKey

Authentication key base class.

BaseKey

Bases: object

Basic key class.

Parameters:

Name Type Description Default
key bytes

Key value.

required
key_type KeyType

Key type.

Password

get_localized_key(master_key, engine_id) classmethod

Convert master key to localized key.

Parameters:

Name Type Description Default
master_key bytes

Master key, must have size according to algorithm.

required
engine_id bytes

SNMP engine id.

required

Returns:

Type Description
bytes

Localized key. Resulting length same as master_key.

get_master_key(passwd) classmethod

Convert password to master key.

Parameters:

Name Type Description Default
passwd bytes

Password

required

Returns:

Type Description
bytes

Master key. Resulting length depends on the algorithm.

snmpd_key()

Returns key and prefix for createUser.

BasePrivKey

Bases: BaseKey

Privacy key base class.

DesKey

Bases: BasePrivKey

Des Key.

KeyType

Bases: IntEnum

Key type.

Attributes:

Name Type Description
Password

Raw password (least security).

Master

Master key (hashed password).

Localized

Localized key, mixed with engine id.

is_localized: bool property

Check if key type is localized.

is_master: bool property

Check if key type is a master.

is_password: bool property

Check if key type is a password.

snmpd_option()

Get key option for snmpd.conf.

Returns:

Type Description
str

Key type prefix like -m, -l, ...

Md5Key

Bases: BaseAuthKey

MD5 Key.

Sha1Key

Bases: BaseAuthKey

SHA-1 Key.

User

Bases: object

SNMPv3 user.

Parameters:

Name Type Description Default
name str

user name.

required
auth_key Optional[BaseAuthKey]

Optional authentication key.

None
priv_key Optional[BasePrivKey]

Optional privacy key.

None

snmpd_create_user: str property

createUser part of snmpd.conf.

Returns:

Type Description
str

createUser configuration directive.

snmpd_rouser: str property

rouser part of snmpd.conf.

Returns:

Type Description
str

rouser configuration directive.

default() classmethod

Default user without name and keys.

Returns:

Type Description
User

Default user instance.

get_auth_alg()

Auth algorithm index with key type mask.

Algorithms
  • 0 - No auth
  • 1 - MD5
  • 2 - SHA1

KeyType.mask applied

get_auth_key()

Authentication key.

get_priv_alg()

Privacy algorithm index.

Algorithms
  • 0 - No privacy
  • 1 - DES
  • 2 - AES-128

KeyType.mask applied

get_priv_key()

Privacy key.

require_auth()

Chech if user requires authentication.

Returns:

Type Description
bool

True, if user requires authetication