fix implementation of yubikey secret reading

This commit is contained in:
Philipp Crocoll
2025-04-15 12:44:43 +02:00
parent 1980f05a7c
commit 26c37bcd2a

View File

@@ -148,17 +148,13 @@ namespace KeeChallenge
{
//read the secret from the stream
int totalBytesRead = 0;
byte[] buffer = new byte[secret.Length];
var secretOutputStream = new MemoryStream(secret);
int bytesRead = csDecrypt.Read(buffer, totalBytesRead, secret.Length - totalBytesRead);
int bytesRead = csDecrypt.Read(secret, totalBytesRead, secret.Length - totalBytesRead);
while (bytesRead > 0 && totalBytesRead < secret.Length)
{
secretOutputStream.Write(buffer, 0, bytesRead);
totalBytesRead += bytesRead;
bytesRead = csDecrypt.Read(buffer, totalBytesRead, secret.Length - totalBytesRead);
bytesRead = csDecrypt.Read(secret, totalBytesRead, secret.Length - totalBytesRead);
}
secretOutputStream.Close();
csDecrypt.Close();
}