Skip to content

Conversation

@cconlon
Copy link
Member

@cconlon cconlon commented Jan 8, 2026

This PR wraps native wolfSSL APIs wc_KeyPemToDer(), wc_CertPemToDer(), and wc_PubKeyPemToDer() in the com.wolfssl.WolfCrypt class:

public static byte[] keyPemToDer(byte[] pem, String password);
public static byte[] certPemToDer(byte[] pem);
public static byte[] pubKeyPemToDer(byte[] pem);

JUnit tests are added as part of this PR.

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 PEM to DER conversion functionality to the WolfCrypt Java bindings by wrapping native wolfSSL APIs (wc_KeyPemToDer(), wc_CertPemToDer(), and wc_PubKeyPemToDer()) in the com.wolfssl.WolfCrypt class.

Key Changes

  • Three new public static methods in WolfCrypt.java for PEM to DER conversions (private keys, certificates, public keys)
  • JNI C implementation with proper memory management and error handling
  • Comprehensive JUnit test suite with 22 test cases covering normal operations, edge cases, and threading scenarios

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/main/java/com/wolfssl/wolfcrypt/WolfCrypt.java Adds three public static methods (keyPemToDer, certPemToDer, pubKeyPemToDer) with input validation and documentation
jni/jni_wolfcrypt.c Implements JNI native functions with proper memory management, error handling, and conditional compilation
jni/include/com_wolfssl_wolfcrypt_WolfCrypt.h Adds JNI function declarations for the three new native methods
src/test/java/com/wolfssl/wolfcrypt/test/WolfCryptTest.java Comprehensive test suite with 585 lines covering functionality, error cases, and thread safety
src/test/java/com/wolfssl/wolfcrypt/test/WolfCryptTestSuite.java Adds WolfCryptTest.class to the test suite

💡 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 4 out of 4 changed files in this pull request and generated 5 comments.


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

@cconlon cconlon assigned rlm2002 and unassigned cconlon Jan 14, 2026
@rlm2002 rlm2002 merged commit 6700484 into wolfSSL:master Jan 14, 2026
57 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