Skip to content

Enable key encoding with the pkcs5 feature - #795

Open
mottopanikeiku wants to merge 1 commit into
RustCrypto:masterfrom
mottopanikeiku:pkcs5-enable-key-encoding
Open

mottopanikeiku wants to merge 1 commit into
RustCrypto:masterfrom
mottopanikeiku:pkcs5-enable-key-encoding

Conversation

@mottopanikeiku

Copy link
Copy Markdown

Summary

With default features off, pkcs5 turns on encryption in the pkcs8 dependency but not this crate's encoding feature, so rsa::pkcs8 and the decoding traits on PrivateKey aren't there and the encrypted-PKCS#8 support can't be used. pkcs5 now enables encoding. I added a short crate-docs example that only compiles with pkcs5.

Reproduce

rsa = { version = "0.10", default-features = false, features = ["pkcs5"] }
use rsa::{PrivateKey, pkcs8::{self, DecodePrivateKey}};

fn load_key(der: &[u8], password: &[u8]) -> pkcs8::Result<PrivateKey> {
    PrivateKey::from_pkcs8_encrypted_der(der, password)
}

Before: rsa::pkcs8 is configured out (E0432). After: it compiles.

Tests

cargo test -p rsa --no-default-features --features pkcs5 --doc fails on master with the new example and passes here. fmt and clippy (1.87) are clean.

I used AI assistance (Claude and GPT-6 Astra) to find, fix and test this.

I made `pkcs5` enable the RSA encoding traits it needs even when default features are off. I added a doctest showing how to load an encrypted PKCS#8 key with that feature.

Assisted-by: Claude
Assisted-by: GPT-6 Astra
Signed-off-by: mottopanikeiku <176798723+mottopanikeiku@users.noreply.github.com>
@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.29%. Comparing base (90fb187) to head (59240f8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #795      +/-   ##
==========================================
+ Coverage   93.14%   93.29%   +0.14%     
==========================================
  Files          29       29              
  Lines        4097     4158      +61     
==========================================
+ Hits         3816     3879      +63     
+ Misses        281      279       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant