diff --git a/build.gradle b/build.gradle index 8ce41eb46f1..a1950eb65db 100644 --- a/build.gradle +++ b/build.gradle @@ -14,6 +14,7 @@ */ +import groovy.transform.CompileStatic import groovy.transform.Memoized 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' spotless { @@ -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 { diff --git a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/framing/Framer.java b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/framing/Framer.java index 2e9cad6dfe5..1302b3765d4 100644 --- a/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/framing/Framer.java +++ b/ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/rlpx/framing/Framer.java @@ -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; @@ -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)); diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index bf2f064afa6..39a5dccc217 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -3481,6 +3481,14 @@ + + + + + + + + @@ -3505,6 +3513,14 @@ + + + + + + + + @@ -3513,6 +3529,14 @@ + + + + + + + + diff --git a/gradle/versions.gradle b/gradle/versions.gradle index 1548ca5baee..af5d4fc47ce 100644 --- a/gradle/versions.gradle +++ b/gradle/versions.gradle @@ -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' }