Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SHA-2 authentication protocols #112

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions snimpy/snmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def __init__(self, host,
:param secname: Security name to use for SNMPv3 only.
:type secname: str
:param authprotocol: Authorization protocol to use for
SNMPv3. This can be `None` or either the string `SHA` or
`MD5`.
SNMPv3. This can be `None` or one of the strings `SHA`,
`MD5`, `SHA224`, `SHA256`, `SHA384` or `SHA512`.
:type authprotocol: None or str
:param authpassword: Authorization password if authorization
protocol is not `None`.
Expand Down Expand Up @@ -154,7 +154,11 @@ def __init__(self, host,
None: cmdgen.usmNoAuthProtocol,
"MD5": cmdgen.usmHMACMD5AuthProtocol,
"SHA": cmdgen.usmHMACSHAAuthProtocol,
"SHA1": cmdgen.usmHMACSHAAuthProtocol
"SHA1": cmdgen.usmHMACSHAAuthProtocol,
"SHA224": cmdgen.usmHMAC128SHA224AuthProtocol,
"SHA256": cmdgen.usmHMAC192SHA256AuthProtocol,
"SHA384": cmdgen.usmHMAC256SHA384AuthProtocol,
"SHA512": cmdgen.usmHMAC384SHA512AuthProtocol,
}[authprotocol]
except KeyError:
raise ValueError("{} is not an acceptable authentication "
Expand Down
2 changes: 1 addition & 1 deletion tests/test_snmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def testSnmpV3(self):

def testSnmpV3Protocols(self):
"""Check accepted auth and privacy protocols"""
for auth in ["MD5", "SHA"]:
for auth in ["MD5", "SHA", "SHA224", "SHA256", "SHA384", "SHA512"]:
for priv in ["AES", "AES128", "DES"]:
snmp.Session(host="localhost",
version=3,
Expand Down