From 26c37bcd2a74f0c6e96da39fadc668c0225df228 Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Tue, 15 Apr 2025 12:44:43 +0200 Subject: [PATCH] fix implementation of yubikey secret reading --- src/keepass2android-app/KeeChallenge.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/keepass2android-app/KeeChallenge.cs b/src/keepass2android-app/KeeChallenge.cs index 3d986028..4bb9373d 100644 --- a/src/keepass2android-app/KeeChallenge.cs +++ b/src/keepass2android-app/KeeChallenge.cs @@ -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(); }