Skip to content

Comments

Add wolfJCE EC KeyFactory implementation#159

Merged
rlm2002 merged 2 commits intowolfSSL:masterfrom
cconlon:ecKeyFactory
Sep 23, 2025
Merged

Add wolfJCE EC KeyFactory implementation#159
rlm2002 merged 2 commits intowolfSSL:masterfrom
cconlon:ecKeyFactory

Conversation

@cconlon
Copy link
Member

@cconlon cconlon commented Sep 19, 2025

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

We were previously using the EC KeyFactory from the SunEC provider, since the class itself was not doing any crypto proper just conversion of keying material. In running the OpenJDK SunJCE tests on top of wolfJCE, we observed some areas of the SunEC implementation that call down to SunJCE. For systems that have removed SunJCE, this is problematic and implementing our own version resolves the issue.

JUnit tests included for testing and regression.

@cconlon cconlon self-assigned this Sep 19, 2025
@cconlon cconlon requested a review from Copilot September 19, 2025 16:09
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 implements the EC KeyFactory (KeyFactory.getInstance('EC')) for wolfJCE, enabling conversion of EC keying material between various KeySpec formats using wolfCrypt rather than the SunEC provider. The change addresses compatibility issues when SunJCE is not available, as wolfJCE now provides its own complete EC KeyFactory implementation.

Key changes:

  • Added new EC KeyFactory implementation with support for PKCS8EncodedKeySpec, X509EncodedKeySpec, ECPrivateKeySpec, and ECPublicKeySpec conversion
  • Extended Ecc native wrapper with curve parameter management and raw key import/export functionality
  • Added comprehensive test coverage for the new KeyFactory implementation

Reviewed Changes

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

Show a summary per file
File Description
src/main/java/com/wolfssl/provider/jce/WolfCryptECKeyFactory.java Complete EC KeyFactory implementation handling key conversions between various formats
src/main/java/com/wolfssl/provider/jce/WolfCryptECPrivateKey.java EC private key implementation supporting DER encoding and raw parameter extraction
src/main/java/com/wolfssl/provider/jce/WolfCryptECPublicKey.java EC public key implementation supporting X.509 encoding and coordinate extraction
src/main/java/com/wolfssl/provider/jce/WolfCryptECParameterSpec.java Enhanced EC parameter handling with curve name metadata and parameter validation
src/main/java/com/wolfssl/wolfcrypt/Ecc.java Extended native interface with curve parameter access and raw key import/export
src/main/java/com/wolfssl/provider/jce/WolfCryptProvider.java Registration of the new EC KeyFactory service
jni/jni_ecc.c Native implementation for curve parameter extraction and raw key operations
src/test/java/com/wolfssl/provider/jce/test/WolfCryptECKeyFactoryTest.java Comprehensive test suite for the EC KeyFactory implementation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or 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 13 out of 13 changed files in this pull request and generated 6 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@cconlon cconlon force-pushed the ecKeyFactory branch 2 times, most recently from e686189 to 644dfed Compare September 22, 2025 22:14
@cconlon cconlon requested a review from Copilot September 22, 2025 22:14
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 28 out of 28 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@rlm2002 rlm2002 merged commit 0a4b4f4 into wolfSSL:master Sep 23, 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