Skip to content

Commit

Permalink
Cyrillic pwd decrypt fix
Browse files Browse the repository at this point in the history
  • Loading branch information
apashkov-ext committed Feb 27, 2023
1 parent b6eff4f commit 1dfe354
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Core/RadiusPassword.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,22 @@ private static Byte[] CreateKey(Byte[] sharedSecret, Byte[] authenticator)
/// <returns></returns>
public static String Decrypt(Byte[] sharedSecret, Byte[] authenticator, Byte[] passwordBytes)
{
var sb = new StringBuilder();
var key = CreateKey(sharedSecret, authenticator);
var bytes = new List<Byte>();

for (var n = 1; n <= passwordBytes.Length / 16; n++)
{
var temp = new Byte[16];
Buffer.BlockCopy(passwordBytes, (n - 1) * 16, temp, 0, 16);
sb.Append(Encoding.UTF8.GetString(EncryptDecrypt(temp, key)));

var block = EncryptDecrypt(temp, key);
bytes.AddRange(block);

key = CreateKey(sharedSecret, temp);
}

return sb.ToString().Replace("\0", "");
var ret = Encoding.UTF8.GetString(bytes.ToArray());
return ret.Replace("\0", "");
}


Expand Down

0 comments on commit 1dfe354

Please sign in to comment.