Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force the use of jdk8+ version of Bouncy Castle library #5748

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/


import groovy.transform.CompileStatic
import groovy.transform.Memoized
import net.ltgt.gradle.errorprone.CheckSeverity

Expand Down Expand Up @@ -147,7 +148,20 @@ allprojects {
}
}

dependencies { errorprone 'com.google.errorprone:error_prone_core' }
dependencies {
components.all(BouncyCastleCapability)
errorprone 'com.google.errorprone:error_prone_core'
}

configurations.all {
resolutionStrategy.capabilitiesResolution.withCapability('org.bouncycastle:bcprov-jdk18on') {
selectHighestVersion()
}
resolutionStrategy.capabilitiesResolution.withCapability('org.bouncycastle:bcpkix-jdk18on') {
selectHighestVersion()
}
}


apply plugin: 'com.diffplug.spotless'
spotless {
Expand Down Expand Up @@ -1044,6 +1058,29 @@ dependencies {
errorprone 'com.google.errorprone:error_prone_core'
}

@CompileStatic
class BouncyCastleCapability implements ComponentMetadataRule {
void execute(ComponentMetadataContext context) {
context.details.with {
if (id.group == "org.bouncycastle") {
if(id.name == "bcprov-jdk15on") {
allVariants {
it.withCapabilities {
it.addCapability("org.bouncycastle", "bcprov-jdk18on", "0")
}
}
} else if(id.name == "bcpkix-jdk15on") {
allVariants {
it.withCapabilities {
it.addCapability("org.bouncycastle", "bcpkix-jdk18on", "0")
}
}
}
}
}
}
}

distributions {
main {
contents {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import static io.netty.buffer.ByteBufUtil.hexDump;
import static io.netty.buffer.Unpooled.wrappedBuffer;
import static org.bouncycastle.pqc.math.linearalgebra.ByteUtils.xor;
import static org.hyperledger.besu.ethereum.p2p.rlpx.RlpxFrameConstants.LENGTH_FRAME_SIZE;
import static org.hyperledger.besu.ethereum.p2p.rlpx.RlpxFrameConstants.LENGTH_MAX_MESSAGE_FRAME;

Expand Down Expand Up @@ -396,6 +395,23 @@ private static int padding16(final int size) {
return pad == 0 ? 0 : 16 - pad;
}

/**
* Compute the bitwise XOR of two arrays of bytes. The arrays have to be of same length. No length
* checking is performed.
*
* @param x1 the first array
* @param x2 the second array
* @return x1 XOR x2
*/
private static byte[] xor(final byte[] x1, final byte[] x2) {
byte[] out = new byte[x1.length];

for (int i = x1.length - 1; i >= 0; i--) {
out[i] = (byte) (x1[i] ^ x2[i]);
}
return out;
}

@FormatMethod
private static FramingException error(final String s, final Object... params) {
return new FramingException(String.format(s, params));
Expand Down
24 changes: 24 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3481,6 +3481,14 @@
<sha256 value="16a278d9d5bfb0a79cb2df4588279de24ec18a4adeb8cd36a884ad2f6fb733cb" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.bouncycastle" name="bcpkix-jdk18on" version="1.76">
<artifact name="bcpkix-jdk18on-1.76.jar">
<sha256 value="935a388854c329f9a6f32708f30c90045d2f91294fa687281273145d4cf9834a" origin="Generated by Gradle"/>
</artifact>
<artifact name="bcpkix-jdk18on-1.76.pom">
<sha256 value="f621ec7eaccd323e7d2fbcaf0ffd8720cf6ea842a65c2bd30e830588912c946e" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.bouncycastle" name="bcprov-jdk15on" version="1.68">
<artifact name="bcprov-jdk15on-1.68.jar">
<sha256 value="f732a46c8de7e2232f2007c682a21d1f4cc8a8a0149b6b7bd6aa1afdc65a0f8d" origin="Generated by Gradle"/>
Expand All @@ -3505,6 +3513,14 @@
<sha256 value="c6ccf55fbb9ea10c62bb20622737993099d4774688eaa0d4a45e1eedaadb9134" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.bouncycastle" name="bcprov-jdk18on" version="1.76">
<artifact name="bcprov-jdk18on-1.76.jar">
<sha256 value="fda85d777aaae168015860b23a77cad9b8d3a1d5c904fda875313427bd560179" origin="Generated by Gradle"/>
</artifact>
<artifact name="bcprov-jdk18on-1.76.pom">
<sha256 value="153009592d3b8f8349f97b8f1538bef0c83341b026918a2327dace22334ffee8" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.bouncycastle" name="bcutil-jdk18on" version="1.75">
<artifact name="bcutil-jdk18on-1.75.jar">
<sha256 value="027f36578c1ffdf08878c1cc2aa1e191f4b9da119c1e8f113299c53f298fa664" origin="Generated by Gradle"/>
Expand All @@ -3513,6 +3529,14 @@
<sha256 value="1e60c25685e521d9eba47713df575f8e5171cac6562a243f99616bbf5a8e7b06" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.bouncycastle" name="bcutil-jdk18on" version="1.76">
<artifact name="bcutil-jdk18on-1.76.jar">
<sha256 value="1a65ad02958223a3f31373bd72eea942cafd1b1877a3ed0b492c2487e77c3c27" origin="Generated by Gradle"/>
</artifact>
<artifact name="bcutil-jdk18on-1.76.pom">
<sha256 value="de5ed3ca118c693d190c5c46d89e0380bb5d77acd8a43b5190403e76483f81ed" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.checkerframework" name="checker-compat-qual" version="2.5.5">
<artifact name="checker-compat-qual-2.5.5.jar">
<sha256 value="11d134b245e9cacc474514d2d66b5b8618f8039a1465cdc55bbc0b34e0008b7a" origin="Generated by Gradle"/>
Expand Down
2 changes: 1 addition & 1 deletion gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ dependencyManagement {

dependency 'org.awaitility:awaitility:4.2.0'

dependencySet(group: 'org.bouncycastle', version: '1.75') {
dependencySet(group: 'org.bouncycastle', version: '1.76') {
entry'bcpkix-jdk18on'
entry'bcprov-jdk18on'
}
Expand Down