Distinguish between Windows & other OSes when testing with SecureRandom, to use available PRNG algorithm (#14874)
Closes #14610
This commit is contained in:
parent
d859b03193
commit
70e2843a58
1 changed files with 4 additions and 1 deletions
|
@ -39,7 +39,7 @@ public class ElytronHmacTest extends HmacTest {
|
|||
public void testHmacSignaturesUsingKeyGen() throws Exception {
|
||||
|
||||
KeyGenerator keygen = KeyGenerator.getInstance("HmacSHA256");
|
||||
SecureRandom random = SecureRandom.getInstance("NativePRNG");
|
||||
SecureRandom random = isWindows() ? SecureRandom.getInstance("Windows-PRNG") : SecureRandom.getInstance("NativePRNG");
|
||||
random.setSeed(UUID.randomUUID().toString().getBytes());
|
||||
keygen.init(random);
|
||||
SecretKey secret = keygen.generateKey();
|
||||
|
@ -50,4 +50,7 @@ public class ElytronHmacTest extends HmacTest {
|
|||
JWSInput input = new JWSInput(encoded);
|
||||
Assert.assertTrue(HMACProvider.verify(input, secret));
|
||||
}
|
||||
private boolean isWindows(){
|
||||
return System.getProperty("os.name").startsWith("Windows");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue