public byte[] CryptDeriveKey(string algname, string alghashname, int keySize, byte[] rgbIV)
        {
            if (keySize < 0)
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
            }
            int num = X509Utils.NameOrOidToAlgId(alghashname, OidGroup.HashAlgorithm);

            if (num == 0)
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_PasswordDerivedBytes_InvalidAlgorithm"));
            }
            int num2 = X509Utils.NameOrOidToAlgId(algname, OidGroup.AllGroups);

            if (num2 == 0)
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_PasswordDerivedBytes_InvalidAlgorithm"));
            }
            if (rgbIV == null)
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_PasswordDerivedBytes_InvalidIV"));
            }
            byte[] result = null;
            Rfc2898DeriveBytes.DeriveKey(this.ProvHandle, num2, num, this.m_password, this.m_password.Length, keySize << 16, rgbIV, rgbIV.Length, JitHelpers.GetObjectHandleOnStack <byte[]>(ref result));
            return(result);
        }
        public byte[] CryptDeriveKey(string algname, string alghashname, int keySize, byte[] rgbIV)
        {
            if (keySize < 0)
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
            }
            int algId1 = X509Utils.NameOrOidToAlgId(alghashname, OidGroup.HashAlgorithm);

            if (algId1 == 0)
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_PasswordDerivedBytes_InvalidAlgorithm"));
            }
            int algId2 = X509Utils.NameOrOidToAlgId(algname, OidGroup.AllGroups);

            if (algId2 == 0)
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_PasswordDerivedBytes_InvalidAlgorithm"));
            }
            if (rgbIV == null)
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_PasswordDerivedBytes_InvalidIV"));
            }
            byte[]         o          = (byte[])null;
            SafeProvHandle provHandle = this.ProvHandle;
            int            algid      = algId2;
            int            algidHash  = algId1;

            byte[] password = this.m_password;
            int    length1  = this.m_password.Length;
            int    dwFlags  = keySize << 16;

            byte[] IV      = rgbIV;
            int    length2 = IV.Length;
            ObjectHandleOnStack objectHandleOnStack = JitHelpers.GetObjectHandleOnStack <byte[]>(ref o);

            Rfc2898DeriveBytes.DeriveKey(provHandle, algid, algidHash, password, length1, dwFlags, IV, length2, objectHandleOnStack);
            return(o);
        }