【发布时间】:2018-06-19 17:46:57
【问题描述】:
我们有一些客户希望在“FIPS Mode”中通过 Windows 运行我们的软件(使用 DevForce)。似乎 DevForce 完成的大多数加密默认情况下都符合 FIPS,但我们遇到了 DevForce 所做的一些散列的问题。具体来说,调用AesCryptoProvider.CalcStringHash 的代码如下所示:
/// <summary>
/// Returns a hash encoded as a string with the chars (A-Z,A-z,0-9,_) only.
/// </summary>
/// <remarks>
/// Under the covers this method returns an 128 bit hash code calculated
/// using SHA1. This code is then encoded into an approx Base64 encode
/// of the chars listed above. This will usually be approx 28 chars in length,
/// which may then be truncated based on the maxChars parameter. This
/// method can process approx 100K 300 char strings a second.
/// </remarks>
/// <param name="stringToHash"></param>
/// <param name="maxChars"></param>
/// <returns></returns>
public string CalcStringHash(string stringToHash, int maxChars)
{
return CodingFns.EncodeBase64(new SHA1Managed().ComputeHash(Encoding.Unicode.GetBytes(stringToHash))).Substring(0, maxChars).Replace("=", "").Replace("/", "_d").Replace("+", "_p");
}
该方法直接实例化 SHA1Managed 实例,不幸的是,该类不符合 FIPS。
这是上下文的完整堆栈跟踪:
Exception: System.InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.
at System.Security.Cryptography.SHA1Managed..ctor()
at IdeaBlade.Core.PlatformServices.AesCryptoProvider.CalcStringHash(String stringToHash, Int32 maxChars)
at IdeaBlade.Core.DynamicTypeInfo.GetUniqueToken()
at IdeaBlade.Core.DynamicTypeInfo.BuildDynamicTypeName()
at IdeaBlade.Core.DynamicTypeInfo..ctor(TypeShape typeShape)
at IdeaBlade.Core.DynamicTypeInfo.FindOrCreate(IEnumerable`1 propertyNames, IEnumerable`1 propertyTypes)
at IdeaBlade.Linq.AnonymousProjectionSelector.GetDynamicTypeInfo()
at IdeaBlade.Linq.AnonymousProjectionSelector.ToLambdaExpression(Type delegateType)
at IdeaBlade.Linq.QueryableExtensions.Select[TSource](IQueryable`1 source, IProjectionSelector selector)
at My.Company.ServerClass.MyRemoteServerMethod(IPrincipal principal, EntityManager serverEm, Object[] rawArgs)
是否有任何解决方法可以让 DevForce 在 FIPS 模式下工作?或者这是否可以在未来的版本中添加?
我注意到该方法的 cmets 谈论性能。如果这是一种性能关键的方法并且切换到 FIPS 投诉替代方案会导致性能下降,那么它可能是一个可配置的选项?我们只有一位客户抱怨 FIPS,但还有更多客户关心性能,所以我不想让那些不关心 FIPS 的人处理得更慢。
【问题讨论】: