net-snmp 3.7.0 → 3.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/index.js +10 -37
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -3203,6 +3203,10 @@ Example programs are included under the module's `example` directory.
3203
3203
 
3204
3204
  * Add SHA-2 authentication support (SHA-224, SHA-256, SHA-384, SHA-512)
3205
3205
 
3206
+ ## Version 3.7.1 - 05/06/2022
3207
+
3208
+ * Fix DES decrypt corruption issue
3209
+
3206
3210
  # License
3207
3211
 
3208
3212
  Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
package/index.js CHANGED
@@ -879,7 +879,7 @@ var readPdu = function (reader, scoped) {
879
879
  var contextEngineID;
880
880
  var contextName;
881
881
  if ( scoped ) {
882
- reader.readSequence ();
882
+ reader = new ber.Reader (reader.readString (ber.Sequence | ber.Constructor, true));
883
883
  contextEngineID = reader.readString (ber.OctetString, true);
884
884
  contextName = reader.readString ();
885
885
  }
@@ -1051,9 +1051,9 @@ Encryption.encryptPdu = function (privProtocol, scopedPdu, privPassword, authPro
1051
1051
  return encryptFunction (scopedPdu, privProtocol, privPassword, authProtocol, engine);
1052
1052
  };
1053
1053
 
1054
- Encryption.decryptPdu = function (privProtocol, encryptedPdu, privParameters, privPassword, authProtocol, engine, forceAutoPaddingDisable) {
1054
+ Encryption.decryptPdu = function (privProtocol, encryptedPdu, privParameters, privPassword, authProtocol, engine) {
1055
1055
  var decryptFunction = Encryption.algorithms[privProtocol].decryptPdu;
1056
- return decryptFunction (encryptedPdu, privProtocol, privParameters, privPassword, authProtocol, engine, forceAutoPaddingDisable);
1056
+ return decryptFunction (encryptedPdu, privProtocol, privParameters, privPassword, authProtocol, engine);
1057
1057
  };
1058
1058
 
1059
1059
  Encryption.debugEncrypt = function (encryptionKey, iv, plainPdu, encryptedPdu) {
@@ -1179,7 +1179,7 @@ Encryption.encryptPduDes = function (scopedPdu, privProtocol, privPassword, auth
1179
1179
  };
1180
1180
  };
1181
1181
 
1182
- Encryption.decryptPduDes = function (encryptedPdu, privProtocol, privParameters, privPassword, authProtocol, engine, forceAutoPaddingDisable) {
1182
+ Encryption.decryptPduDes = function (encryptedPdu, privProtocol, privParameters, privPassword, authProtocol, engine) {
1183
1183
  var des = Encryption.algorithms[PrivProtocols.des];
1184
1184
  var privLocalizedKey;
1185
1185
  var decryptionKey;
@@ -1203,23 +1203,9 @@ Encryption.decryptPduDes = function (encryptedPdu, privProtocol, privParameters,
1203
1203
  }
1204
1204
 
1205
1205
  decipher = crypto.createDecipheriv (des.CRYPTO_ALGORITHM, decryptionKey, iv);
1206
- if ( forceAutoPaddingDisable ) {
1207
- decipher.setAutoPadding(false);
1208
- }
1206
+ decipher.setAutoPadding(false);
1209
1207
  decryptedPdu = decipher.update (encryptedPdu);
1210
- // This try-catch is a workaround for a seemingly incorrect error condition
1211
- // - where sometimes a decrypt error is thrown with decipher.final()
1212
- // It replaces this line which should have been sufficient:
1213
- // decryptedPdu = Buffer.concat ([decryptedPdu, decipher.final()]);
1214
- try {
1215
- decryptedPdu = Buffer.concat ([decryptedPdu, decipher.final()]);
1216
- } catch (error) {
1217
- // debug("Decrypt error: " + error);
1218
- decipher = crypto.createDecipheriv (des.CRYPTO_ALGORITHM, decryptionKey, iv);
1219
- decipher.setAutoPadding(false);
1220
- decryptedPdu = decipher.update (encryptedPdu);
1221
- decryptedPdu = Buffer.concat ([decryptedPdu, decipher.final()]);
1222
- }
1208
+ decryptedPdu = Buffer.concat ([decryptedPdu, decipher.final()]);
1223
1209
  // Encryption.debugDecrypt (decryptionKey, iv, encryptedPdu, decryptedPdu);
1224
1210
 
1225
1211
  return decryptedPdu;
@@ -1491,23 +1477,10 @@ Message.prototype.decryptPdu = function (user, responseCb) {
1491
1477
  decryptedPduReader = new ber.Reader (decryptedPdu);
1492
1478
  this.pdu = readPdu(decryptedPduReader, true);
1493
1479
  return true;
1494
- // really really occasionally the decrypt truncates a single byte
1495
- // causing an ASN read failure in readPdu()
1496
- // in this case, disabling auto padding decrypts the PDU correctly
1497
- // this try-catch provides the workaround for this condition
1498
- } catch (possibleTruncationError) {
1499
- try {
1500
- decryptedPdu = Encryption.decryptPdu(user.privProtocol, this.encryptedPdu,
1501
- this.msgSecurityParameters.msgPrivacyParameters, user.privKey, user.authProtocol,
1502
- this.msgSecurityParameters.msgAuthoritativeEngineID, true);
1503
- decryptedPduReader = new ber.Reader (decryptedPdu);
1504
- this.pdu = readPdu(decryptedPduReader, true);
1505
- return true;
1506
- } catch (error) {
1507
- responseCb (new ResponseInvalidError ("Failed to decrypt PDU: " + error,
1508
- ResponseInvalidCode.ECouldNotDecrypt));
1509
- return false;
1510
- }
1480
+ } catch (error) {
1481
+ responseCb (new ResponseInvalidError ("Failed to decrypt PDU: " + error,
1482
+ ResponseInvalidCode.ECouldNotDecrypt));
1483
+ return false;
1511
1484
  }
1512
1485
 
1513
1486
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "net-snmp",
3
- "version": "3.7.0",
3
+ "version": "3.7.1",
4
4
  "description": "JavaScript implementation of the Simple Network Management Protocol (SNMP)",
5
5
  "main": "index.js",
6
6
  "directories": {