Force the use of jdk18 version of Bouncy Castle library (#5748)

This avoid that any dependency can include the jdk15 version in the distribution.
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
pull/6028/head
Fabio Di Fabio 1 year ago committed by GitHub
parent 1c293fed97
commit e5c9f55f8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 39
      build.gradle
  2. 18
      ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/framing/Framer.java
  3. 24
      gradle/verification-metadata.xml
  4. 2
      gradle/versions.gradle

@ -14,6 +14,7 @@
*/ */
import groovy.transform.CompileStatic
import groovy.transform.Memoized import groovy.transform.Memoized
import net.ltgt.gradle.errorprone.CheckSeverity import net.ltgt.gradle.errorprone.CheckSeverity
@ -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' apply plugin: 'com.diffplug.spotless'
spotless { spotless {
@ -1044,6 +1058,29 @@ dependencies {
errorprone 'com.google.errorprone:error_prone_core' 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 { distributions {
main { main {
contents { contents {

@ -16,7 +16,6 @@ package org.hyperledger.besu.ethereum.p2p.rlpx.framing;
import static io.netty.buffer.ByteBufUtil.hexDump; import static io.netty.buffer.ByteBufUtil.hexDump;
import static io.netty.buffer.Unpooled.wrappedBuffer; 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_FRAME_SIZE;
import static org.hyperledger.besu.ethereum.p2p.rlpx.RlpxFrameConstants.LENGTH_MAX_MESSAGE_FRAME; import static org.hyperledger.besu.ethereum.p2p.rlpx.RlpxFrameConstants.LENGTH_MAX_MESSAGE_FRAME;
@ -396,6 +395,23 @@ public class Framer {
return pad == 0 ? 0 : 16 - pad; 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 @FormatMethod
private static FramingException error(final String s, final Object... params) { private static FramingException error(final String s, final Object... params) {
return new FramingException(String.format(s, params)); return new FramingException(String.format(s, params));

@ -3481,6 +3481,14 @@
<sha256 value="16a278d9d5bfb0a79cb2df4588279de24ec18a4adeb8cd36a884ad2f6fb733cb" origin="Generated by Gradle"/> <sha256 value="16a278d9d5bfb0a79cb2df4588279de24ec18a4adeb8cd36a884ad2f6fb733cb" origin="Generated by Gradle"/>
</artifact> </artifact>
</component> </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"> <component group="org.bouncycastle" name="bcprov-jdk15on" version="1.68">
<artifact name="bcprov-jdk15on-1.68.jar"> <artifact name="bcprov-jdk15on-1.68.jar">
<sha256 value="f732a46c8de7e2232f2007c682a21d1f4cc8a8a0149b6b7bd6aa1afdc65a0f8d" origin="Generated by Gradle"/> <sha256 value="f732a46c8de7e2232f2007c682a21d1f4cc8a8a0149b6b7bd6aa1afdc65a0f8d" origin="Generated by Gradle"/>
@ -3505,6 +3513,14 @@
<sha256 value="c6ccf55fbb9ea10c62bb20622737993099d4774688eaa0d4a45e1eedaadb9134" origin="Generated by Gradle"/> <sha256 value="c6ccf55fbb9ea10c62bb20622737993099d4774688eaa0d4a45e1eedaadb9134" origin="Generated by Gradle"/>
</artifact> </artifact>
</component> </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"> <component group="org.bouncycastle" name="bcutil-jdk18on" version="1.75">
<artifact name="bcutil-jdk18on-1.75.jar"> <artifact name="bcutil-jdk18on-1.75.jar">
<sha256 value="027f36578c1ffdf08878c1cc2aa1e191f4b9da119c1e8f113299c53f298fa664" origin="Generated by Gradle"/> <sha256 value="027f36578c1ffdf08878c1cc2aa1e191f4b9da119c1e8f113299c53f298fa664" origin="Generated by Gradle"/>
@ -3513,6 +3529,14 @@
<sha256 value="1e60c25685e521d9eba47713df575f8e5171cac6562a243f99616bbf5a8e7b06" origin="Generated by Gradle"/> <sha256 value="1e60c25685e521d9eba47713df575f8e5171cac6562a243f99616bbf5a8e7b06" origin="Generated by Gradle"/>
</artifact> </artifact>
</component> </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"> <component group="org.checkerframework" name="checker-compat-qual" version="2.5.5">
<artifact name="checker-compat-qual-2.5.5.jar"> <artifact name="checker-compat-qual-2.5.5.jar">
<sha256 value="11d134b245e9cacc474514d2d66b5b8618f8039a1465cdc55bbc0b34e0008b7a" origin="Generated by Gradle"/> <sha256 value="11d134b245e9cacc474514d2d66b5b8618f8039a1465cdc55bbc0b34e0008b7a" origin="Generated by Gradle"/>

@ -151,7 +151,7 @@ dependencyManagement {
dependency 'org.awaitility:awaitility:4.2.0' 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'bcpkix-jdk18on'
entry'bcprov-jdk18on' entry'bcprov-jdk18on'
} }

Loading…
Cancel
Save