You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am using SecurityUtilities.SignFile to sign a ClickOnce manifest files but it occasionally fails with a System.Security.Cryptography.CryptographicException that stems from a call to ObtainRFC3161Timestamp.
I am directly calling the API using the Microsoft.Build.Tasks.Core nuget package.
Steps to Reproduce
This behaviour depends on the result of the random number generator in ObtainRFC3161Timestamp so the issues manifests on average once every couple of hundreds attempts. The following is a minimal example that reproduces the issue using code from SignedCmiManifest2.
Signing the ClickOnce manifest file always succeeds.
Actual Behavior
Signing fails occasionally with a CryptographicException that has a HResult of TRUST_E_TIME_STAMP.
Analysis
The problem is that the Win32.CryptRetrieveTimeStamp() call within ObtainRFC3161Timestamp() sometimes returns a TRUST_E_TIME_STAMP result. The reason is because the generated nonce in ObtainRFC3161Timestamp() - just a evenly distributed random 192 bit number - is in an unexpected range.
When using the default ObtainRFC3161Timestamp() implementation of the 1000 calls about two TRUST_E_TIME_STAMP errors occur.
To test this can be made worse by doing nonce[^1] = 0xFF in ObtainRFC3161Timestamp() which lets 50% of calls fail.
The team responsible for nuget signing seems to have encountered a similiar issue and implemented a fix.
When implementing their fix nonce[^1] &= 0x7f; nonce[^1] |= 0x01; 100% of calls succeed.
Versions & Configurations
MSBuild version 17.7.2+d6990bcfa for .NET Framework
17.7.2.37605
dotnet --version
7.0.401
The text was updated successfully, but these errors were encountered:
Issue Description
Hi, I am using SecurityUtilities.SignFile to sign a ClickOnce manifest files but it occasionally fails with a System.Security.Cryptography.CryptographicException that stems from a call to
ObtainRFC3161Timestamp
.I am directly calling the API using the Microsoft.Build.Tasks.Core nuget package.
Steps to Reproduce
This behaviour depends on the result of the random number generator in ObtainRFC3161Timestamp so the issues manifests on average once every couple of hundreds attempts. The following is a minimal example that reproduces the issue using code from SignedCmiManifest2.
Expected Behavior
Signing the ClickOnce manifest file always succeeds.
Actual Behavior
Signing fails occasionally with a
CryptographicException
that has a HResult ofTRUST_E_TIME_STAMP
.Analysis
The problem is that the
Win32.CryptRetrieveTimeStamp()
call withinObtainRFC3161Timestamp()
sometimes returns aTRUST_E_TIME_STAMP
result. The reason is because the generated nonce inObtainRFC3161Timestamp()
- just a evenly distributed random 192 bit number - is in an unexpected range.When using the default
ObtainRFC3161Timestamp()
implementation of the 1000 calls about twoTRUST_E_TIME_STAMP
errors occur.To test this can be made worse by doing
nonce[^1] = 0xFF
inObtainRFC3161Timestamp()
which lets 50% of calls fail.The team responsible for nuget signing seems to have encountered a similiar issue and implemented a fix.
When implementing their fix
nonce[^1] &= 0x7f; nonce[^1] |= 0x01;
100% of calls succeed.Versions & Configurations
MSBuild version 17.7.2+d6990bcfa for .NET Framework
17.7.2.37605
dotnet --version
7.0.401
The text was updated successfully, but these errors were encountered: