Skip to content

Commit 6329de4

Browse files
committed
cosmetic code fixes
1 parent 0aa119f commit 6329de4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pysnmp/proto/secmod/rfc3414/localkey.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
#
77
try:
88
from hashlib import md5, sha1
9+
910
except ImportError:
1011
import md5
1112
import sha
1213

1314
md5 = md5.new
1415
sha1 = sha.new
16+
1517
from pyasn1.type import univ
1618

1719

@@ -37,30 +39,38 @@ def hashPassphrase(passphrase, hashFunc):
3739
count += 1
3840
return hasher.digest()
3941

42+
4043
def passwordToKey(passphrase, snmpEngineId, hashFunc):
4144
return localizeKey(hashPassphrase(passphrase, hashFunc), snmpEngineId, hashFunc)
4245

46+
4347
def localizeKey(passKey, snmpEngineId, hashFunc):
4448
passKey = univ.OctetString(passKey).asOctets()
4549
# noinspection PyDeprecation,PyCallingNonCallable
4650
return hashFunc(passKey + snmpEngineId.asOctets() + passKey).digest()
4751

52+
4853
# RFC3414: A.2.1
4954
def hashPassphraseMD5(passphrase):
5055
return hashPassphrase(passphrase, md5)
5156

57+
5258
# RFC3414: A.2.2
5359
def hashPassphraseSHA(passphrase):
5460
return hashPassphrase(passphrase, sha1)
5561

62+
5663
def passwordToKeyMD5(passphrase, snmpEngineId):
5764
return localizeKey(hashPassphraseMD5(passphrase), snmpEngineId, md5)
5865

66+
5967
def passwordToKeySHA(passphrase, snmpEngineId):
6068
return localizeKey(hashPassphraseMD5(passphrase), snmpEngineId, sha1)
6169

70+
6271
def localizeKeyMD5(passKey, snmpEngineId):
6372
return localizeKey(passKey, snmpEngineId, md5)
6473

74+
6575
def localizeKeySHA(passKey, snmpEngineId):
6676
return localizeKey(passKey, snmpEngineId, sha1)

pysnmp/proto/secmod/rfc7860/auth/hmacsha2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
except ImportError:
1313

14-
class NotAvalable(object):
14+
class NotAvailable(object):
1515
def __call__(self, *args, **kwargs):
1616
raise errind.authenticationError
1717

18-
sha224 = sha256 = sha384 = sha512 = NotAvalable()
18+
sha224 = sha256 = sha384 = sha512 = NotAvailable()
1919

2020
from pyasn1.type import univ
2121
from pysnmp.proto.secmod.rfc3414.auth import base

0 commit comments

Comments
 (0)