Microsoft.IdentityModel.Clients.ActiveDirectory.CryptographyHelper.GetCryptoProviderForSha256 C# (CSharp) Method

GetCryptoProviderForSha256() private static method

private static GetCryptoProviderForSha256 ( RSACryptoServiceProvider rsaProvider ) : RSACryptoServiceProvider
rsaProvider System.Security.Cryptography.RSACryptoServiceProvider
return System.Security.Cryptography.RSACryptoServiceProvider
        private static RSACryptoServiceProvider GetCryptoProviderForSha256(RSACryptoServiceProvider rsaProvider)
        {
            const int PROV_RSA_AES = 24;    // CryptoApi provider type for an RSA provider supporting sha-256 digital signatures

            // On Mono, use the default ProviderType
            if (rsaProvider.CspKeyContainerInfo.ProviderType == PROV_RSA_AES || Mono.IsMono())
            {
                return rsaProvider;
            }

            CspParameters csp = new CspParameters
                                {
                                    ProviderType = PROV_RSA_AES,
                                    KeyContainerName = rsaProvider.CspKeyContainerInfo.KeyContainerName,
                                    KeyNumber = (int)rsaProvider.CspKeyContainerInfo.KeyNumber
                                };

            if (rsaProvider.CspKeyContainerInfo.MachineKeyStore)
            {
                csp.Flags = CspProviderFlags.UseMachineKeyStore;
            }

            //
            // If UseExistingKey is not specified, the CLR will generate a key for a non-existent group.
            // With this flag, a CryptographicException is thrown instead.
            //
            csp.Flags |= CspProviderFlags.UseExistingKey;
            return new RSACryptoServiceProvider(csp);
        }
    }