【问题标题】:Exception when using DevForce in a FIPS-compliant environment在符合 FIPS 的环境中使用 DevForce 时出现异常
【发布时间】: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 的人处理得更慢。

【问题讨论】:

    标签: c# fips devforce


    【解决方案1】:

    这是一个错误,我们可以修复它(希望在下一个版本中)。此散列逻辑仅在为“动态”类型生成名称时使用,该名称在处理匿名类型和动态查询时使用。您可以通过投影到自定义类型而不是匿名类型来解决此错误,否则没有解决方法可以避免该问题。

    如果性能是一个问题,而且很可能不是因为这种散列现在只用于动态类型名称,我们可以考虑在 FIPS/非 FIPS 兼容的提供程序之间进行选择。

    【讨论】:

    • 谢谢!我们可以等待下一个版本,因为变通方法听起来很复杂(我们会进行 ton 的动态查询并选择匿名类型,因此接触所有代码不会很有趣)。如果每次查询执行或某事只会受到一次打击,那么性能可能不是问题。我只是担心它是否在紧密循环中的其他任何地方使用或类似的东西。我想我最初应该提到它,但是您能否验证 DevForce 中没有任何其他非 FIP 代码?我不想为了碰到另一个错误而克服这个错误。
    • Stephen,我们已经发布了 7.5.2 版本,其中包含对此的修复。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多