Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaClub · Post-Quantum Cryptography in Java

A local demo of ML-KEM, ML-DSA, and TLS 1.3 hybrid key exchange. It uses the JDK and Bash, with results printed in the terminal and key TLS traces saved in results/.

Run the demo

Use OpenJDK 27 for all scenarios. For the standalone ML-KEM and ML-DSA demos, JDK 24 or newer is enough. The launcher uses JAVA_HOME when set and otherwise finds java, javac, and keytool on PATH.

./run.sh all 10 2

To select the JDK used for the original benchmark, run the demo this way.

JAVA_HOME="$HOME/.sdkman/candidates/java/27.0.0+35-open" ./run.sh all 10 2
Command Output
./run.sh kem ML-KEM-768 encapsulation and matching shared secrets
./run.sh signature ML-DSA-65 verification succeeds for the original message and fails for the modified message
./run.sh tls Classic x25519 and hybrid X25519MLKEM768 selected in ServerHello.key_share
./run.sh fallback A client offering both groups connects to a server that supports only x25519
./run.sh no-common A hybrid-only client and classic-only server reject the connection
./run.sh verify Two full handshakes per benchmark group, with server certificates and without PSK or session tickets
./run.sh benchmark 500 100 500 measured handshakes and 100 warmups per group, with mean, p50, p95, and p99 in milliseconds

The launcher compiles Java and creates a local self-signed ECDSA certificate on first use. Both TLS modes trust that specific certificate and verify the peer identity. If the certificate expires, remove the generated build/localhost.p12 so the next run can renew it. The hybrid group changes key exchange. The certificate signature is ECDSA in every group.

Handshake measurement

The timer measures the call to SSLSocket.startHandshake() from the client. Before timing, the benchmark creates a fresh client SSLContext, connects a new TCP socket, accepts it on the server, sets TCP_NODELAY at both ends, and configures both TLS sockets. After timing, it checks that both peers completed the handshake and that the client negotiated TLS 1.3 with TLS_AES_128_GCM_SHA256. There is no HTTP or other application data in this flow.

One loopback server, certificate, cipher suite, and sequential client are used for both groups. The server accepts either group. The client advertises only the group under test. Group order alternates each round, and the statistics exclude warmup samples. The fresh client context prevents session resumption. The server also sets jdk.tls.server.newSessionTicketCount=0 on the tested SunJSSE build. The separate verify command checks the actual handshake trace. The benchmark requires JSSE debug logging to be off.

The terminal and results/benchmark.log show warmup and measurement progress every 50 rounds, at the next completed round if two seconds have passed since the last update, and at the end of each phase. Each round includes one handshake per group. Progress is printed outside the timed interval.

The timings describe full client-side handshakes over local TCP, including cryptography, TLS record exchange, and thread scheduling. Repeat the benchmark on an idle host to assess run-to-run variation. Use the 10-round run to check the demo and the longer run to compare latency distributions.

Manual HTTPS demo

Start the server in one terminal and run the client in another.

./run.sh server
./run.sh client

The client displays the HTTP status, TLS protocol, cipher suite, and response body from https://localhost:8443/hello. To choose a particular key exchange group, set JAVA_TOOL_OPTIONS='-Djdk.tls.namedGroups=x25519' on both commands or select X25519MLKEM768 on both.

References

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages