[release/6.0] Fix Windows 8 detection in Pbkdf2 (#58823)
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Thu, 9 Sep 2021 15:00:11 +0000 (09:00 -0600)
committerGitHub <noreply@github.com>
Thu, 9 Sep 2021 15:00:11 +0000 (09:00 -0600)
* Fix Windows 8 detection.

Windows 8's actual version is 6.2, not 8. The test would succeed only on Windows 10+.

* Explain that Windows 8's version is 6.2.

Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
Co-authored-by: Theodore Tsirpanis <12659251+teo-tsirpanis@users.noreply.github.com>
Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
src/libraries/System.Security.Cryptography.Algorithms/src/Internal/Cryptography/Pbkdf2Implementation.Windows.cs

index c72dcb4..e9275bc 100644 (file)
@@ -16,9 +16,9 @@ namespace Internal.Cryptography
 {
     internal static partial class Pbkdf2Implementation
     {
-        // For Windows 7 we will use BCryptDeriveKeyPBKDF2. For Windows 8+ we will use BCryptKeyDerivation
-        // since it has better performance.
-        private static readonly bool s_useKeyDerivation = OperatingSystem.IsWindowsVersionAtLeast(8, 0, 0);
+        // For Windows 7 we will use BCryptDeriveKeyPBKDF2. For Windows 8+ (seen as version 6.2.0) we will
+        // use BCryptKeyDerivation since it has better performance.
+        private static readonly bool s_useKeyDerivation = OperatingSystem.IsWindowsVersionAtLeast(6, 2);
 
         // A cached instance of PBKDF2 for Windows 8, where pseudo handles are not supported.
         private static SafeBCryptAlgorithmHandle? s_pbkdf2AlgorithmHandle;