-
Notifications
You must be signed in to change notification settings - Fork 58
fix,tests: Fixed bug where attest cert could not be RSA3072 or RSA4096, removed obsolete tests and consolidated Piv tests #230
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
Conversation
add tests to verify private key with piv and asn encoding/decoding works add tests to verify functionality of RSAPublicKey.CreateFromPkcs8
refactor rsaformat refactor cryptosupport
use TestKeys class use common base class for Piv remove SampleKeyPairs.cs removed CertConverter
Test Results: Windows 2 files 2 suites 9s ⏱️ Results for commit dbb6718. ♻️ This comment has been updated with latest results. |
Test Results: Ubuntu 2 files 2 suites 13s ⏱️ Results for commit dbb6718. ♻️ This comment has been updated with latest results. |
Test Results: MacOS 2 files 2 suites 9s ⏱️ Results for commit dbb6718. ♻️ This comment has been updated with latest results. |
Yubico.YubiKey/tests/integration/Yubico/YubiKey/DeviceResetTests.cs
Outdated
Show resolved
Hide resolved
Yubico.YubiKey/src/Yubico/YubiKey/Fido2/Commands/CredentialManagementCommand.cs
Show resolved
Hide resolved
remove unnecessary test on size of certs reduced test logic remove unused class add default pin and puk to base class
fix tests with auth add complex pin and puk
- added field DefaultManagementKey - early exit when fail TryVerifyPin - use range operator
7164b9e
to
a7b54cc
Compare
…essful (PivSession) - additional: added param docs for mutualAuthentication
- lookup of key definitions - determine valid attestation cert
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.
Pull Request Overview
This pull request fixes a bug preventing RSA3072 and RSA4096 attestation certificates from being used, removes obsolete tests, and refactors several command and cryptographic methods to improve clarity and consistency. Key changes include:
- Bug fix and consolidation of key size and definition lookup in PIV commands.
- Refactoring of obsolete test invocations and adjustments in exception handling.
- Code style improvements such as replacing explicit equality checks with negated Boolean expressions and updating inline comments.
Reviewed Changes
Copilot reviewed 148 out of 148 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/GetMetadataCommand.cs | Removed explicit initialization of _slotNumber in the parameterless constructor. |
Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/CreateAttestationStatementCommand.cs | Replaced equality checks with negated conditions for slot number validation. |
Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateSignCommand.cs | Refactored algorithm determination into a separate method using LINQ. |
Yubico.YubiKey/src/Yubico/YubiKey/Fido2/Commands/* | Updated ReadOnlyMemory constructions to use full authParam data. |
Yubico.YubiKey/src/Yubico/YubiKey/Cryptography/RSAPublicKey.cs | Moved private key parameter validation into CreateFromParameters and updated key definition lookup. |
Yubico.YubiKey/src/Yubico/YubiKey/Cryptography/KeyDefinitions.cs | Introduced a convenience method for RSA modulus length and clarified ECDSA OID error handling. |
Yubico/YubiKey/src/Yubico/YubiKey/Cryptography/ECPublicKey.cs | Updated return types for public key creation methods for better type clarity. |
Yubico.YubiKey/src/Yubico/YubiKey/Cryptography/AsnUtilities.cs | Revised bit clamping checks for X25519 with updated (but inconsistent) inline comments. |
Yubico.YubiKey/src/Yubico/YubiKey/Cryptography/AsnPublicKeyEncoder.cs | Changed exception type and message for missing RSA parameters. |
Various examples under /examples/PivSampleCode/ | Added pragma warning disables around obsolete API usage. |
Comments suppressed due to low confidence (1)
Yubico.YubiKey/src/Yubico/YubiKey/Cryptography/AsnPublicKeyEncoder.cs:105
- [nitpick] The exception thrown for missing RSA parameter values now uses InvalidOperationException with a different message. Consider aligning the exception type and message with similar methods to ensure consistency in error reporting.
if (parameters.Exponent == null ||
tests: fixed comments and code restructure
# Conflicts: # Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivSession.Attestation.cs # Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivSession.Crypto.cs # Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/ImportTests.cs # Yubico.YubiKey/tests/unit/Yubico/YubiKey/Cryptography/ECPrivateKeyTests.cs # Yubico.YubiKey/tests/unit/Yubico/YubiKey/Cryptography/ECPublicKeyTests.cs # Yubico.YubiKey/tests/unit/Yubico/YubiKey/Cryptography/RSAPublicKeyTests.cs # Yubico.YubiKey/tests/unit/Yubico/YubiKey/Piv/PivEncoderDecoderTests.cs # Yubico.YubiKey/tests/unit/Yubico/YubiKey/Piv/PivPrivateKeyTests.cs # Yubico.YubiKey/tests/unit/Yubico/YubiKey/Piv/PivPublicKeyTests.cs # Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/KeyConverter.cs # Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/PivKeyExtensions.cs # Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/SampleKeyPairs.cs # Yubico.YubiKey/tests/utilities/Yubico/YubiKey/TestUtilities/TestKeyExtensions.cs
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.
LGTM. I ran the integration tests locally also. See my comments as ideas for future improvements.
Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivSession.Attestation.cs
Outdated
Show resolved
Hide resolved
Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/LargeBlobTests.cs
Outdated
Show resolved
Hide resolved
public void ChangeRetryCounts_Succeeds( | ||
StandardTestDevice testDeviceType) |
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.
out of curiosity, is this the way the formatter works on the c# code?
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.
I dont know honestly, this is the way the formatter works with the current .editorconfig and Rider, so I dont question it too much. Im sure it could be optimized. I would only want it to split into rows if the params are larger than 2. Now I think it splits when it reaches a current viewport width
Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PivSessionIntegrationTestBase.cs
Outdated
Show resolved
Hide resolved
Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/PivSessionIntegrationTestBase.cs
Outdated
Show resolved
Hide resolved
remove comments, revert test change, simpler complexpin and complexpuk
Description
This PR fixes a bug where attestation cert could not be RSA3072 or RSA4096, as well as updates a number of tests that were made obsolete in recent refactors around ECPublicKey, ECPrivateKey, RSAPublicKey and RSAPrivateKey.
Additional changes:
Type of change
How has this been tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test configuration:
Checklist:
dotnet format
to format my codeFootnotes
See Yubikey models (Multi-protocol, Security Key, FIPS, Bio, YubiHSM, YubiHSM FIPS) ↩