Skip to content

gufo.snmp

Gufo SNMP: The accelerated Python SNMP client library.

Attributes:

Name Type Description
__version__ str

Current version

Aes128Key

Bases: BasePrivKey

AES-128 Key.

Aes192Key

Bases: BasePrivKey

AES-192 Key.

Aes256Key

Bases: BasePrivKey

AES-256 Key.

BaseAuthKey

Bases: BaseKey

Authentication key base class.

BasePrivKey

Bases: BaseKey

Privacy key base class.

DesKey

Bases: BasePrivKey

Des Key.

KeyExpansion

Bases: IntEnum

Key expansion policy for AES-192/256 privacy keys.

Specifies how a localized authentication key is expanded when it is shorter than the key required by AES-192 or AES-256. This is relevant primarily for MD5 and SHA-1 authentication, whose localized keys are shorter than the required AES key.

Different SNMP implementations use different expansion schemes:

  • Blumenthal — Blumenthal AES-192/256 key expansion.
  • Cisco — Cisco/Reeder AES-192/256 key expansion.

The policy has no effect when the localized key is already long enough or when a different privacy protocol is used.

Attributes:

Name Type Description
Blumenthal

Use the Blumenthal key-expansion scheme.

Cisco

Use the Cisco/Reeder key-expansion scheme.

Md5Key

Bases: BaseAuthKey

MD5 Key.

Sha1Key

Bases: BaseAuthKey

SHA-1 Key.

Sha224Key

Bases: BaseAuthKey

SHA-224 Key.

Sha256Key

Bases: BaseAuthKey

SHA-256 Key.

Sha384Key

Bases: BaseAuthKey

SHA-384 Key.

Sha512Key

Bases: BaseAuthKey

SHA-512 Key.

SnmpVersion

Bases: IntEnum

SNMP protocol version.

User

SNMPv3 user.

Parameters:

Name Type Description Default
name str

user name.

required
auth_key BaseAuthKey | None

Optional authentication key.

None
priv_key BasePrivKey | None

Optional privacy key.

None
key_expansion KeyExpansion

Key expansion policy for AES-192/256 privacy keys.

Blumenthal

snmpd_create_user property

CreateUser part of snmpd.conf.

Returns:

Type Description
str

createUser configuration directive.

snmpd_rouser property

rouser part of snmpd.conf.

Returns:

Type Description
str

rouser configuration directive.

__repr__()

repr() implementation.

__str__()

str() implementation.

default() classmethod

Default user without name and keys.

Returns:

Type Description
User

Default user instance.

get_auth_alg()

Return the authentication algorithm index with the key type mask.

When the privacy key requires more key material than the authentication algorithm provides, the configured key expansion policy is encoded into the algorithm index.

Algorithm indexes:

  • 0 - No auth
  • 1 - MD5
  • 2 - MD5 with Blumenthal key expansion
  • 3 - MD5 with Cisco key expansion
  • 4 - SHA-1
  • 5 - SHA-1 with Blumenthal key expansion
  • 6 - SHA-1 with Cisco key expansion

The expansion policy only affects algorithms whose key is shorter than the selected privacy key.

Returns: Authentication algorithm index with the key type mask applied.

get_auth_key()

Authentication key.

get_priv_alg()

Privacy algorithm index.

Algorithms
  • 0 - No privacy
  • 1 - DES
  • 2 - AES-128
  • 3 - AES-192
  • 4 - AES-256

KeyType.mask applied

get_priv_key()

Privacy key.

require_auth()

Chech if user requires authentication.

Returns:

Type Description
bool

True, if user requires authetication