From 39941363acb31675f8adc29345a095d9c8e77eb2 Mon Sep 17 00:00:00 2001 From: Adam Humpherys Date: Thu, 27 Aug 2020 08:18:10 -0600 Subject: [PATCH 1/2] Bumping QRCoder from 1.3.5 to 1.3.9 --- .../Google.Authenticator.csproj | 2 +- .../TwoFactorAuthenticator.cs | 32 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Google.Authenticator/Google.Authenticator.csproj b/Google.Authenticator/Google.Authenticator.csproj index 9d62cf8..0fef337 100644 --- a/Google.Authenticator/Google.Authenticator.csproj +++ b/Google.Authenticator/Google.Authenticator.csproj @@ -14,7 +14,7 @@ - + diff --git a/Google.Authenticator/TwoFactorAuthenticator.cs b/Google.Authenticator/TwoFactorAuthenticator.cs index 4f52720..608eadd 100644 --- a/Google.Authenticator/TwoFactorAuthenticator.cs +++ b/Google.Authenticator/TwoFactorAuthenticator.cs @@ -66,17 +66,17 @@ public SetupCode GenerateSetupCode(string issuer, string accountTitleNoSpaces, b } string qrCodeUrl = string.Empty; - if (generateQrCode) - { - using (QRCodeGenerator qrGenerator = new QRCodeGenerator()) - using (QRCodeData qrCodeData = qrGenerator.CreateQrCode(provisionUrl, QRCodeGenerator.ECCLevel.Q)) - using (QRCode qrCode = new QRCode(qrCodeData)) - using (Bitmap qrCodeImage = qrCode.GetGraphic(QRPixelsPerModule)) - using (MemoryStream ms = new MemoryStream()) - { - qrCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png); - - qrCodeUrl = String.Format("data:image/png;base64,{0}", Convert.ToBase64String(ms.ToArray())); + if (generateQrCode) + { + using (QRCodeGenerator qrGenerator = new QRCodeGenerator()) + using (QRCodeData qrCodeData = qrGenerator.CreateQrCode(provisionUrl, QRCodeGenerator.ECCLevel.Q)) + using (QRCode qrCode = new QRCode(qrCodeData)) + using (Bitmap qrCodeImage = qrCode.GetGraphic(QRPixelsPerModule)) + using (MemoryStream ms = new MemoryStream()) + { + qrCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png); + + qrCodeUrl = String.Format("data:image/png;base64,{0}", Convert.ToBase64String(ms.ToArray())); } } @@ -129,7 +129,7 @@ internal string GenerateHashedCode(byte[] key, long iterationNumber, int digits } HMACSHA1 hmac = new HMACSHA1(key); - + byte[] hash = hmac.ComputeHash(counter); int offset = hash[hash.Length - 1] & 0xf; @@ -154,7 +154,7 @@ private long GetCurrentCounter(DateTime now, DateTime epoch, int timeStep) { return (long)(now - epoch).TotalSeconds / timeStep; } - + public bool ValidateTwoFactorPIN(string accountSecretKey, string twoFactorCodeFromClient) { return ValidateTwoFactorPIN(accountSecretKey, twoFactorCodeFromClient, DefaultClockDriftTolerance); @@ -170,10 +170,10 @@ public string GetCurrentPIN(string accountSecretKey) { return GeneratePINAtInterval(accountSecretKey, GetCurrentCounter()); } - - public string GetCurrentPIN(string accountSecretKey,DateTime now) + + public string GetCurrentPIN(string accountSecretKey, DateTime now) { - return GeneratePINAtInterval(accountSecretKey, GetCurrentCounter(now,_epoch,30)); + return GeneratePINAtInterval(accountSecretKey, GetCurrentCounter(now, _epoch, 30)); } public string[] GetCurrentPINs(string accountSecretKey) From 933b66b38f693be6bdd7aa17cb11490f0c6fad76 Mon Sep 17 00:00:00 2001 From: Adam Humpherys Date: Thu, 27 Aug 2020 08:20:59 -0600 Subject: [PATCH 2/2] version bump --- Google.Authenticator/Google.Authenticator.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Google.Authenticator/Google.Authenticator.csproj b/Google.Authenticator/Google.Authenticator.csproj index 0fef337..db869ef 100644 --- a/Google.Authenticator/Google.Authenticator.csproj +++ b/Google.Authenticator/Google.Authenticator.csproj @@ -7,7 +7,7 @@ Google Authenticator Two-Factor Authentication Library (Not officially affiliated with Google.) Brandon Potter Brandon Potter - 2.0.1 + 2.0.2 Apache-2.0 https://github.com/BrandonPotter/GoogleAuthenticator GoogleAuthenticator