Repository navigation
Reject Curve25519/Curve448 keys with the wrong length - #825
Open
dlazobnaKocka wants to merge 1 commit into
Open
dlazobnaKocka wants to merge 1 commit into
dlazobnaKocka wants to merge 1 commit into
Conversation
The *_import_raw() functions checked the key length with LTC_ARGCHK. A certificate or SSH public key with a short Ed25519 key could reach them, so the default build called abort(). With ARGTYPE 2 or 3 the memcpy read past the end of the input buffer. The PKCS#8 and SubjectPublicKeyInfo importers only checked the upper bound. A 1 byte key returned CRYPT_OK and the rest of the key buffer kept whatever was in it before. Return CRYPT_PK_INVALID_SIZE in all of these cases. Fixes: 52a24ca ("add Curve25519 API") Fixes: 076a110 ("Ed448 + X448") Fixes: 8d19047 ("Add support for more PEM file types + some fixes") Fixes: 208ee2b ("Refactor SubjectPublicKeyInfo import")
Member
|
Looks good to me small correction: the default build via plain make or CMake Release uses ARGTYPE=4 not ARGTYPE=0 |
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.
A certificate or SSH2 public key with a short Ed25519, X25519, Ed448 or X448 key reaches the *_import_raw() functions through x509_import_spki() or pem_ssh.c. Those check the length with LTC_ARGCHK, so the default build calls abort(). With ARGTYPE 2 or 3 the memcpy reads past the end of the input buffer.
This SSH2 key with a 1 byte Ed25519 key is enough, passed to pem_decode_openssh():
The PKCS#8 and SubjectPublicKeyInfo importers had a related problem. They only checked the upper bound, so a 1 byte key returned CRYPT_OK and the rest of the key buffer kept whatever was in it before.
The fix returns CRYPT_PK_INVALID_SIZE in all of these cases. Each curve gets a small test with a short PKCS#8, SPKI and raw key. The tests fail on develop and pass with the fix.
Checklist
Fixes:tag to the commit message