JCE: add support for SecureRandom.getInstance("DEFAULT"), maps to HashDRBG

pull/72/head
Chris Conlon 2024-04-05 10:04:29 -06:00
parent 430b8b7503
commit 45deb2802f
3 changed files with 10 additions and 1 deletions

View File

@ -34,6 +34,7 @@ The JCE provider currently supports the following algorithms:
SHA-512 SHA-512
SecureRandom Class SecureRandom Class
DEFAULT (maps to HashDRBG)
HashDRBG HashDRBG
Cipher Class Cipher Class

View File

@ -65,6 +65,8 @@ public final class WolfCryptProvider extends Provider {
/* SecureRandom */ /* SecureRandom */
/* TODO: May need to add "SHA1PRNG" alias, other JCA consumemrs may /* TODO: May need to add "SHA1PRNG" alias, other JCA consumemrs may
* explicitly request it? Needs more testing. */ * explicitly request it? Needs more testing. */
put("SecureRandom.DEFAULT",
"com.wolfssl.provider.jce.WolfCryptRandom");
put("SecureRandom.HashDRBG", put("SecureRandom.HashDRBG",
"com.wolfssl.provider.jce.WolfCryptRandom"); "com.wolfssl.provider.jce.WolfCryptRandom");

View File

@ -57,7 +57,13 @@ public class WolfCryptRandomTest {
public void testGetRandomFromProvider() public void testGetRandomFromProvider()
throws NoSuchProviderException, NoSuchAlgorithmException { 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 @Test