未验证 提交 48936455 编写于 作者: K Kevin Jones 提交者: GitHub

Use SHA256 one-shot for CrlCache

Co-authored-by: NJeremy Barton <jbarton@microsoft.com>
上级 0c474714
......@@ -28,9 +28,6 @@ internal static class CrlCache
private const ulong X509_R_CERT_ALREADY_IN_HASH_TABLE = 0x0B07D065;
[ThreadStatic]
private static HashAlgorithm? ts_urlHash;
public static void AddCrlForCertificate(
SafeX509Handle cert,
SafeX509StoreHandle store,
......@@ -215,21 +212,15 @@ private static string GetCrlFileName(SafeX509Handle cert, string crlUrl)
}
uint persistentHash = unchecked((uint)persistentHashLong);
if (ts_urlHash == null)
{
ts_urlHash = SHA256.Create();
}
Span<byte> hash = stackalloc byte[256 >> 3];
// Endianness isn't important, it just needs to be consistent.
// (Even if the same storage was used for two different endianness systems it'd stabilize at two files).
ReadOnlySpan<byte> utf16Url = MemoryMarshal.AsBytes(crlUrl.AsSpan());
if (!ts_urlHash.TryComputeHash(utf16Url, hash, out int written) || written != hash.Length)
if (SHA256.HashData(utf16Url, hash) != hash.Length)
{
Debug.Fail("TryComputeHash failed or produced an incorrect length output");
Debug.Fail("HashData failed or produced an incorrect length output");
throw new CryptographicException();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册