Skip to content

Commit f3a7cf1

Browse files
committed
Move the MLS gRPC interop test harness out of the published mls module into the non-publishing misc one as org.bouncycastle.mls.examples.client, taking mls_client.proto and the protobuf codegen with it, so that bcmls no longer ships classes needing io.grpc and com.google.protobuf from a jar whose POM and OSGi manifest declare neither.
1 parent c4ff979 commit f3a7cf1

11 files changed

Lines changed: 88 additions & 115 deletions

File tree

‎docs/claude/architecture.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ This is symmetric with the `module-info.java` rule above: a new package that's e
6969

7070
## Examples live in `misc/`, not in the Gradle modules
7171

72-
`misc/` is the canonical home for example / demo code. Existing example packages: `misc/src/main/java/org/bouncycastle/{asn1,crypto,jcajce,openpgp,pqc/crypto}/examples/`. New example code should land here, not under `core/.../examples`, `prov/.../examples`, `pg/.../openpgp/examples`, etc. — putting it inside a **published** Gradle module (core/prov/pkix/pg/...) would force it into the published `bc*` jars and make it part of the JPMS-exported API surface.
72+
`misc/` is the canonical home for example / demo code. Existing example packages: `misc/src/main/java/org/bouncycastle/{asn1,crypto,jcajce,openpgp,pqc/crypto}/examples/`. It is also where a **test harness that needs third-party jars** belongs — `org.bouncycastle.mls.examples.client` (the MLS working group's gRPC interop runner, with its `src/main/proto/mls_client.proto` and the protobuf codegen plugin) moved here out of the published `mls` module, which had been shipping classes needing `io.grpc` / `com.google.protobuf` in a jar whose POM and OSGi manifest declared neither. New example code should land here, not under `core/.../examples`, `prov/.../examples`, `pg/.../openpgp/examples`, etc. — putting it inside a **published** Gradle module (core/prov/pkix/pg/...) would force it into the published `bc*` jars and make it part of the JPMS-exported API surface.
7373

7474
`misc` **is** a Gradle module (in `settings.gradle`, with a `misc/build.gradle`) — but a deliberately *non-publishing* one: it is compiled and its example smoke-tests are run by `./gradlew :misc:build` so the examples don't rot against the library APIs, but it defines **no** `publishing` block and is **not** in the root `build.gradle` `distModules` list, so nothing from `misc` ships to Maven or into the distribution jars. Keep it that way — the whole point is that example code compiles under CI without becoming shipped API. Two consequences to preserve: (1) the shared `config/checkstyle/checkstyle.xml` exempts every `org.bouncycastle..*.examples.*` package from the `DebugMethodChecker` (examples legitimately call `System.out.println` / `System.exit`), so example files carry **no** `-DM` squelch comments — the Allman-brace checks (`LeftCurly`/`RightCurly`) still apply; (2) `misc/build.gradle` declares its cross-module deps explicitly (`prov`, `util`, `pkix`, `pg`, `mail`, plus `javax.mail`) since the `project(...)` deps are `implementation` (non-transitive), and `misc/src/test` carries its own `org.bouncycastle.test.PrintTestResult` copy like every other module's test tree. `pg/src/main/java/org/bouncycastle/openpgp/examples/` already exists as a legacy quirk and is published; the rule applies symmetrically — new OpenPGP example code goes under `misc/.../openpgp/examples/` instead (the package was added there for github #1414's `PublicKeyByteArrayHandler`, complementing the older PBE-only `ByteArrayHandler` in pg).
7575

‎docs/releasenotes.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ <h3>2.1.4 Additional Notes</h3>
206206
<li>As announced in the 1.85 release notes, the deprecated SLH-DSA (FIPS 205) implementation under org.bouncycastle.pqc.crypto.slhdsa has been removed. Use the standardised implementation under org.bouncycastle.crypto instead (crypto.params.SLHDSA* / crypto.generators.SLHDSAKeyPairGenerator / crypto.signers.SLHDSASigner and HashSLHDSASigner), which is registered in the BC provider. The org.bouncycastle.pqc.crypto.util key-factory entries - the only production callers still on the deprecated package - now use the canonical classes instead; no object identifiers are affected and existing SLH-DSA certificates and keys decode exactly as before.</li>
207207
<li>BCJSSE: server-side OCSP stapling is configured by the same system properties as SunJSSE, and like SunJSSE they are read per SSLContext rather than once per class load, so one process can host a context that staples and a context that does not. jdk.tls.server.enableStatusRequestExtension (default false) enables it; jdk.tls.stapling.cacheSize (256), jdk.tls.stapling.cacheLifetime (3600 seconds), jdk.tls.stapling.responseTimeout (5000 milliseconds), jdk.tls.stapling.responderURI, jdk.tls.stapling.responderOverride (false) and jdk.tls.stapling.ignoreExtensions configure it, with exactly zero for either cache setting meaning no limit of that kind rather than no caching. The response timeout is the exception to that reading: it bounds a handshake thread, where "no limit" is not something to configure by accident, so its minimum is one millisecond and a zero is refused with a warning and the default used in its place. A negative value is refused the same way whichever of these properties it is given to, the default being used instead, as it is for a value that is not a number. Two differences from SunJSSE are deliberate. First, jdk.tls.stapling.ignoreExtensions defaults to true here: the OCSP request extensions in question are the client's to choose and a nonce among them makes every response single-use, so honouring them would let a client force an outbound OCSP request per handshake, which is what the cache exists to prevent - RFC 6066 sec. 8 has the client naming extensions it "wishes the server to include" rather than extensions it is owed, and setting the property to false restores parity. What that forwards is the nonce, and only the nonce: an extension a client asks to have passed on is not one this server can promise anything about, and a response shaped by one client's extensions would be cached under the certificate alone and then relayed to clients that asked with different ones. A nonced request is answered outside the cache accordingly - neither served from it nor put into it - which is why honouring extensions costs an outbound request per handshake, and a nonced lookup that fails is not recorded against the shared request the other clients use. Second, a response stating no nextUpdate is never cached, where SunJSSE holds one for cacheLifetime; this matches how the CertPath validator side of the library already reads RFC 6960 sec. 4.2.2.1. One further property is specific to this implementation: org.bouncycastle.jsse.server.stapling.failureLifetime (60 seconds) sets how long a failed lookup suppresses further attempts for the same certificate, so an unreachable responder costs one attempt per interval rather than one per handshake. Note also that fetches are made on the handshake thread within the responseTimeout budget rather than on a background thread pool as SunJSSE uses, so the first handshake needing a given response pays for retrieving it.</li>
208208
<li>Unreachable classes for RFC 3281 cert-path services have been removed.</li>
209+
<li>The MLS gRPC interop test harness has moved out of the published bcmls jar, where it was org.bouncycastle.mls.client, into the non-publishing misc module as org.bouncycastle.mls.examples.client.</li>
209210
</ul>
210211

211212
<a id="r1rv85v2"><h3>2.2.1 Version</h3></a>

‎misc/build.gradle‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,96 @@
44
// code must not become part of the shipped bc* API surface. Hence no publishing block and
55
// no entry in the root build.gradle distModules list.
66

7+
plugins {
8+
// Generates the gRPC service and protobuf message classes the MLS interop harness under
9+
// org.bouncycastle.mls.examples.client implements. The harness lives here rather than in the
10+
// published mls module because it is a test tool for the RFC 9420 interoperability runner,
11+
// not library API: shipping it in bcmls put classes needing io.grpc and com.google.protobuf
12+
// into a published jar whose POM and OSGi manifest declared neither.
13+
id 'com.google.protobuf' version '0.9.4'
14+
}
15+
16+
apply plugin: 'com.google.protobuf'
17+
18+
def grpcVersion = '1.58.0' // keep in step with the grpc-* jars under test/libs
19+
def protocVersion = '3.22.3'
20+
721
jar.archiveBaseName = "bcmisc-$vmrange"
822

23+
sourceSets {
24+
main {
25+
java {
26+
srcDirs 'build/generated/source/proto/main/grpc'
27+
srcDirs 'build/generated/source/proto/main/java'
28+
}
29+
}
30+
}
31+
932
dependencies {
1033
implementation project(':prov')
1134
implementation project(':util')
1235
implementation project(':pkix')
1336
implementation project(':pg')
1437
implementation project(':mail')
1538
implementation project(':tls')
39+
implementation project(':mls')
1640

1741
implementation group: 'javax.mail', name: 'mail', version: '1.4'
1842

43+
// The MLS interop harness only. These are the jars the mls module used to carry, still
44+
// hand-placed under test/libs.
45+
implementation(files("../test/libs/annotations-api-6.0.53.jar"))
46+
implementation(files("../test/libs/guava-32.0.1-android.jar"))
47+
implementation(files("../test/libs/failureaccess-1.0.1.jar"))
48+
implementation(files("../test/libs/grpc-api-1.58.0.jar"))
49+
implementation(files("../test/libs/grpc-protobuf-1.58.0.jar"))
50+
implementation(files("../test/libs/grpc-protobuf-lite-1.58.0.jar"))
51+
implementation(files("../test/libs/grpc-stub-1.58.0.jar"))
52+
implementation(files("../test/libs/protobuf-java-3.22.3.jar"))
53+
54+
compileOnly(files("../test/libs/grpc-services-1.58.0.jar"))
55+
56+
runtimeOnly(files("../test/libs/grpc-core-1.58.0.jar"))
57+
runtimeOnly(files("../test/libs/grpc-netty-shaded-1.58.0.jar"))
58+
runtimeOnly(files("../test/libs/perfmark-api-0.26.0.jar"))
59+
1960
// The example smoke tests (src/test) drive the S/MIME and OpenPGP examples
2061
// via their main() methods; they need JUnit and the same javax.mail runtime
2162
// as the examples themselves. PrintTestResult is carried as a per-module
2263
// test copy under src/test (as every other module does).
2364
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
2465
}
2566

67+
protobuf {
68+
protoc {
69+
artifact = "com.google.protobuf:protoc:${protocVersion}"
70+
}
71+
plugins {
72+
grpc {
73+
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
74+
}
75+
}
76+
generateProtoTasks {
77+
all()*.plugins {
78+
grpc {}
79+
}
80+
}
81+
}
82+
83+
// Checkstyle and the example-code conventions apply to what is written by hand, not to the
84+
// protobuf/gRPC output under build/generated.
85+
checkstyleMain {
86+
source = fileTree('src/main/java')
87+
}
88+
89+
extractIncludeProto {
90+
dependsOn(":prov:jar", ":util:jar")
91+
}
92+
93+
extractIncludeTestProto {
94+
dependsOn(":prov:jar", ":util:jar")
95+
}
96+
2697
test {
2798
// The S/MIME and OpenPGP example smoke tests write scratch files (id.p12,
2899
// *.message, *.bpg, test.txt, ...) via relative paths in the working

mls/src/main/java/org/bouncycastle/mls/client/KeyPackageWithSecrets.java renamed to misc/src/main/java/org/bouncycastle/mls/examples/client/KeyPackageWithSecrets.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.bouncycastle.mls.client;
1+
package org.bouncycastle.mls.examples.client;
22

33
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
44
import org.bouncycastle.mls.codec.KeyPackage;

mls/src/main/java/org/bouncycastle/mls/client/MLSClientImpl.java renamed to misc/src/main/java/org/bouncycastle/mls/examples/client/MLSClientImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.bouncycastle.mls.client;
1+
package org.bouncycastle.mls.examples.client;
22

33
import java.io.IOException;
44
import java.security.SecureRandom;

mls/src/main/java/org/bouncycastle/mls/client/MLSServer.java renamed to misc/src/main/java/org/bouncycastle/mls/examples/client/MLSServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.bouncycastle.mls.client;
1+
package org.bouncycastle.mls.examples.client;
22

33
import java.io.IOException;
44

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Test harness driving an MLS (RFC 9420) participant - key-package generation, group join,
3+
* message send / receive and welcome processing - over the MLS working group's gRPC
4+
* interoperability service, whose messages are generated from {@code src/main/proto/mls_client.proto}.
5+
* <p>
6+
* This is a test tool rather than library API, which is why it lives in the non-publishing
7+
* {@code misc} module: it needs {@code io.grpc} and {@code com.google.protobuf} on the
8+
* classpath, and it used to ship inside the published {@code bcmls} jar, whose POM and OSGi
9+
* manifest declared neither. The MLS library itself is {@code org.bouncycastle.mls.*} in the
10+
* {@code mls} module and has no gRPC dependency.
11+
*/
12+
package org.bouncycastle.mls.examples.client;

‎mls/build.gradle‎

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,14 @@
22
plugins {
33
// OSGI
44
id "biz.aQute.bnd.builder" version "7.1.0"
5-
// Provide convenience executables for trying out the examples.
6-
id 'application'
7-
id 'com.google.protobuf' version '0.9.4'
85
// Generate IntelliJ IDEA's .idea & .iml project files
96
// id 'idea'
107
}
118

129
apply plugin: 'java'
13-
apply plugin: 'com.google.protobuf'
1410

1511
sourceSets {
1612

17-
main {
18-
java {
19-
srcDirs 'build/generated/source/proto/main/grpc'
20-
srcDirs 'build/generated/source/proto/main/java'
21-
}
22-
}
23-
2413
java9 {
2514
java {
2615
srcDirs = ['src/main/jdk1.9']
@@ -33,32 +22,6 @@ dependencies {
3322
implementation project(':pkix')
3423
implementation project(':prov')
3524

36-
//Provided
37-
implementation(files("../test/libs/annotations-api-6.0.53.jar"))
38-
// implementation(files("../test/libs/protobuf-java-util-3.22.3.jar"))
39-
implementation(files("../test/libs/guava-32.0.1-android.jar"))
40-
implementation(files("../test/libs/grpc-stub-1.58.0.jar"))
41-
implementation(files("../test/libs/protobuf-java-3.22.3.jar"))
42-
implementation(files("../test/libs/grpc-api-1.58.0.jar"))
43-
implementation(files("../test/libs/grpc-protobuf-lite-1.58.0.jar"))
44-
implementation(files("../test/libs/failureaccess-1.0.1.jar"))
45-
implementation(files("../test/libs/grpc-protobuf-1.58.0.jar"))
46-
47-
//Compile
48-
compileOnly(files("../test/libs/grpc-services-1.58.0.jar"))
49-
50-
//Runtime
51-
runtimeOnly(files("../test/libs/grpc-netty-shaded-1.58.0.jar"))
52-
runtimeOnly(files("../test/libs/grpc-core-1.58.0.jar"))
53-
runtimeOnly(files("../test/libs/perfmark-api-0.26.0.jar"))
54-
55-
//Download jars online
56-
// implementation "io.grpc:grpc-protobuf:${grpcVersion}"
57-
// implementation "io.grpc:grpc-services:${grpcVersion}"
58-
// implementation "io.grpc:grpc-stub:${grpcVersion}"
59-
// compileOnly "org.apache.tomcat:annotations-api:6.0.53"
60-
// runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}"
61-
// implementation "com.google.protobuf:protobuf-java-util:${protocVersion}"
6225
java9Implementation files(sourceSets.main.output.classesDirs) {
6326
builtBy compileJava
6427
}
@@ -68,20 +31,12 @@ evaluationDependsOn(":prov")
6831
evaluationDependsOn(":util")
6932
evaluationDependsOn(":pkix")
7033

71-
def grpcVersion = '1.58.0' // CURRENT_GRPC_VERSION
72-
def protocVersion = '3.22.3'
73-
74-
7534
checkstyleMain {
7635
source = fileTree('src/main/java')
7736
}
7837

7938
compileJava {
8039
options.release = 8
81-
82-
// options.errorprone.disableWarningsInGeneratedCode = true
83-
// options.errorprone.errorproneArgs = ["-Xep:IgnoredPureGetter:OFF"]
84-
// options.errorprone.errorproneArgs.add("-XepExcludedPaths:.*/build/generated/.*")
8540
}
8641

8742
compileJava9Java {
@@ -99,69 +54,9 @@ compileJava9Java {
9954
options.sourcepath = files(['src/main/java', 'src/main/jdk1.9'])
10055
}
10156

102-
protobuf {
103-
protoc {
104-
artifact = "com.google.protobuf:protoc:${protocVersion}"
105-
}
106-
plugins {
107-
grpc {
108-
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
109-
}
110-
}
111-
generateProtoTasks {
112-
all()*.plugins {
113-
grpc {}
114-
}
115-
}
116-
}
117-
11857
jar.archiveBaseName = "bcmls-$vmrange"
11958

12059

121-
startScripts.enabled = false
122-
123-
// Creates start scripts for a class name and adds it to the distribution.
124-
def createStartScripts(String mainClassName) {
125-
String bareName = mainClassName.substring(mainClassName.lastIndexOf('.') + 1);
126-
String taskName = bareName.uncapitalize();
127-
def newTask = tasks.register(taskName, CreateStartScripts) {
128-
mainClass = mainClassName
129-
applicationName = taskName.replaceAll('([A-Z])') { '-' + it[0].uncapitalize() }
130-
outputDir = new File(project.buildDir, 'tmp/scripts/' + name)
131-
// classpath = startScripts.classpath
132-
}
133-
application {
134-
applicationDistribution.into('bin') {
135-
from(newTask)
136-
filePermissions {
137-
user {
138-
read = true
139-
write = true
140-
execute = true
141-
}
142-
group {
143-
read = true
144-
execute = true
145-
}
146-
other {
147-
read = true
148-
execute = true
149-
}
150-
}
151-
}
152-
}
153-
}
154-
155-
extractIncludeProto {
156-
dependsOn(":prov:jar",":util:jar")
157-
}
158-
159-
extractIncludeTestProto {
160-
dependsOn(":prov:jar",":util:jar")
161-
}
162-
163-
createStartScripts('org.bouncycastle.mls.client.impl.MLSClient')
164-
16560
jar {
16661
from sourceSets.main.output
16762
into('META-INF/versions/9') {

‎mls/src/main/java/org/bouncycastle/mls/client/package-info.java‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)