summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2019-08-04 12:40:02 +0200
committerIlya Etingof <etingof@gmail.com>2019-08-04 12:40:02 +0200
commit6066897cd142b6954fa9f643780e4e488a8369a5 (patch)
treeaa5d0cf9d63c167c35821b30eb59174b0f24acf1
parent060428091bd7ecebb0be293252071c8654184c5f (diff)
downloadpysnmp-git-6066897cd142b6954fa9f643780e4e488a8369a5.tar.gz
Fix USM configuration for the case of partial keys
-rw-r--r--pysnmp/entity/config.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/pysnmp/entity/config.py b/pysnmp/entity/config.py
index 5c5b5c8b..4ff5895e 100644
--- a/pysnmp/entity/config.py
+++ b/pysnmp/entity/config.py
@@ -199,7 +199,9 @@ def addV3User(snmpEngine, userName,
# Localize authentication key unless given
- masterAuthKey = localAuthKey = authKey = rfc1902.OctetString(authKey or null)
+ authKey = authKey and rfc1902.OctetString(authKey)
+
+ masterAuthKey = localAuthKey = authKey
if authKeyType < usmKeyTypeMaster: # pass phrase is given
masterAuthKey = authServices[authProtocol].hashPassphrase(
@@ -215,7 +217,9 @@ def addV3User(snmpEngine, userName,
privKeyType = pysnmpUsmKeyType.syntax.clone(privKeyType)
- masterPrivKey = localPrivKey = privKey = rfc1902.OctetString(privKey or null)
+ privKey = privKey and rfc1902.OctetString(privKey)
+
+ masterPrivKey = localPrivKey = privKey
if privKeyType < usmKeyTypeMaster: # pass phrase is given
masterPrivKey = privServices[privProtocol].hashPassphrase(
@@ -277,14 +281,14 @@ def addV3User(snmpEngine, userName,
'privKey "%s" by index securityName "%s" securityEngineId '
'"%s"' % (
userName, securityName, authProtocol, privProtocol,
- localAuthKey.prettyPrint(),
- localPrivKey.prettyPrint(),
- masterAuthKey.prettyPrint(),
- masterPrivKey.prettyPrint(),
- authKey.prettyPrint(),
- privKey.prettyPrint(),
+ localAuthKey and localAuthKey.prettyPrint(),
+ localPrivKey and localPrivKey.prettyPrint(),
+ masterAuthKey and masterAuthKey.prettyPrint(),
+ masterPrivKey and masterPrivKey.prettyPrint(),
+ authKey and authKey.prettyPrint(),
+ privKey and privKey.prettyPrint(),
securityName,
- securityEngineId and securityEngineId.prettyPrint()))
+ securityEngineId.prettyPrint()))
def delV3User(snmpEngine,