corda/node-api/build.gradle
Shams Asari 0091807c2f ENT-11101: Fix all crypto issues introduced by Java 17 upgrade
The various crypto tests that were previously ignored have been re-enabled.

The abandoned i2p EdDSA library has been replaced with native support that was added in Java 15.

Java 17 (via the `SunEC` provider) does not support the secp256k1 curve (one of the two ECDSA curves supported in Corda). This would not normally have been an issue as secp256k1 is already taken care of by Bouncy Castle. However, this only works if the `Crypto` API is used or if `”BC”` is explicitly specified as the provider (e.g. `Signature.getInstance(“SHA256withECDSA”, “BC”)`). If no provider is specified, which is what is more common, and actually what the Java docs recommend, then this doesn’t work as the `SunEC` provider is selected. To resolve this, a custom provider was created, installed just in front of `SunEC`, which “augments” `SunEC` by delegating to Bouncy Castle if keys or parameters for secp256k1 are encountered.

`X509Utilities.createCertificate` now calls `X509Certificate.verify()` to verify the created certificate, rather than using the Bouncy Castle API. This is more representative of how certificates will be verified (e.g. during SSL handshake) and weeds out other issues (such as unsupported curve error for secp256k1).

`BCCryptoService` has been renamed to `DefaultCryptoService` as it no longer explicitly uses Bouncy Castle but rather uses the installed security providers. This was done to fix a failing test. Further, `BCCryptoService` was already relying on the installed providers in some places.

The hack to get Corda `SecureRandom` working was also resolved. Also, as an added bonus, tests which ignored `SPHINCS256_SHA256` have been reinstated.

Note, there is a slightly inconsistency between how EdDSA and ECDSA keys are handled (and also RSA). For the later, Bouncy Castle is preferred, and methods such as `toSupportedKey*` will convert any JDK class to Bouncy Castle. For EdDSA the preference is the JDK (`SunEC`). However, this is simply a continuation of the previous preference of the i2p library over Bouncy Castle.
2024-03-04 13:29:49 +00:00

116 lines
4.5 KiB
Groovy

apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'net.corda.plugins.quasar-utils'
apply plugin: 'corda.common-publishing'
description 'Corda node API'
dependencies {
api project(":core")
implementation project(":serialization") // TODO Remove this once the NetworkBootstrapper class is moved into the tools:bootstrapper module
implementation project(':common-configuration-parsing') // TODO Remove this dependency once NetworkBootsrapper is moved into tools:bootstrapper
implementation project(':common-logging')
implementation project(":common-validation")
implementation "io.opentelemetry:opentelemetry-api:$open_telemetry_version"
compileOnly project(':opentelemetry')
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
// TODO: remove the forced update of commons-collections and beanutils when artemis updates them
implementation "org.apache.commons:commons-collections4:${commons_collections_version}"
implementation "commons-beanutils:commons-beanutils:${beanutils_version}"
implementation("org.apache.activemq:artemis-core-client:${artemis_version}") {
exclude group: 'org.jgroups', module: 'jgroups'
}
implementation "org.apache.activemq:artemis-commons:${artemis_version}"
implementation "javax.json:javax.json-api:$json_api_version"
implementation "com.google.code.findbugs:jsr305:$jsr305_version"
implementation "io.netty:netty-handler-proxy:$netty_version"
// TypeSafe Config: for simple and human friendly config files.
implementation "com.typesafe:config:$typesafe_config_version"
implementation "org.apache.qpid:proton-j:$protonj_version"
// SQL connection pooling library
implementation "com.zaxxer:HikariCP:$hikari_version"
// ClassGraph: classpath scanning
implementation "io.github.classgraph:classgraph:$class_graph_version"
// Kryo: object graph serialization.
implementation "com.esotericsoftware:kryo:$kryo_version"
implementation "de.javakaffee:kryo-serializers:$kryo_serializer_version"
// For caches rather than guava
implementation "com.github.ben-manes.caffeine:caffeine:$caffeine_version"
// For db migration
implementation "org.liquibase:liquibase-core:$liquibase_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
// Bouncy castle support needed for X509 certificate manipulation
implementation "org.bouncycastle:bcprov-jdk18on:${bouncycastle_version}"
implementation "org.bouncycastle:bcpkix-jdk18on:${bouncycastle_version}"
implementation "io.reactivex:rxjava:$rxjava_version"
implementation "javax.persistence:javax.persistence-api:2.2"
implementation "org.hibernate:hibernate-core:$hibernate_version"
implementation "co.paralleluniverse:quasar-osgi-annotations:$quasar_version"
runtimeOnly 'com.mattbertolini:liquibase-slf4j:2.0.0'
// JDK11: required by Quasar at run-time
runtimeOnly "com.esotericsoftware:kryo:$kryo_version"
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockito_kotlin_version"
testImplementation "co.paralleluniverse:quasar-core:$quasar_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_jupiter_version}"
testImplementation "junit:junit:$junit_version"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${junit_vintage_version}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junit_jupiter_version}"
testRuntimeOnly "org.junit.platform:junit-platform-launcher:${junit_platform_version}"
testImplementation project(':node-driver')
// Unit testing helpers.
testImplementation "org.assertj:assertj-core:$assertj_version"
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testImplementation project(':core-test-utils')
testImplementation project(':test-utils')
implementation ("org.apache.activemq:artemis-amqp-protocol:${artemis_version}") {
// Gains our proton-j version from core module.
exclude group: 'org.apache.qpid', module: 'proton-j'
exclude group: 'org.jgroups', module: 'jgroups'
}
}
configurations {
testArtifacts.extendsFrom testRuntimeOnlyClasspath
}
tasks.register('testJar', Jar) {
classifier "tests"
from sourceSets.test.output
}
artifacts {
testArtifacts testJar
}
jar {
baseName 'corda-node-api'
}
publishing {
publications {
maven(MavenPublication) {
artifactId jar.baseName
from components.java
}
}
}