Skip to content

Conversation

@cconlon
Copy link
Member

@cconlon cconlon commented Nov 7, 2025

This PR adds our own implementation of RSA KeyFactory (KeyFactory.getInstance('RSA')).

Additions include:

  • WolfCryptRSAKeyFactory: Handles key generation from specs (RSAPrivateCrtKeySpec, RSAPrivateKeySpec, RSAPublicKeySpec, X509EncodedKeySpec, PKCS8EncodedKeySpec) and key translation
  • WolfCryptRSAPrivateCrtKey: CRT-enabled RSA private keys (implements RSAPrivateCrtKey)
  • WolfCryptRSAPrivateKey: Non-CRT RSA private keys (implements RSAPrivateKey only)
  • WolfCryptRSAPublicKey: RSA public key implementation
  • JNI support: Wrapped wc_RsaImportCrtKey() and wc_RsaExportCrtKey() for raw RSA parameter import/export

Unit tests included for testing and regression.

@cconlon cconlon self-assigned this Nov 7, 2025
@cconlon cconlon requested a review from Copilot November 7, 2025 17:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds RSA KeyFactory support to the wolfJCE provider, enabling conversion and management of RSA keys across different formats. The implementation includes comprehensive test coverage and JNI bindings for exporting/importing CRT parameters.

  • Adds complete RSA KeyFactory implementation with support for various KeySpec formats (X509, PKCS8, RSAPublicKeySpec, RSAPrivateCrtKeySpec, RSAPrivateKeySpec)
  • Implements separate key classes for RSA public keys, CRT private keys, and non-CRT private keys
  • Adds JNI native methods for exporting and importing RSA CRT key parameters

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
WolfCryptRSAKeyFactory.java Main KeyFactory implementation for RSA key format conversions
WolfCryptRSAPublicKey.java RSAPublicKey implementation with X.509 encoding support
WolfCryptRSAPrivateCrtKey.java RSAPrivateCrtKey implementation with full CRT parameters
WolfCryptRSAPrivateKey.java RSAPrivateKey implementation for non-CRT keys
WolfCryptRSAKeyFactoryTest.java Comprehensive test suite with 15 test methods
jni_rsa.c JNI bindings for wc_RsaExportCrtKey and wc_RsaImportCrtKey
Rsa.java Java wrappers for new native export/import methods
WolfCryptProvider.java Registers RSA KeyFactory service
WolfCryptCipher.java Updates error message for clarity
README_JCE.md Documents new RSA KeyFactory support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cconlon cconlon assigned rlm2002 and cconlon and unassigned cconlon and rlm2002 Nov 10, 2025
@cconlon cconlon assigned rlm2002 and unassigned cconlon Nov 10, 2025
@rlm2002 rlm2002 merged commit 0465da1 into wolfSSL:master Nov 10, 2025
46 checks passed
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.

2 participants