Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Enable SHA256.Create() calls to work for desktop applications on FIPS compliant machines. #6354

Closed
NTaylorMullen opened this issue Jun 2, 2017 · 1 comment
Assignees
Milestone

Comments

@NTaylorMullen
Copy link
Contributor

When unnetcoreappifying our libraries we didn't also enable our SHA256.Create() implementations to work under the desktop framework. To do this you need to change SHA256.Create() the to the following:

public static SHA256 CreateSHA256()
{
	SHA256 sha256;

	try
	{
		sha256 = SHA256.Create();
	}
	// SHA256.Create is documented to throw this exception on FIPS compliant machines.
	// See: https://msdn.microsoft.com/en-us/library/z08hz7ad%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
	catch (System.Reflection.TargetInvocationException)
	{
		// Fallback to a FIPS compliant SHA256 algorithm.
		sha256 = new SHA256CryptoServiceProvider();
	}

	return sha256;
}
@NTaylorMullen
Copy link
Contributor Author

6c69cb8

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants