Skip to content

Commit

Permalink
Add five-zero security engine ID for localized keys
Browse files Browse the repository at this point in the history
If the user specifies localized keys, but does not specify security
engine ID (-e), the magic value of 0x0000000000 will be automatically
associated with given localized keys to use them with any unknown
authoritative SNMP engine.
  • Loading branch information
etingof committed Aug 11, 2019
1 parent ab4c7ee commit d1fceec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
15 changes: 12 additions & 3 deletions docs/source/options-protocol-rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ See :RFC:`3414#section-2.6` for more information on key localization algorithm.

.. note::

Using any of *-3[kKMm]* options effectively disable SNMP engine ID
discovery mechanism. Therefore authoritative security SNMP engine ID should
be specified along with *-3[kKMm]* options (via *-e* option).
Using any of *-3[kKMm]* options effectively inactivate USM key
localization mechanism. As a consequence, local SNMP engine configuration
won't get automatically populated with remote SNMP engine's
*securityEngineId*.

Therefore authoritative security SNMP engine ID should be specified
along with *-3[kKMm]* options (via *-e* option).

Otherwise, the magic *securityEngineId* value of five zeros
(*0x0000000000*) will be added to local configuration automatically to
refer to the localized keys that should be used with any unknown
authoritative SNMP engine.
14 changes: 11 additions & 3 deletions snmpclitools/cli/secmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@ def _unhexKey(key):
raise error.PySnmpError('Security level not specified')

if 'securityEngineId' in ctx:
ctx['securityEngineId'] = _unhexKey(ctx['securityEngineId'])
securityEngineId = _unhexKey(ctx['securityEngineId'])

else:
ctx['securityEngineId'] = None
securityEngineId = None

if 'contextEngineId' in ctx:
ctx['contextEngineId'] = _unhexKey(ctx['contextEngineId'])
Expand Down Expand Up @@ -437,6 +437,14 @@ def _unhexKey(key):
else:
privKeyType = config.usmKeyTypePassphrase

if (authKeyType == config.usmKeyTypeLocalized or
privKeyType == config.usmKeyTypeLocalized):
# Wildcard security engine ID assocciating localized keys
# with any authoritative SNMP engine
securityEngineId = rfc1902.OctetString(hexValue='0000000000')

ctx['securityEngineId'] = securityEngineId

if ctx['securityLevel'] == 'noAuthNoPriv':
if 'authKey' in ctx:
del ctx['authKey']
Expand Down Expand Up @@ -471,7 +479,7 @@ def _unhexKey(key):
ctx['authKey'],
ctx['privProtocol'],
ctx['privKey'],
securityEngineId=ctx['securityEngineId'],
securityEngineId=securityEngineId,
securityName=ctx['securityName'],
authKeyType=authKeyType,
privKeyType=privKeyType
Expand Down

0 comments on commit d1fceec

Please sign in to comment.