[SNMP4J] Problem Receicing V3 traps - please help
Scott VanWart
scott.vanwart at Q1Labs.com
Mon Aug 22 02:30:07 CEST 2005
Hello,
I am using SNMP4J to receive V3 traps using MD5 and DES. I am able to
accept the data and I can get up time from the device and the OID, but I
cannot figure out how to decrypt the message being sent by the device.
Below is my code, any suggestions would GREATLY appreciated as I have
been stuck for some days now.
public synchronized void processPdu(CommandResponderEvent e)
{
PDU command = e.getPDU();
Address source = e.getPeerAddress();
e.setProcessed(true);
String payload = "";
VariableBinding varBinding;
Variable var;
int length = command.size();
for(int i = 0; i < length; i++)
{
varBinding =
command.get(i);
var =
varBinding.getVariable();
payload =
var.toString();
// logger.info("SNMP V3
TRAp data:" + payload);
}
byte[] data = new
byte[payload.length()];
byte[] ciphertext = null;
data = payload.getBytes();
byte[] result = null;
try
{
byte[] dec = new
sun.misc.BASE64Decoder().decodeBuffer(payload);
PrivDES des = new
PrivDES();
UsmUserEntry user =
snmp.getUSM().getUser(new OctetString("dragon-admin"), new
OctetString("dragon-admin"));
byte[] key =
user.getAuthenticationKey();
byte[] p = new
byte[des.getDecryptParamsLength()];
DecryptParams params =
new DecryptParams(p,0,des.getDecryptParamsLength());
long enginetime = 0;
long engineboots = 0;
result =
des.decrypt(dec,0,dec.length,key,engineboots,enginetime,params);
Thanks,
Scott
Scott Van Wart
Software Engineer
Direct: 506-462-9117
Email: scott.vanwart at q1labs.com
Q1 Labs Inc - The Nexus of Security and Networking
More information about the SNMP4J
mailing list