Skip to content

Conversation

@cconlon
Copy link
Member

@cconlon cconlon commented Jan 9, 2026

This PR wraps native Base16_Encode() and Base16_Decode() for in WolfCrypt.toHexString() and WolfCrypt.hexStringToByteArray() methods. Includes Base16Enabled() feature check and JUnit tests.

public static String toHexString(byte[] data);
public static byte[] hexStringToByteArray(String hexStr);

The wolfSSL native APIs above require WOLFSSL_BASE16 to be defined, but since --enable-jni already defines OPENSSL_EXTRA, which automatically defines WOLFSSL_BASE16, users shouldn't need to add anything else to native wolfSSL configure.

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 hexadecimal string conversion capabilities to the WolfCrypt class by wrapping native wolfSSL Base16 encoding/decoding functions. The implementation includes proper feature detection, comprehensive error handling, and extensive test coverage.

  • Adds toHexString() method to convert byte arrays to hexadecimal strings
  • Adds hexStringToByteArray() method to convert hexadecimal strings back to byte arrays
  • Includes Base16Enabled() feature detection method

Reviewed changes

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

Show a summary per file
File Description
src/main/java/com/wolfssl/wolfcrypt/WolfCrypt.java Adds public API methods for hex conversion with proper validation and error handling
jni/jni_wolfcrypt.c Implements JNI native methods with overflow protection, memory management, and error handling
jni/include/com_wolfssl_wolfcrypt_WolfCrypt.h Declares JNI function signatures for new native methods
src/test/java/com/wolfssl/wolfcrypt/test/WolfCryptTest.java Provides comprehensive test coverage including edge cases, thread safety, and known test vectors
src/test/java/com/wolfssl/wolfcrypt/test/WolfCryptTestSuite.java Registers new test class in the test suite

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

@rlm2002 rlm2002 merged commit c23abe2 into wolfSSL:master Jan 9, 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