@@ -14,30 +14,13 @@ namespace Microsoft.AspNetCore.Cryptography.KeyDerivation.PBKDF2
14
14
/// </summary>
15
15
internal sealed class NetCorePbkdf2Provider : IPbkdf2Provider
16
16
{
17
- private static readonly ManagedPbkdf2Provider _fallbackProvider = new ManagedPbkdf2Provider ( ) ;
18
-
19
17
public byte [ ] DeriveKey ( string password , byte [ ] salt , KeyDerivationPrf prf , int iterationCount , int numBytesRequested )
20
18
{
21
19
Debug . Assert ( password != null ) ;
22
20
Debug . Assert ( salt != null ) ;
23
21
Debug . Assert ( iterationCount > 0 ) ;
24
22
Debug . Assert ( numBytesRequested > 0 ) ;
25
23
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
- {
41
24
HashAlgorithmName algorithmName ;
42
25
switch ( prf )
43
26
{
@@ -54,7 +37,7 @@ private static byte[] DeriveKeyImpl(string password, byte[] salt, KeyDerivationP
54
37
throw new ArgumentOutOfRangeException ( ) ;
55
38
}
56
39
57
- return Rfc2898DeriveBytes . Pbkdf2 ( Encoding . UTF8 . GetBytes ( password ) , salt , iterationCount , algorithmName , numBytesRequested ) ;
40
+ return Rfc2898DeriveBytes . Pbkdf2 ( password , salt , iterationCount , algorithmName , numBytesRequested ) ;
58
41
}
59
42
}
60
43
}
0 commit comments