Skip to content

Commit

Permalink
Fixed #185 by removing extra paddings.
Browse files Browse the repository at this point in the history
  • Loading branch information
lextm committed Oct 31, 2023
1 parent ecc6c7c commit 0cd3b4b
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions SharpSnmpLib/Security/AESPrivacyProviderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,19 +402,6 @@ public ISnmpData Encrypt(ISnmpData data, SecurityParameters parameters)

var pkey = PasswordToKey(_phrase.GetRaw(), parameters.EngineId.GetRaw());
var bytes = data.ToBytes();
var reminder = bytes.Length % 8;
var count = reminder == 0 ? 0 : 8 - reminder;
using (var stream = new MemoryStream())
{
stream.Write(bytes, 0, bytes.Length);
for (var i = 0; i < count; i++)
{
stream.WriteByte(1);
}

bytes = stream.ToArray();
}

var encrypted = Encrypt(bytes, pkey, parameters.EngineBoots!.ToInt32(), parameters.EngineTime!.ToInt32(), parameters.PrivacyParameters!.GetRaw());
return new OctetString(encrypted);
}
Expand Down Expand Up @@ -509,7 +496,7 @@ internal byte[] ExtendShortKey(byte[] shortKey, byte[] engineId, IAuthentication
else
{
Array.Copy(tmpBuf, 0, extKey, keyLen, MinimumKeyLength - keyLen);
keyLen += (MinimumKeyLength - keyLen);
keyLen += MinimumKeyLength - keyLen;
}

lastKeyBuf = new byte[tmpBuf.Length];
Expand Down

0 comments on commit 0cd3b4b

Please sign in to comment.