diff --git a/src/Microsoft.AspNet.Security.DataProtection/PBKDF2.cs b/src/Microsoft.AspNet.Security.DataProtection/PBKDF2.cs deleted file mode 100644 index c2f7c22b86..0000000000 --- a/src/Microsoft.AspNet.Security.DataProtection/PBKDF2.cs +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Security.Cryptography; - -namespace Microsoft.AspNet.Security.DataProtection -{ - /// - /// Helper class to derive keys from low-entropy passwords using the PBKDF2 algorithm. - /// - public static class PBKDF2 - { - /// - /// Derives a key from a low-entropy password. - /// - /// The name of the PRF to use for key derivation. - /// The low-entropy password from which to generate a key. - /// The salt used to randomize the key derivation. - /// The number of iterations to perform. - /// The desired byte length of the derived key. - /// A key derived from the provided password. - /// For compatibility with the Rfc2898DeriveBytes class, specify "SHA1" for the algorithmName parameter. - public unsafe static byte[] DeriveKey(string algorithmName, byte[] password, byte[] salt, ulong iterationCount, uint numBytesToDerive) - { - if (String.IsNullOrEmpty(algorithmName)) - { - throw new ArgumentException(Res.Common_NullOrEmpty, "algorithmName"); - } - if (password == null || password.Length == 0) - { - throw new ArgumentException(Res.Common_NullOrEmpty, "password"); - } - if (salt == null || salt.Length == 0) - { - throw new ArgumentException(Res.Common_NullOrEmpty, "salt"); - } - if (iterationCount <= 0) - { - throw new ArgumentOutOfRangeException("iterationCount"); - } - - byte[] derivedKey = new byte[numBytesToDerive]; - int status; - - using (BCryptAlgorithmHandle algHandle = Algorithms.CreateGenericHMACHandleFromPrimitiveProvider(algorithmName)) - { - fixed (byte* pPassword = password) - fixed (byte* pSalt = salt) - fixed (byte* pDerivedKey = derivedKey) - { - status = UnsafeNativeMethods.BCryptDeriveKeyPBKDF2( - algHandle, pPassword, (uint)password.Length, pSalt, (uint)salt.Length, iterationCount, - pDerivedKey, numBytesToDerive, dwFlags: 0); - } - } - - if (status == 0 /* STATUS_SUCCESS */) - { - return derivedKey; - } - else - { - throw new CryptographicException(status); - } - } - } -}