Repository navigation
Conversation
A legacy encrypted PEM whose DEK-Info IV was 8-15 bytes long for an AES cipher passed the existing 8-byte check (needed for the key derivation salt) and then hit an assertion in rust-openssl, raising PanicException instead of ValueError. Check that the IV length matches the cipher's IV length before using it.
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.
load_pem_private_key()raisesPanicExceptionfor an encryptedtraditional PEM whose
DEK-InfoIV is 8 to 15 bytes long with an AEScipher:
decrypt_pemonly checks that the IV has at least 8 bytes (the keyderivation salt), then passes it to
openssl::symm::decryptiv_len <= iv.len(), so a 16-byte-IV cipherwith a shorter IV panics instead of returning an error
PanicExceptionis not anExceptionsubclass, so callers catchingValueErrororExceptionfor malformed key files do not catch itNow checks the IV length against the cipher's IV length and returns the
existing
PemInvalidIverror (ValueError), whose message now alsomentions the length. Includes a regression test (fails without the
fix) and a changelog entry.
AI assistance was used for the analysis and the patch; reproduced and
checked by hand.