-
Notifications
You must be signed in to change notification settings - Fork 5k
Signed CMS for SLH-DSA #115310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Signed CMS for SLH-DSA #115310
Conversation
Note regarding the
|
1 similar comment
Note regarding the
|
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
Line 33 in 86949c2
|
I am curious if we need to implement any of this down level, since .NET Framework will have its own implementation. I... think... it probably could make sense to implement all of the new public API surface as
|
...raries/System.Security.Cryptography.Pkcs/ref/System.Security.Cryptography.Pkcs.netcoreapp.cs
Outdated
Show resolved
Hide resolved
...stem.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSignature.SlhDsa.cs
Outdated
Show resolved
Hide resolved
...ries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSignature.cs
Outdated
Show resolved
Hide resolved
...braries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSigner.cs
Outdated
Show resolved
Hide resolved
...braries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSigner.cs
Outdated
Show resolved
Hide resolved
...braries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSigner.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Pkcs/tests/SignedCms/SignedCmsTests.netcoreapp.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Pkcs/tests/SignedCms/SignedCmsTests.netcoreapp.cs
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Pkcs/tests/SignedCms/SignedCmsTests.netcoreapp.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Pkcs/tests/SignedCms/SignedCmsTests.netcoreapp.cs
Outdated
Show resolved
Hide resolved
...braries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSigner.cs
Outdated
Show resolved
Hide resolved
For Unix, downlevel won't work because we don't have the key accessors on certs for openssl in Microsoft.Bcl.Cryptography. However, I think we can still support Windows downlevel (net8.0 and net9.0) since the accessors will be available for them.
After talking to @bartonjs about this: netstandard2.0 should have the same API as NetFx so that means no public API changes. I think |
...ryptography/src/System/Security/Cryptography/X509Certificates/X509CertificateKeyAccessors.cs
Outdated
Show resolved
Hide resolved
.../System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSignature.DSA.cs
Outdated
Show resolved
Hide resolved
...libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsHash.cs
Outdated
Show resolved
Hide resolved
/// <exception cref="CryptographicException"> | ||
/// The public key was invalid, or otherwise could not be imported. | ||
/// </exception> | ||
[ExperimentalAttribute("SYSLIB5006")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use the const (and UrlFormat, as being introduced in #115412)
[Experimental(Experimentals.PostQuantumCryptographyDiagId)]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@barotnjs I don't know where we landed on this - but shouldn't the experimental be on the class? Like, if we ship the class it would, technically, be an unguarded breaking change for us to remove it, if we needed to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we put it on the class, but then mark ML-DSA (or whatever) as "not Experimental" while one of the rest still is, we have to be diligent at moving the Experimentals down to each remaining member.
We could also put it on the class until there's one stable member so that we don't end up with "well, we deleted everything, because all of PQC got abandoned by the industry before the specs all went final-stable.... so now we have this empty static class"... but I don't really see that outcome, so I don't feel like the class-level one is warranted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also put it on the class until there's one stable member so that we don't end up with "well, we deleted everything, because all of PQC got abandoned by the industry before the specs all went final-stable.
More like, "It turns out that extensions are not the right shape for [whatever reason]" but, okay.
/// <summary> | ||
/// Helper methods to access keys on <see cref="X509Certificate2"/>. | ||
/// </summary> | ||
public static class X509CertificateKeyAccessors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should EB-Never this for .NET 10+?
...raries/Microsoft.Bcl.Cryptography/tests/X509Certificates/X509CertificateKeyAccessorsTests.cs
Outdated
Show resolved
Hide resolved
...raries/Microsoft.Bcl.Cryptography/tests/X509Certificates/X509CertificateKeyAccessorsTests.cs
Outdated
Show resolved
Hide resolved
...raries/Microsoft.Bcl.Cryptography/tests/X509Certificates/X509CertificateKeyAccessorsTests.cs
Outdated
Show resolved
Hide resolved
...es/System.Security.Cryptography.Pkcs/src/Internal/Cryptography/Pal/Windows/PkcsPalWindows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Pkcs/src/System.Security.Cryptography.Pkcs.csproj
Outdated
Show resolved
Hide resolved
...libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsHash.cs
Show resolved
Hide resolved
...stem.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSignature.SlhDsa.cs
Show resolved
Hide resolved
...raries/Microsoft.Bcl.Cryptography/tests/X509Certificates/X509CertificateKeyAccessorsTests.cs
Outdated
Show resolved
Hide resolved
...raries/Microsoft.Bcl.Cryptography/tests/X509Certificates/X509CertificateKeyAccessorsTests.cs
Outdated
Show resolved
Hide resolved
...raries/Microsoft.Bcl.Cryptography/tests/X509Certificates/X509CertificateKeyAccessorsTests.cs
Outdated
Show resolved
Hide resolved
...raries/Microsoft.Bcl.Cryptography/tests/X509Certificates/X509CertificateKeyAccessorsTests.cs
Outdated
Show resolved
Hide resolved
...raries/Microsoft.Bcl.Cryptography/tests/X509Certificates/X509CertificateKeyAccessorsTests.cs
Outdated
Show resolved
Hide resolved
/// <exception cref="CryptographicException"> | ||
/// The public key was invalid, or otherwise could not be imported. | ||
/// </exception> | ||
[ExperimentalAttribute("SYSLIB5006")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we put it on the class, but then mark ML-DSA (or whatever) as "not Experimental" while one of the rest still is, we have to be diligent at moving the Experimentals down to each remaining member.
We could also put it on the class until there's one stable member so that we don't end up with "well, we deleted everything, because all of PQC got abandoned by the industry before the specs all went final-stable.... so now we have this empty static class"... but I don't really see that outcome, so I don't feel like the class-level one is warranted.
This PR forks Sign and Verify into a Pure and Hash mode with the Hash mode being the same as the existing implementation. Additionally it adds support for SHAKE128 and SHAKE256 as digest algorithms in CMS.
Some design decisions:
SubjectIdentifierType.NoSignature
is specified, we will check whether the signing algorithm is SLH-DSA and throw if it is. Otherwise we will just use the hash as the signature as before. If Windows has a different behavior for NetFx, we will just adopt it since we don't have an opinion here.CheckHash
.CMS for SLH-DSA successfully roundtrips with openssl (message created with SignedCms can be verified with OpenSsl and vice versa).