Skip to content

Comments

Add toString() to WolfCryptRandom, init fixes for serialization#154

Merged
rlm2002 merged 2 commits intowolfSSL:masterfrom
cconlon:drbgFixes
Sep 10, 2025
Merged

Add toString() to WolfCryptRandom, init fixes for serialization#154
rlm2002 merged 2 commits intowolfSSL:masterfrom
cconlon:drbgFixes

Conversation

@cconlon
Copy link
Member

@cconlon cconlon commented Sep 8, 2025

This PR adds a toString() implementation to WolfCryptRandom, which returns the proper string details that are expected from printing a SecureRandom object.

It also makes sure this.rng (Rng) is initialized when methods are called, which fix some edge cases when using serialization of WolfCryptRandom objects.

JUnit tests have been included for regression prevention.

This fixes a few of the OpenJDK SunJCE DRBG tests.

@cconlon cconlon self-assigned this Sep 8, 2025
@cconlon cconlon requested a review from Copilot September 8, 2025 22:11
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 toString() implementation to WolfCryptRandom and fixes serialization edge cases by ensuring the RNG is properly initialized when methods are called. The changes improve compatibility with OpenJDK SunJCE DRBG tests.

  • Added toString() method returning standardized DRBG string format
  • Implemented lazy initialization pattern to handle serialization/deserialization scenarios
  • Added comprehensive JUnit tests for serialization/deserialization functionality

Reviewed Changes

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

File Description
WolfCryptRandom.java Added toString() method, lazy RNG initialization, and null parameter validation
WolfCryptRandomTest.java Added serialization/deserialization test with helper methods

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

@rlm2002 rlm2002 merged commit 084fd6a into wolfSSL:master Sep 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