summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2019-08-05 21:28:57 +0200
committerIlya Etingof <etingof@gmail.com>2019-08-05 21:28:57 +0200
commit51a461b20653082810ddb9a54be510116a4838a0 (patch)
tree7c69b2b5c880e0b7d09d318ee8f727ba2842e363
parent64310f1e83522943440d674e8f926f9914f23372 (diff)
downloadpysnmp-git-51a461b20653082810ddb9a54be510116a4838a0.tar.gz
Expose USM_* constants to `hlapi` top-level scope
-rw-r--r--CHANGES.txt2
-rw-r--r--pysnmp/hlapi/v3arch/__init__.py86
-rw-r--r--pysnmp/hlapi/v3arch/auth.py77
3 files changed, 105 insertions, 60 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 0813d057..70194834 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -37,7 +37,7 @@ Revision 5.0.0, released 2019-08-XX
and deliver their results via a call back.
* The `readNext*` methods of the `SNMPv2-SMI` MIB objects redesigned
- to return the very next obejct even if it is not readable. In this
+ to return the very next object even if it is not readable. In this
case the `noSuchObject` or `noSuchInstance` SNMP exception values
are returned. The motivation is to avoid deep stack recursion on
MIB walk. The caller is expected to watch these SNMP sentinels
diff --git a/pysnmp/hlapi/v3arch/__init__.py b/pysnmp/hlapi/v3arch/__init__.py
index 901c488e..cce578f6 100644
--- a/pysnmp/hlapi/v3arch/__init__.py
+++ b/pysnmp/hlapi/v3arch/__init__.py
@@ -16,56 +16,88 @@ from pysnmp.entity.engine import *
# default is synchronous asyncore-based API
from pysnmp.hlapi.v3arch.asyncore.sync import *
-usmNoAuthProtocol = auth.usmNoAuthProtocol
+USM_AUTH_NONE = auth.USM_AUTH_NONE
"""No Authentication Protocol"""
-usmHMACMD5AuthProtocol = auth.usmHMACMD5AuthProtocol
+USM_AUTH_HMAC96_MD5 = auth.USM_AUTH_HMAC96_MD5
"""The HMAC-MD5-96 Digest Authentication Protocol (:RFC:`3414#section-6`)"""
-usmHMACSHAAuthProtocol = auth.usmHMACSHAAuthProtocol
-"""The HMAC-SHA-96 Digest Authentication Protocol AKA SHA-1 (:RFC:`3414#section-7`)"""
+USM_AUTH_HMAC96_SHA = auth.USM_AUTH_HMAC96_SHA
+"""The HMAC-SHA-96 Digest Authentication Protocol AKA SHA-1 \
+(:RFC:`3414#section-7`)"""
-usmHMAC128SHA224AuthProtocol = auth.usmHMAC128SHA224AuthProtocol
+USM_AUTH_HMAC128_SHA224 = auth.USM_AUTH_HMAC128_SHA224
"""The HMAC-SHA-2 Digest Authentication Protocols (:RFC:`7860`)"""
-usmHMAC192SHA256AuthProtocol = auth.usmHMAC192SHA256AuthProtocol
+USM_AUTH_HMAC192_SHA256 = auth.USM_AUTH_HMAC192_SHA256
"""The HMAC-SHA-2 Digest Authentication Protocols (:RFC:`7860`)"""
-usmHMAC256SHA384AuthProtocol = auth.usmHMAC256SHA384AuthProtocol
+USM_AUTH_HMAC256_SHA384 = auth.USM_AUTH_HMAC256_SHA384
"""The HMAC-SHA-2 Digest Authentication Protocols (:RFC:`7860`)"""
-usmHMAC384SHA512AuthProtocol = auth.usmHMAC384SHA512AuthProtocol
+USM_AUTH_HMAC384_SHA512 = auth.USM_AUTH_HMAC384_SHA512
"""The HMAC-SHA-2 Digest Authentication Protocols (:RFC:`7860`)"""
-usmNoPrivProtocol = auth.usmNoPrivProtocol
+USM_PRIV_NONE = auth.USM_PRIV_NONE
"""No Privacy Protocol"""
-usmDESPrivProtocol = auth.usmDESPrivProtocol
+USM_PRIV_CBC56_DES = auth.USM_PRIV_CBC56_DES
"""The CBC-DES Symmetric Encryption Protocol (:RFC:`3414#section-8`)"""
-usm3DESEDEPrivProtocol = auth.usm3DESEDEPrivProtocol
-"""The 3DES-EDE Symmetric Encryption Protocol (`draft-reeder-snmpv3-usm-3desede-00 <https:://tools.ietf.org/html/draft-reeder-snmpv3-usm-3desede-00#section-5>`_)"""
+USM_PRIV_CBC168_3DES = auth.USM_PRIV_CBC168_3DES
+"""The 3DES-EDE Symmetric Encryption Protocol (`draft-reeder-snmpv3-usm-3desede-00 \
+<https:://tools.ietf.org/html/draft-reeder-snmpv3-usm-3desede-00#section-5>`_)"""
-usmAesCfb128Protocol = auth.usmAesCfb128Protocol
+USM_PRIV_CFB128_AES = auth.USM_PRIV_CFB128_AES
"""The CFB128-AES-128 Symmetric Encryption Protocol (:RFC:`3826#section-3`)"""
-usmAesCfb192Protocol = auth.usmAesCfb192Protocol
-"""The CFB128-AES-192 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 <https:://tools.ietf.org/html/draft-blumenthal-aes-usm-04#section-3>`_) with Reeder key localization"""
+USM_PRIV_CFB192_AES = auth.USM_PRIV_CFB192_AES
+"""The CFB128-AES-192 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 \
+<https:://tools.ietf.org/html/draft-blumenthal-aes-usm-04#section-3>`_) with \
+Reeder key localization"""
-usmAesCfb256Protocol = auth.usmAesCfb256Protocol
-"""The CFB128-AES-256 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 <https:://tools.ietf.org/html/draft-blumenthal-aes-usm-04#section-3>`_) with Reeder key localization"""
+USM_PRIV_CFB256_AES = auth.USM_PRIV_CFB256_AES
+"""The CFB128-AES-256 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 \
+<https:://tools.ietf.org/html/draft-blumenthal-aes-usm-04#section-3>`_) with \
+Reeder key localization"""
-usmAesBlumenthalCfb192Protocol = auth.usmAesBlumenthalCfb192Protocol
-"""The CFB128-AES-192 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 <https:://tools.ietf.org/html/draft-blumenthal-aes-usm-04#section-3>`_)"""
+USM_PRIV_CFB192_AES_BLUMENTHAL = auth.USM_PRIV_CFB192_AES_BLUMENTHAL
+"""The CFB128-AES-192 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 \
+<https:://tools.ietf.org/html/draft-blumenthal-aes-usm-04#section-3>`_)"""
-usmAesBlumenthalCfb256Protocol = auth.usmAesBlumenthalCfb256Protocol
-"""The CFB128-AES-256 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 <https:://tools.ietf.org/html/draft-blumenthal-aes-usm-04#section-3>`_)"""
+USM_PRIV_CFB256_AES_BLUMENTHAL = auth.USM_PRIV_CFB256_AES_BLUMENTHAL
+"""The CFB128-AES-256 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 \
+<https:://tools.ietf.org/html/draft-blumenthal-aes-usm-04#section-3>`_)"""
-usmKeyTypePassphrase = auth.usmKeyTypePassphrase
+USM_KEY_TYPE_PASSPHRASE = auth.USM_KEY_TYPE_PASSPHRASE
"""USM key material type - plain-text pass phrase (:RFC:`3414#section-2.6`)"""
-usmKeyTypeMaster = auth.usmKeyTypeMaster
-"""USM key material type - hashed pass-phrase AKA master key (:RFC:`3414#section-2.6`)"""
-
-usmKeyTypeLocalized = auth.usmKeyTypeLocalized
-"""USM key material type - hashed pass-phrase hashed with Context SNMP Engine ID (:RFC:`3414#section-2.6`)"""
+USM_KEY_TYPE_MASTER = auth.USM_KEY_TYPE_MASTER
+"""USM key material type - hashed pass-phrase AKA master key \
+(:RFC:`3414#section-2.6`)"""
+
+USM_KEY_TYPE_LOCALIZED = auth.USM_KEY_TYPE_LOCALIZED
+"""USM key material type - hashed pass-phrase hashed with Context SNMP Engine \
+ID (:RFC:`3414#section-2.6`)"""
+
+# Backward-compatible protocol IDs
+
+usmNoAuthProtocol = USM_AUTH_NONE
+usmHMACMD5AuthProtocol = USM_AUTH_HMAC96_MD5
+usmHMACSHAAuthProtocol = USM_AUTH_HMAC96_SHA
+usmHMAC128SHA224AuthProtocol = USM_AUTH_HMAC128_SHA224
+usmHMAC192SHA256AuthProtocol = USM_AUTH_HMAC192_SHA256
+usmHMAC256SHA384AuthProtocol = USM_AUTH_HMAC256_SHA384
+usmHMAC384SHA512AuthProtocol = USM_AUTH_HMAC384_SHA512
+usmNoPrivProtocol = USM_PRIV_NONE
+usmDESPrivProtocol = USM_PRIV_CBC56_DES
+usm3DESEDEPrivProtocol = USM_PRIV_CBC168_3DES
+usmAesCfb128Protocol = USM_PRIV_CFB128_AES
+usmAesCfb192Protocol = USM_PRIV_CFB192_AES
+usmAesCfb256Protocol = USM_PRIV_CFB256_AES
+usmAesBlumenthalCfb192Protocol = USM_PRIV_CFB192_AES_BLUMENTHAL
+usmAesBlumenthalCfb256Protocol = USM_PRIV_CFB256_AES_BLUMENTHAL
+
+usmKeyTypePassphrase = USM_KEY_TYPE_PASSPHRASE
+usmKeyTypeMaster = USM_KEY_TYPE_MASTER
+usmKeyTypeLocalized = USM_KEY_TYPE_LOCALIZED
diff --git a/pysnmp/hlapi/v3arch/auth.py b/pysnmp/hlapi/v3arch/auth.py
index 16363546..c4302d52 100644
--- a/pysnmp/hlapi/v3arch/auth.py
+++ b/pysnmp/hlapi/v3arch/auth.py
@@ -19,17 +19,7 @@ __all__ = [
'USM_PRIV_CFB128_AES', 'USM_PRIV_CFB192_AES',
'USM_PRIV_CFB256_AES', 'USM_PRIV_CFB192_AES_BLUMENTHAL',
'USM_PRIV_CFB256_AES_BLUMENTHAL', 'USM_KEY_TYPE_PASSPHRASE',
- 'USM_KEY_TYPE_MASTER', 'USM_KEY_TYPE_LOCALIZED',
- # backward-compatible constants
- 'usm3DESEDEPrivProtocol', 'usmAesCfb128Protocol',
- 'usmAesCfb192Protocol', 'usmAesCfb256Protocol',
- 'usmAesBlumenthalCfb192Protocol', 'usmAesBlumenthalCfb256Protocol',
- 'usmDESPrivProtocol', 'usmHMACMD5AuthProtocol',
- 'usmHMACSHAAuthProtocol', 'usmHMAC128SHA224AuthProtocol',
- 'usmHMAC192SHA256AuthProtocol', 'usmHMAC256SHA384AuthProtocol',
- 'usmHMAC384SHA512AuthProtocol', 'usmNoAuthProtocol',
- 'usmNoPrivProtocol', 'usmKeyTypePassphrase', 'usmKeyTypeMaster',
- 'usmKeyTypeLocalized'
+ 'USM_KEY_TYPE_MASTER', 'USM_KEY_TYPE_LOCALIZED'
]
@@ -97,27 +87,6 @@ USM_KEY_TYPE_LOCALIZED = config.USM_KEY_TYPE_LOCALIZED
"""USM key material type - hashed pass-phrase hashed with Context SNMP Engine ID \
(:RFC:`3414#section-2.6`)"""
-# Backward-compatible protocol IDs
-usmNoAuthProtocol = USM_AUTH_NONE
-usmHMACMD5AuthProtocol = USM_AUTH_HMAC96_MD5
-usmHMACSHAAuthProtocol = USM_AUTH_HMAC96_SHA
-usmHMAC128SHA224AuthProtocol = USM_AUTH_HMAC128_SHA224
-usmHMAC192SHA256AuthProtocol = USM_AUTH_HMAC192_SHA256
-usmHMAC256SHA384AuthProtocol = USM_AUTH_HMAC256_SHA384
-usmHMAC384SHA512AuthProtocol = USM_AUTH_HMAC384_SHA512
-usmNoPrivProtocol = USM_PRIV_NONE
-usmDESPrivProtocol = USM_PRIV_CBC56_DES
-usm3DESEDEPrivProtocol = USM_PRIV_CBC168_3DES
-usmAesCfb128Protocol = USM_PRIV_CFB128_AES
-usmAesCfb192Protocol = USM_PRIV_CFB192_AES
-usmAesCfb256Protocol = USM_PRIV_CFB256_AES
-usmAesBlumenthalCfb192Protocol = USM_PRIV_CFB192_AES_BLUMENTHAL
-usmAesBlumenthalCfb256Protocol = USM_PRIV_CFB256_AES_BLUMENTHAL
-
-usmKeyTypePassphrase = USM_KEY_TYPE_PASSPHRASE
-usmKeyTypeMaster = USM_KEY_TYPE_MASTER
-usmKeyTypeLocalized = USM_KEY_TYPE_LOCALIZED
-
class CommunityData(object):
"""Creates SNMP v1/v2c configuration entry.
@@ -468,3 +437,47 @@ class UsmUserData(object):
authKeyType is None and self.authKeyType or USM_KEY_TYPE_PASSPHRASE,
privKeyType is None and self.privKeyType or USM_KEY_TYPE_PASSPHRASE
)
+
+
+# Backward-compatible protocol IDs
+
+usmNoAuthProtocol = USM_AUTH_NONE
+usmHMACMD5AuthProtocol = USM_AUTH_HMAC96_MD5
+usmHMACSHAAuthProtocol = USM_AUTH_HMAC96_SHA
+usmHMAC128SHA224AuthProtocol = USM_AUTH_HMAC128_SHA224
+usmHMAC192SHA256AuthProtocol = USM_AUTH_HMAC192_SHA256
+usmHMAC256SHA384AuthProtocol = USM_AUTH_HMAC256_SHA384
+usmHMAC384SHA512AuthProtocol = USM_AUTH_HMAC384_SHA512
+usmNoPrivProtocol = USM_PRIV_NONE
+usmDESPrivProtocol = USM_PRIV_CBC56_DES
+usm3DESEDEPrivProtocol = USM_PRIV_CBC168_3DES
+usmAesCfb128Protocol = USM_PRIV_CFB128_AES
+usmAesCfb192Protocol = USM_PRIV_CFB192_AES
+usmAesCfb256Protocol = USM_PRIV_CFB256_AES
+usmAesBlumenthalCfb192Protocol = USM_PRIV_CFB192_AES_BLUMENTHAL
+usmAesBlumenthalCfb256Protocol = USM_PRIV_CFB256_AES_BLUMENTHAL
+
+usmKeyTypePassphrase = USM_KEY_TYPE_PASSPHRASE
+usmKeyTypeMaster = USM_KEY_TYPE_MASTER
+usmKeyTypeLocalized = USM_KEY_TYPE_LOCALIZED
+
+__all__.extend(
+ ['usm3DESEDEPrivProtocol',
+ 'usmAesCfb128Protocol',
+ 'usmAesCfb192Protocol',
+ 'usmAesCfb256Protocol',
+ 'usmAesBlumenthalCfb192Protocol',
+ 'usmAesBlumenthalCfb256Protocol',
+ 'usmDESPrivProtocol',
+ 'usmHMACMD5AuthProtocol',
+ 'usmHMACSHAAuthProtocol',
+ 'usmHMAC128SHA224AuthProtocol',
+ 'usmHMAC192SHA256AuthProtocol',
+ 'usmHMAC256SHA384AuthProtocol',
+ 'usmHMAC384SHA512AuthProtocol',
+ 'usmNoAuthProtocol',
+ 'usmNoPrivProtocol',
+ 'usmKeyTypePassphrase',
+ 'usmKeyTypeMaster',
+ 'usmKeyTypeLocalized']
+) \ No newline at end of file