From 51a461b20653082810ddb9a54be510116a4838a0 Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Mon, 5 Aug 2019 21:28:57 +0200 Subject: Expose USM_* constants to `hlapi` top-level scope --- pysnmp/hlapi/v3arch/__init__.py | 86 ++++++++++++++++++++++++++++------------- pysnmp/hlapi/v3arch/auth.py | 77 +++++++++++++++++++++--------------- 2 files changed, 104 insertions(+), 59 deletions(-) (limited to 'pysnmp') 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 `_)""" +USM_PRIV_CBC168_3DES = auth.USM_PRIV_CBC168_3DES +"""The 3DES-EDE Symmetric Encryption Protocol (`draft-reeder-snmpv3-usm-3desede-00 \ +`_)""" -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 `_) 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 \ +`_) with \ +Reeder key localization""" -usmAesCfb256Protocol = auth.usmAesCfb256Protocol -"""The CFB128-AES-256 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 `_) 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 \ +`_) with \ +Reeder key localization""" -usmAesBlumenthalCfb192Protocol = auth.usmAesBlumenthalCfb192Protocol -"""The CFB128-AES-192 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 `_)""" +USM_PRIV_CFB192_AES_BLUMENTHAL = auth.USM_PRIV_CFB192_AES_BLUMENTHAL +"""The CFB128-AES-192 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 \ +`_)""" -usmAesBlumenthalCfb256Protocol = auth.usmAesBlumenthalCfb256Protocol -"""The CFB128-AES-256 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 `_)""" +USM_PRIV_CFB256_AES_BLUMENTHAL = auth.USM_PRIV_CFB256_AES_BLUMENTHAL +"""The CFB128-AES-256 Symmetric Encryption Protocol (`draft-blumenthal-aes-usm-04 \ +`_)""" -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 -- cgit v1.2.1