-
Notifications
You must be signed in to change notification settings - Fork 5k
Add PKCS#8, SPKI and PEM support for SLH-DSA #114943
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
Add PKCS#8, SPKI and PEM support for SLH-DSA #114943
Conversation
Note regarding the
|
1 similar comment
Note regarding the
|
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
src/libraries/Common/src/System/Security/Cryptography/KeyFormatHelper.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs
Outdated
Show resolved
Hide resolved
.../Common/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaTestData.cs
Show resolved
Hide resolved
.../Common/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaTestData.cs
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs
Outdated
Show resolved
Hide resolved
...on/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaContractTests.cs
Show resolved
Hide resolved
...mon/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaFactoryTests.cs
Outdated
Show resolved
Hide resolved
...ts/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaImplementationTests.cs
Show resolved
Hide resolved
...ts/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaImplementationTests.cs
Outdated
Show resolved
Hide resolved
...ts/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaImplementationTests.cs
Show resolved
Hide resolved
...mmon/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaTestHelpers.cs
Outdated
Show resolved
Hide resolved
...mmon/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaTestHelpers.cs
Outdated
Show resolved
Hide resolved
...mmon/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaTestHelpers.cs
Outdated
Show resolved
Hide resolved
...mmon/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaTestHelpers.cs
Outdated
Show resolved
Hide resolved
// Early heuristic based bailout so no core methods are called | ||
AssertExtensions.FalseExpression(slhDsa.TryExportPkcs8PrivateKey([], out int bytesWritten)); | ||
Assert.Equal(9, encodedMetadata.Length); |
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.
It feels weird to me that this is being recomputed and reverified on every single run with every single algorithm. It's probably fine, but I'd probably just declare 9 as a local const and leave a comment as to how that value was determined.
What really matters is that it tests "one below this doesn't call the Core method, and at this size it does". So maybe I'd omit the comment, as const int MinimumOverhead = 9;
says "it's a minimum" and then the test confirms it's the same minimum that the implementation uses.
There's room to argue if we want the minimum to be 9, or if we want to say that since we have a finite list of SlhDsaAlgorithm and we know they all have a minimum of (whatever it is) that we're going to push the impl limit higher. Again, it doesn't matter a whole lot to the test why we picked that number, but it would have to match if it's testing the boundary.
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.
it doesn't matter a whole lot to the test why we picked that number
I think it's worth having both the following tests: (1) the number we picked is honored in the implementation and (2) the length check will permit a minimal encoding. And by minimal encoding, I mean either a hardcoded or runtime generated ASN encoding for each algo that we believe is the smallest spec compliant PKCS#8 encoding.
If we don't have (2) it becomes very easy to just update the constant in the product and in the failing test and nothing really gets validated. By having (2) it forces us to provide a new minimal encoding to prove that the new constant still satisfies the constraint of allowing the minimal encoding.
Also, the overhead right now does not account for the Version
so I'll add it in.
...on/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaContractTests.cs
Outdated
Show resolved
Hide resolved
...on/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaContractTests.cs
Outdated
Show resolved
Hide resolved
...mon/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaFactoryTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/SlhDsa.cs
Outdated
Show resolved
Hide resolved
...mmon/tests/System/Security/Cryptography/AlgorithmImplementations/SlhDsa/SlhDsaTestHelpers.cs
Outdated
Show resolved
Hide resolved
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.
Good after the one remaining rename
/ba-g Failing wasm tests are unrelated. |
Add support for PKCS#8, SPKI and PEM, both encrypted and unencrypted.
Contributes to #113506