Repository navigation
Check the version of DSA and EC private keys - #826
Merged
Merged
Conversation
dsa_import() and ecc_import_openssl() decoded the version of a DSAPrivateKey or ECPrivateKey but never checked it, so a key with any version was accepted. This is the same problem as libtom#803 for RSA. DSAPrivateKey has to be version 0 and ECPrivateKey version 1. Return CRYPT_INVALID_PACKET otherwise. Fixes: ed6897d ("DSA private keys are being exported to a compatible with OpenSSL and GnuTLS format.") Fixes: 05d397d ("ECC improved import/export")
Member
|
Looks good to me |
sjaeckel
approved these changes
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Same problem as #803 (fixed in #814), this time for DSA and EC.
dsa_import() and ecc_import_openssl() decode the version of a DSAPrivateKey or ECPrivateKey but never check it, so a key with any version is accepted. The key itself is still validated, so this is about strict parsing, not a crash.
DSAPrivateKey now has to be version 0 and ECPrivateKey version 1, otherwise the import returns CRYPT_INVALID_PACKET. For EC both the curve OID form and the explicit curve form are checked.
The tests flip the version byte in the existing DSA and EC test keys. They fail on develop and pass with the fix.
Checklist
Fixes:tag to the commit message