Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was 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

@NTaylorMullen

Description

@NTaylorMullen

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;
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions