This repository has been archived by the owner. It is now read-only.

SHA256 Hash Algorithm Not FIPS Compliant #571

Closed
muntaserq opened this Issue Nov 20, 2014 · 12 comments

Comments

Projects
None yet
6 participants
@muntaserq
Copy link

muntaserq commented Nov 20, 2014

Hello,

We are trying to deploy a server implementation of ThinkTecture on a server that requires FIPS compliant to be enabled. We are running into a issue during the Autofac dependency resolving. We believe the issue stems from the mapping of the ITokenHandleStore. We believe we need to replace the hashing algorithm with one that is FIPS compliant, do you recommend us changing the constant (DefaultHashAlgorithm) or implementing our own ITokenHandleStore. If we need to implement our own, is it even possible to do that? If not, are there any other recommendations on how to resolve this issue?

This is part of the error message that lead us to infer this, beginning part and the end:

{"Message":"An error has occurred.","ExceptionMessage":"An error occurred when trying to create a controller of type 'AuthorizeEndpointController'. Make sure that the controller has a parameterless public constructor.","ExceptionType":"System.InvalidOperationException","StackTrace":" at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) in c:\ballen\github\thinktecture\IdSrv3\Thinktecture.IdentityServer.v3\source\Core\Configuration\IdentityServerServiceFactory.cs:line 0\r\n at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request) in
.
.
.
c:\ballen\github\thinktecture\IdSrv3\Thinktecture.IdentityServer.v3\source\Core\Configuration\IdentityServerServiceFactory.cs:line 0","InnerException":{"Message":"An error has occurred.","ExceptionMessage":"This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.","ExceptionType":"System.InvalidOperationException","StackTrace":" at System.Security.Cryptography.SHA256Managed..ctor()"}}}}

@leastprivilege

This comment has been minimized.

Copy link
Member

leastprivilege commented Nov 21, 2014

We are calling HashAlgorithm.Create - so it should be possible to re-map that implementation using .NET's global crypto config - or you can implement your own store.

Check the wiki on instructions on how to replace our store/service implementations.

@leastprivilege

This comment has been minimized.

Copy link
Member

leastprivilege commented Nov 24, 2014

Any progress?

@muntaserq

This comment has been minimized.

Copy link
Author

muntaserq commented Nov 24, 2014

We noticed that with the ITokenService that we cannot override the default
hashalgorithm. We tweaked both of the configuration values to a hash
algorithm which is FIPS compliant.

This is what prevents us from overriding the default hash algorithm.

public KeyHashingTransientDataRepository(ITransientDataRepository inner)
: this(Constants.DefaultHashAlgorithm, inner)
{
}

@leastprivilege

This comment has been minimized.

Copy link
Member

leastprivilege commented Nov 25, 2014

But we are calling

hash = HashAlgorithm.Create(hashName);

where hashName = "SHA256"

Can't you remap that to a FIPS compliant SHA256 configuration using the .NET crypto config facility? Which other change are you suggesting?

What exactly have you done so far?

@muntaserq

This comment has been minimized.

Copy link
Author

muntaserq commented Nov 25, 2014

We're not entirely sure if modifying the machine.config to achieve the
remap using .NET crypto config facility is a viable solution.

Also, the call referenced isn't the only place that causes a problem.

In DefaultTokenService there is a call:

var algorithm = SHA256.Create();

This needed to be changed to the new hash algorithm, in this case we found
the HMACSHA256 to be compliant and work for what we need.

On Mon Nov 24 2014 at 11:43:07 PM Dominick Baier notifications@github.com
wrote:

But we are calling

hash = HashAlgorithm.Create(hashName);

where hashName = "SHA256"

Can't you remap that to a FIPS compliant SHA256 configuration using the
.NET crypto config facility? Which other change are you suggesting?

What exactly have you done so far?


Reply to this email directly or view it on GitHub
#571 (comment)
.

@leastprivilege

This comment has been minimized.

Copy link
Member

leastprivilege commented Nov 26, 2014

SHA256 and HMACSHA256 are two different things - I guess the FIPS compliant implementation of SHA256 would be System.Security.Cryptography. Sha256Cng.

I believe you can remap that using CryptoConfig.

@leastprivilege

This comment has been minimized.

Copy link
Member

leastprivilege commented Dec 7, 2014

any updates?

@brockallen

This comment has been minimized.

Copy link
Member

brockallen commented Dec 19, 2014

Here's the guidance on configuring CryptoConfig:

http://blogs.msdn.com/b/shawnfa/archive/2008/12/02/cryptoconfig.aspx

@ReeceWilliams7

This comment has been minimized.

Copy link
Contributor

ReeceWilliams7 commented May 18, 2015

I created a blog that defines the steps required for the CryptoConfig tool.

http://anemptyreece.com/2015/05/16/identityserver3-fips/

Hopefully that proves useful to anyone who comes across this issue.

@leastprivilege

This comment has been minimized.

Copy link
Member

leastprivilege commented May 18, 2015

thanks!

@RobKraft

This comment has been minimized.

Copy link

RobKraft commented Jan 27, 2017

This issue is also now resolved in .Net 4.6.2. Prior to .Net 4.6.2, SHA256.Create() defaulted to using SHA256Managed. In .Net 4.6.2 they changed it to use SHA256Cng. dotnet/roslyn#15939

@rosdi

This comment has been minimized.

Copy link

rosdi commented Dec 6, 2017

Thanks @RobKraft , updating .NET requires less red-tape than trying to convince administrator to disable FIPS compliant setting.

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