Skip to content

Commit 85761ee

Browse files
iigoninbennygoerzigKarstenSchnitterKai Sternad
committed
reduce footprint of BC libraries
Signed-off-by: Igonin <[email protected]> Co-authored-by: Benny Goerzig <[email protected]> Co-authored-by: Karsten Schnitter <[email protected]> Co-authored-by: Kai Sternad <[email protected]>
1 parent b79f303 commit 85761ee

File tree

10 files changed

+5
-32
lines changed

10 files changed

+5
-32
lines changed

distribution/tools/plugin-cli/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ base {
3737
dependencies {
3838
compileOnly project(":server")
3939
compileOnly project(":libs:opensearch-cli")
40+
api "org.bouncycastle:bc-fips:${versions.bouncycastle_jce}"
4041
api "org.bouncycastle:bcpg-fips:${versions.bouncycastle_pg}"
4142
testImplementation(project(":test:framework"))
4243
testImplementation 'com.google.jimfs:jimfs:1.3.0'

distribution/tools/plugin-cli/src/main/java/org/opensearch/tools/cli/plugin/InstallPluginCommand.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.apache.lucene.util.CollectionUtil;
4141
import org.apache.lucene.util.Constants;
4242
import org.bouncycastle.bcpg.ArmoredInputStream;
43-
import org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider;
4443
import org.bouncycastle.openpgp.PGPException;
4544
import org.bouncycastle.openpgp.PGPPublicKey;
4645
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
@@ -633,7 +632,7 @@ void verifySignature(final Path zip, final String urlString) throws IOException,
633632
// compute the signature of the downloaded plugin zip
634633
final PGPPublicKeyRingCollection collection = new PGPPublicKeyRingCollection(ain, new JcaKeyFingerprintCalculator());
635634
final PGPPublicKey key = collection.getPublicKey(signature.getKeyID());
636-
signature.init(new JcaPGPContentVerifierBuilderProvider().setProvider(new BouncyCastleFipsProvider()), key);
635+
signature.init(new JcaPGPContentVerifierBuilderProvider().setProvider("BCFIPS"), key);
637636
final byte[] buffer = new byte[1024];
638637
int read;
639638
while ((read = fin.read(buffer)) != -1) {

distribution/tools/plugin-cli/src/test/java/org/opensearch/tools/cli/plugin/InstallPluginCommandTests.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.bouncycastle.bcpg.ArmoredOutputStream;
4141
import org.bouncycastle.bcpg.BCPGOutputStream;
4242
import org.bouncycastle.bcpg.HashAlgorithmTags;
43-
import org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider;
4443
import org.bouncycastle.openpgp.PGPEncryptedData;
4544
import org.bouncycastle.openpgp.PGPException;
4645
import org.bouncycastle.openpgp.PGPKeyPair;
@@ -1362,7 +1361,7 @@ public PGPSecretKey newSecretKey() throws NoSuchAlgorithmException, NoSuchProvid
13621361
null,
13631362
null,
13641363
new JcaPGPContentSignerBuilder(pkp.getPublicKey().getAlgorithm(), HashAlgorithmTags.SHA256),
1365-
new JcePBESecretKeyEncryptorBuilder(PGPEncryptedData.AES_192, sha1Calc).setProvider(new BouncyCastleFipsProvider())
1364+
new JcePBESecretKeyEncryptorBuilder(PGPEncryptedData.AES_192, sha1Calc).setProvider("BCFIPS")
13661365
.build("passphrase".toCharArray())
13671366
);
13681367
}

gradle/fips.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ if (BuildParams.inFipsJvm) {
3636
fipsPolicy = new File(fipsResourcesDir, "fips_java_bcjsse_11.policy")
3737
}
3838
File fipsTrustStore = new File(fipsResourcesDir, 'cacerts.bcfks')
39-
def bcFips = dependencies.create('org.bouncycastle:bc-fips:2.0.0')
40-
def bcTlsFips = dependencies.create('org.bouncycastle:bctls-fips:2.0.19')
39+
def bcFips = dependencies.create('org.bouncycastle:bc-fips:1.0.2.1')
40+
def bcTlsFips = dependencies.create('org.bouncycastle:bctls-fips:1.0.12.2')
4141

4242
pluginManager.withPlugin('java') {
4343
TaskProvider<ExportOpenSearchBuildResourcesTask> fipsResourcesTask = project.tasks.register('fipsResources', ExportOpenSearchBuildResourcesTask)

server/build.gradle

-9
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,6 @@ dependencies {
115115
// https://mvnrepository.com/artifact/org.roaringbitmap/RoaringBitmap
116116
api libs.roaringbitmap
117117

118-
// BC security provider
119-
api libs.bcjce
120-
api libs.bctls
121-
api libs.bcutil
122-
123118
testImplementation 'org.awaitility:awaitility:4.3.0'
124119
testImplementation(project(":test:framework")) {
125120
// tests use the locally compiled version of server
@@ -169,10 +164,6 @@ tasks.named("testingConventions").configure {
169164
}
170165
}
171166

172-
tasks.named("dependencyLicenses").configure {
173-
mapping from: /bc.*/, to: 'bouncycastle'
174-
}
175-
176167
// Set to current version by default
177168
def japicmpCompareTarget = System.getProperty("japicmp.compare.version")
178169
if (japicmpCompareTarget == null) { /* use latest released version */

server/licenses/bctls-fips-2.0.19.jar.sha1

-1
This file was deleted.

server/licenses/bcutil-fips-2.0.3.jar.sha1

-1
This file was deleted.

server/licenses/bouncycastle-LICENSE.txt

-14
This file was deleted.

server/licenses/bouncycastle-NOTICE.txt

-1
This file was deleted.

0 commit comments

Comments
 (0)