Skip to content

Instantly share code, notes, and snippets.

@alexnavis
Last active May 31, 2017 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexnavis/8eec113cabc47a43a5a6d1eb870352fb to your computer and use it in GitHub Desktop.
Save alexnavis/8eec113cabc47a43a5a6d1eb870352fb to your computer and use it in GitHub Desktop.
SNMP v3 AES not working
:snmp.start()
:crypto.start()
:snmpm.register_user('v3_default_user', :snmpm_user_default, nil, [])
# http://snmpsim.sourceforge.net/public-snmp-simulator.html
# snmpget -v 3 -u "usr-md5-aes" -a MD5 -x AES -X "privkey1" -A "authkey1" -l authPriv demo.snmplabs.com 1.3.6.1.2.1.1.1.0
engine_id = "80004fb805636c6f75644dab22cc" |> Base.decode16!(case: :mixed) |> :binary.bin_to_list
user_name = 'usr-md5-aes'
auth_key = 'authkey1'
priv = 'privkey1'
auth_key = :snmp.passwd2localized_key(:md5, auth_key, engine_id)
priv_key = :snmp.passwd2localized_key(:md5, priv, engine_id)
ip_address = {104,236,166,95}
:snmpm.verbosity(:all, :trace)
:snmpm.register_usm_user(engine_id, user_name, [auth: :usmHMACMD5AuthProtocol, auth_key: auth_key, priv: :usmAesCfb128Protocol, priv_key: priv_key])
:snmpm.register_agent('v3_default_user', 'v3_agent', [engine_id: engine_id, address: ip_address, version: :v3, sec_model: :usm, sec_name: user_name, sec_level: :authPriv ])
# warm - up to sync engineBoot and engineTime for the first to cache the value in SNMPM ets tables
:snmpm.sync_get('v3_default_user', 'v3_agent', [], 2000)
:snmpm.sync_get('v3_default_user', 'v3_agent', [[1,3,6,1,2,1,1,1,0]], 5000)
*** [2017:05:31 07:52:52 7] SNMP M-NET-IF TRACE ***
handle_send_pdu -> message generated
*** [2017:05:31 07:52:52 7] SNMP M-NET-IF DEBUG ***
sent 142 bytes to {104,236,166,95}:161 [#Port<0.19260>]
*** [2017:05:31 07:52:57 7] SNMP M-SERVER LOG ***
received sync_timeout [478027566] message
*** [2017:05:31 07:52:57 7] SNMP M-SERVER TRACE ***
handle_sync_timeout -> entry with
ReqId: 478027566
From: {<0.677.0>,#Ref<0.0.1.3421>}
*** [2017:05:31 07:52:57 7] SNMP M-SERVER DEBUG ***
handle_sync_timeout -> deliver reply (timeout) and demonitor:
Monref: #Ref<0.0.1.3431>
From: {<0.677.0>,#Ref<0.0.1.3421>}
{:error, {:timeout, 478027566}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment