38
38
import org .apache .lucene .store .IOContext ;
39
39
import org .apache .lucene .store .IndexOutput ;
40
40
import org .apache .lucene .store .NIOFSDirectory ;
41
- import org .opensearch . common . Randomness ;
41
+ import org .bouncycastle . crypto . CryptoServicesRegistrar ;
42
42
import org .opensearch .common .crypto .KeyStoreFactory ;
43
43
import org .opensearch .common .crypto .KeyStoreType ;
44
44
import org .opensearch .common .util .io .IOUtils ;
@@ -205,7 +205,7 @@ public void testFailWhenCannotConsumeSecretStream() throws Exception {
205
205
try (IndexOutput indexOutput = directory .createOutput ("opensearch.keystore" , IOContext .DEFAULT )) {
206
206
CodecUtil .writeHeader (indexOutput , "opensearch.keystore" , 3 );
207
207
indexOutput .writeByte ((byte ) 0 ); // No password
208
- SecureRandom random = Randomness . createSecure ();
208
+ SecureRandom random = CryptoServicesRegistrar . getSecureRandom ();
209
209
byte [] salt = new byte [64 ];
210
210
random .nextBytes (salt );
211
211
byte [] iv = new byte [12 ];
@@ -233,7 +233,7 @@ public void testFailWhenCannotConsumeEncryptedBytesStream() throws Exception {
233
233
try (IndexOutput indexOutput = directory .createOutput ("opensearch.keystore" , IOContext .DEFAULT )) {
234
234
CodecUtil .writeHeader (indexOutput , "opensearch.keystore" , 3 );
235
235
indexOutput .writeByte ((byte ) 0 ); // No password
236
- SecureRandom random = Randomness . createSecure ();
236
+ SecureRandom random = CryptoServicesRegistrar . getSecureRandom ();
237
237
byte [] salt = new byte [64 ];
238
238
random .nextBytes (salt );
239
239
byte [] iv = new byte [12 ];
@@ -262,7 +262,7 @@ public void testFailWhenSecretStreamNotConsumed() throws Exception {
262
262
try (IndexOutput indexOutput = directory .createOutput ("opensearch.keystore" , IOContext .DEFAULT )) {
263
263
CodecUtil .writeHeader (indexOutput , "opensearch.keystore" , 3 );
264
264
indexOutput .writeByte ((byte ) 0 ); // No password
265
- SecureRandom random = Randomness . createSecure ();
265
+ SecureRandom random = CryptoServicesRegistrar . getSecureRandom ();
266
266
byte [] salt = new byte [64 ];
267
267
random .nextBytes (salt );
268
268
byte [] iv = new byte [12 ];
@@ -289,7 +289,7 @@ public void testFailWhenEncryptedBytesStreamIsNotConsumed() throws Exception {
289
289
try (IndexOutput indexOutput = directory .createOutput ("opensearch.keystore" , IOContext .DEFAULT )) {
290
290
CodecUtil .writeHeader (indexOutput , "opensearch.keystore" , 3 );
291
291
indexOutput .writeByte ((byte ) 0 ); // No password
292
- SecureRandom random = Randomness . createSecure ();
292
+ SecureRandom random = CryptoServicesRegistrar . getSecureRandom ();
293
293
byte [] salt = new byte [64 ];
294
294
random .nextBytes (salt );
295
295
byte [] iv = new byte [12 ];
@@ -372,15 +372,15 @@ public void testIllegalSettingName() throws Exception {
372
372
public void testFailLoadV1KeystoresInFipsJvm () throws Exception {
373
373
assumeTrue ("Test in FIPS JVM" , inFipsJvm ());
374
374
375
- Exception e = assertThrows (SecurityException .class , () -> generateV1 () );
376
- assertThat (e .getMessage (), containsString ("Only PKCS_11, BCFKS keystores are allowed in FIPS JVM " ));
375
+ Exception e = assertThrows (NoSuchProviderException .class , this :: generateV1 );
376
+ assertThat (e .getMessage (), containsString ("no such provider: SunJCE " ));
377
377
}
378
378
379
379
public void testFailLoadV2KeystoresInFipsJvm () throws Exception {
380
380
assumeTrue ("Test in FIPS JVM" , inFipsJvm ());
381
381
382
- Exception e = assertThrows (SecurityException .class , () -> generateV2 () );
383
- assertThat (e .getMessage (), containsString ("Only PKCS_11, BCFKS keystores are allowed in FIPS JVM " ));
382
+ Exception e = assertThrows (NoSuchProviderException .class , this :: generateV2 );
383
+ assertThat (e .getMessage (), containsString ("no such provider: SunJCE " ));
384
384
}
385
385
386
386
public void testBackcompatV1 () throws Exception {
0 commit comments