Repository navigation
pkcs12: support supplementary Unicode passwords in UTF-8 KDF - #2477
Open
domenkozar wants to merge 1 commit into
Open
domenkozar wants to merge 1 commit into
domenkozar wants to merge 1 commit into
Conversation
domenkozar
marked this pull request as ready for review
October 8, 2026 14:52
This was referenced Oct 8, 2026
This branch has not been deployed
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.
derive_key_utf8currently constructs an ASN.1BmpString, so passwords containing supplementary Unicode characters fail before derivation. OpenSSL'sPKCS12_key_gen_utf8accepts these passwords using UTF-16BE surrogate pairs; consequently a PFX password such aspäss🔑can be opened by OpenSSL but fails in Rust consumers of this function.Encode UTF-8 passwords directly as null-terminated UTF-16BE in a zeroizing buffer. This intentionally extends the UTF-8 helper beyond its previous BMP-only acceptance for OpenSSL interoperability.
derive_key_bmpretains its strict ASN.1 BMP input, and derived output for existing BMP passwords, empty passwords, and embedded NULs is unchanged. The existing invalid-rounds behavior remains covered.Replace the supplementary-character rejection test with independent OpenSSL 3.6.4 vectors covering encryption-key, IV, and MAC derivation, including output spanning multiple digest blocks. Add equivalence coverage for UTF-8 and BMP helpers. The vector-generation command is recorded in the test.
Validation with rustc 1.97.1:
cargo fmt --all -- --checkcargo clippy -p pkcs12 --all-features --tests -- -D warningscargo test -p pkcs12 --all-featurespem,kdf, andpem,kdf, withRUSTFLAGS=-Dwarnings.Prepared with Codex assistance.