Skip to content

Conversation

@imlk0
Copy link

@imlk0 imlk0 commented Nov 11, 2025

Introduce support for encoding and decoding X25519 private keys using the PKCS#8 standard (both DER and PEM formats). This enables interoperability with OpenSSL, TLS stacks, and other crypto systems.

Changes:

  • Add pkcs8 crate as optional dependency
  • Implement EncodePrivateKey and TryFrom<PrivateKeyInfoRef>
  • Handle nested OCTET STRING structure required by RFC
  • Add tests for DER/PEM encoding round-trips
  • Wire up pem feature behind feature gate

@imlk0
Copy link
Author

imlk0 commented Nov 11, 2025

Hi @tarcieri. This is a implementation for #846. I've written tests, however it seems the current CI setup doesn't seem to test all feature combinations (especially pkcs8 and pem). As a result, these new tests may not be triggered in the CI pipeline. Do you have any advice on how to proceed? Any advice would be welcome!

Introduce support for encoding and decoding X25519 private keys
using the PKCS#8 standard (both DER and PEM formats). This enables
interoperability with OpenSSL, TLS stacks, and other crypto systems.

Changes:
- Add `pkcs8` crate as optional dependency
- Implement `EncodePrivateKey` and `TryFrom<PrivateKeyInfoRef>`
- Handle nested OCTET STRING structure required by RFC
- Add tests for DER/PEM encoding round-trips
- Wire up `pem` feature behind feature gate

Signed-off-by: Kun Lai <laikun@linux.alibaba.com>
Signed-off-by: Kun Lai <laikun@linux.alibaba.com>
@imlk0
Copy link
Author

imlk0 commented Nov 11, 2025

Just pushed a fix to keep Clippy happy. Thanks for catching that! @tarcieri

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