Skip to content

X509CertificateLoader does not shim HMAC in .NET Standard 2.0 correctly #111926

@vcsjones

Description

@vcsjones

This was initially reported at https://stackoverflow.com/questions/79392501/whats-so-dangerous-about-pkcs12loaderlimits-dangerousnolimits

This person reported a CryptographicException from here:

Which in theory should not be possible to hit, as the list of hash algorithms is closed and validated here:

if (!hmac.TryGetHashAndReset(derived, out int bytesWritten) || bytesWritten != expectedOutputSize)

However, in this shim, it as asking IncrementalHash "What is your algorithm name?". IncrementalHash prepends "HMAC" in front of the algorithm names:

_algorithmName = new HashAlgorithmName("HMAC" + name.Name);

IncrementalHash answers with an algorithm of "HMACSHA1", not "SHA1" (for example). The switch in the shim does not handle the algorithm names that are prepended.

This only happens for the .NET Standard 2.0 build.

Metadata

Metadata

Assignees

Labels

area-System.Securityin-prThere is an active PR which will close this issue when it is merged

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions