Skip to content

Commit

Permalink
Merge pull request #72 from cconlon/SecureRandomDEFAULT
Browse files Browse the repository at this point in the history
JCE: add support for SecureRandom.getInstance("DEFAULT")
  • Loading branch information
lealem47 authored Apr 5, 2024
2 parents 430b8b7 + 45deb28 commit 3158aa8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README_JCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The JCE provider currently supports the following algorithms:
SHA-512

SecureRandom Class
DEFAULT (maps to HashDRBG)
HashDRBG

Cipher Class
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/wolfssl/provider/jce/WolfCryptProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public WolfCryptProvider() {
/* SecureRandom */
/* TODO: May need to add "SHA1PRNG" alias, other JCA consumemrs may
* explicitly request it? Needs more testing. */
put("SecureRandom.DEFAULT",
"com.wolfssl.provider.jce.WolfCryptRandom");
put("SecureRandom.HashDRBG",
"com.wolfssl.provider.jce.WolfCryptRandom");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ public static void testProviderInstallationAtRuntime() {
public void testGetRandomFromProvider()
throws NoSuchProviderException, NoSuchAlgorithmException {

SecureRandom rand = SecureRandom.getInstance("HashDRBG", "wolfJCE");
SecureRandom rand = null;

/* HashDRBG */
rand = SecureRandom.getInstance("HashDRBG", "wolfJCE");

/* DEFAULT */
rand = SecureRandom.getInstance("DEFAULT", "wolfJCE");
}

@Test
Expand Down

0 comments on commit 3158aa8

Please sign in to comment.