Open MattBussing opened 4 months ago
Following up on this. Is there any updates?
Pinging @davidsh since you worked on https://github.com/dotnet/runtime/issues/17005#issuecomment-308746803
Thanks @MattBussing for the repro and all the details. We will take a look.
@jennyf19 Thank you for taking a look!
Hello. Thanks for taking the time to review this issue! I found a very odd bug. I get a CryptographicException "The buffer supplied to a function was too small" when the following condition are true:
RsaSecurityKey key new(rsa.ExportParameters(true))
. I don't get this error usingRsaSecurityKey key = new(rsa)
.You can reproduce this error with https://github.com/MattBussing/IdentityModelRepro. Granted you don't have the RSA key to generate the issue and I can't share the key for security reasons. But, when you run the following commands it will demonstrate the issue.
Note this is running in .NET Framework 4.8.
fails
BufferRepro.exe --path "key.xml" --use-bad-version true
passes
BufferRepro.exe --path "key.xml" --use-bad-version false
Error
Are there similar issues?
Kind of. These have the same error message "The buffers supplied to a function was too small", but they aren't using WinHTTP.
Is this caused by 0 padding?
https://stackoverflow.com/a/39217099/9728299
All the RSA params do not end or begin with a byte of zero.
Is the RSA key valid?
Yes. It was able to encrypt and decrypt data correctly.
Does it work if we use Microsoft.IdentityModel.JsonWebTokens instead of System.IdentityModel.Tokens.Jwt?
No. In fact they both take in RSACryptoServiceProvider, which uses Windows' native crypto libraries. So, it breaks on both.