gufo.snmp.user¶
User structure definition.
Aes128Key
¶
Aes192Key
¶
Aes256Key
¶
BaseKey
¶
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.
DesKey
¶
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. |
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. |
Md5Key
¶
Sha1Key
¶
Sha224Key
¶
Sha256Key
¶
Sha384Key
¶
Sha512Key
¶
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
¶
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 |