@@ -14,30 +14,13 @@ namespace Microsoft.AspNetCore.Cryptography.KeyDerivation.PBKDF2
1414 /// </summary>
1515 internal sealed class NetCorePbkdf2Provider : IPbkdf2Provider
1616 {
17- private static readonly ManagedPbkdf2Provider _fallbackProvider = new ManagedPbkdf2Provider ( ) ;
18-
1917 public byte [ ] DeriveKey ( string password , byte [ ] salt , KeyDerivationPrf prf , int iterationCount , int numBytesRequested )
2018 {
2119 Debug . Assert ( password != null ) ;
2220 Debug . Assert ( salt != null ) ;
2321 Debug . Assert ( iterationCount > 0 ) ;
2422 Debug . Assert ( numBytesRequested > 0 ) ;
2523
26- if ( salt . Length < 8 )
27- {
28- // Rfc2898DeriveBytes enforces the 8 byte recommendation.
29- // To maintain compatibility, we call into ManagedPbkdf2Provider for salts shorter than 8 bytes
30- // because we can't use Rfc2898DeriveBytes with this salt.
31- return _fallbackProvider . DeriveKey ( password , salt , prf , iterationCount , numBytesRequested ) ;
32- }
33- else
34- {
35- return DeriveKeyImpl ( password , salt , prf , iterationCount , numBytesRequested ) ;
36- }
37- }
38-
39- private static byte [ ] DeriveKeyImpl ( string password , byte [ ] salt , KeyDerivationPrf prf , int iterationCount , int numBytesRequested )
40- {
4124 HashAlgorithmName algorithmName ;
4225 switch ( prf )
4326 {
@@ -54,7 +37,7 @@ private static byte[] DeriveKeyImpl(string password, byte[] salt, KeyDerivationP
5437 throw new ArgumentOutOfRangeException ( ) ;
5538 }
5639
57- return Rfc2898DeriveBytes . Pbkdf2 ( Encoding . UTF8 . GetBytes ( password ) , salt , iterationCount , algorithmName , numBytesRequested ) ;
40+ return Rfc2898DeriveBytes . Pbkdf2 ( password , salt , iterationCount , algorithmName , numBytesRequested ) ;
5841 }
5942 }
6043}
0 commit comments