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
SecureRandom Class
DEFAULT (maps to HashDRBG)
HashDRBG
Cipher Class

View File

@ -65,6 +65,8 @@ public final class WolfCryptProvider extends Provider {
/* 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");

View File

@ -57,7 +57,13 @@ public class WolfCryptRandomTest {
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