fixes #12949 -- added support for decrypting des-cbc-md5 keys#12978
Merged
reaperhulk merged 1 commit intopyca:mainfrom May 25, 2025
Merged
fixes #12949 -- added support for decrypting des-cbc-md5 keys#12978reaperhulk merged 1 commit intopyca:mainfrom
reaperhulk merged 1 commit intopyca:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes #12949 by adding support for decrypting private keys encrypted with the DES-CBC/MD5 PBE scheme. Key changes include:
- A new test case in the serialization tests for loading MD5/DES-CBC encrypted keys (with a FIPS skip marker).
- A new OID constant and a corresponding variant in the AlgorithmParameters enum to support PBE_WITH_MD5_AND_DES_CBC.
- Implementation of the pkcs5_pbe_decrypt function in the pkcs8 module and addition of a PBKDF1 function to support key derivation.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/hazmat/primitives/test_serialization.py | Added new test for PKCS#8 decryption using MD5 and DES-CBC with proper FIPS-compliance skipping. |
| src/rust/cryptography-x509/src/oid.rs | Defined a new constant for the PBE_WITH_MD5_AND_DES_CBC OID. |
| src/rust/cryptography-x509/src/common.rs | Extended the AlgorithmParameters enum and introduced a new PbeParams struct to support DES-CBC mode. |
| src/rust/cryptography-key-parsing/src/pkcs8.rs | Added the pkcs5_pbe_decrypt function and updated parse_encrypted_private_key to utilize it. |
| src/rust/cryptography-crypto/src/pbkdf1.rs | Implemented PBKDF1 as defined in RFC 2898 for PKCS#5 v1.5 PBE algorithms. |
32eb0df to
bf4e4a1
Compare
Member
Author
|
sigh, our we need some way to check if we have single des in the tests |
9725330 to
f8ad758
Compare
reaperhulk
approved these changes
May 25, 2025
alex
added a commit
to alex/cryptography
that referenced
this pull request
May 25, 2025
reaperhulk
added a commit
that referenced
this pull request
May 25, 2025
* Rename PBES1 types to better match their origins in the spec (#12976) PBEParams is defined in RFC 8018 as going with PBES1, but then its also used by PKCS#12 ciphers in RFC 7292. * add vector and test for longer salt length in PBE (#12977) * add vector and test for longer salt length in PBE * Update docs/development/test-vectors.rst Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com> --------- Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com> * fixes #12949 -- added support for decrypting des-cbc-md5 keys (#12978) * add missing 45.0.0 changelog entry (#12946) * add missing 45.0.0 changelog entry @Yossarian pointed out that we missed this breaking change #12110 * Update CHANGELOG.rst * oops * changelog + version bump * add pbeWithMD5AndDES-CBC test vector (#12956) * typo * fix documentation for the decrepit algorithms module (#12953) --------- Co-authored-by: Paul Kehrer <paul.l.kehrer@gmail.com>
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.
Implemented by Zed (claude sonnet 4) + a bit of cleanup by me with the following prompt: