GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add exportKeyingMaterial() to QuicSslEngine (RFC 5705 TLS exporter) by Dolfik1 · Pull Request #17111 · netty/netty Conversation
|
|
Updated the commit message to follow the commit message guidelines. Happy to address any feedback. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@Dolfik1 did you sign our icla yet ? https://netty.io/s/icla |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yes, I signed it before and signed it again to be sure. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * material. | ||
| */ | ||
| public byte[] exportKeyingMaterial(String label, byte @Nullable [] context, int length) throws SSLException { | ||
| throw new UnsupportedOperationException(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be better to just use return null as not supported. WDYT ?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The exportKeyingMaterial method is intended for cryptographic purposes, so an explicit exception instead of null may be preferable to avoid possible errors in user code (fail-fast).
Looking at the implementation in QuicheQuicSslEngine, you can see that we always throw an SSLException if the underlying implementation returns null, so user code should already expect and handle exceptions.
Additionally, we currently always implement this method, so this exception can only be thrown if a new implementation of the class is added in the future or if this interface is implemented in user code.
If you disagree with my reasoning, let me know and I'll fix it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
makes sense
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing a length I think we could pass in the exportedKeyMaterial byte array as a parameter, and either return void and throw if not supported, or return a boolean indicated if EKM was exported.
That way we eliminate an OutOfMemoryError possibility from the (*env)->NewByteArray(env, length) call.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@normanmaurer One thought about this PR: this feature could be useful not only for QUIC connections but also for any TLS 1.2+ connections. We could mark this method as @UnstableApi and consider extracting it into a separate interface in the future, which could also be implemented by ReferenceCountedOpenSslEngine to support this functionality for OpenSSL engine. In this way we can even get rid of the UnsupportedOperationException in the future. I wouldn't move this method into a separate interface now, since I'm not sure what the final API will look like. What do you think about this? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
@Dolfik1 good question... We could for example create a new abstract class @chrisvest WDYT ? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think we could define the method in a KeyMaterialExporter interface in netty-handler.
The QuicSslEngine could then implement this, or we could make only the QuicheQuicSslEngine implement it so support gated by an instanceof and cast. Although support could in principle depend on runtime factors rather than types.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * material. | ||
| */ | ||
| public byte[] exportKeyingMaterial(String label, byte @Nullable [] context, int length) throws SSLException { | ||
| throw new UnsupportedOperationException(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing a length I think we could pass in the exportedKeyMaterial byte array as a parameter, and either return void and throw if not supported, or return a boolean indicated if EKM was exported.
That way we eliminate an OutOfMemoryError possibility from the (*env)->NewByteArray(env, length) call.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ObjectUtil.checkPositiveOrZero(length, "length"); | ||
|
|
||
| final byte[] keyingMaterial; | ||
| synchronized (this) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think the concurrency here problematic.
The event loop thread drives the TLS state machine indirectly through calls into quiche, while we at the same time expose this public methods that make calls on SSL*.
The other synchronized methods operate either on snapshot data extracted at handshake time from the event loop, or doesn't make use of SSL*.
This method can be called from outside of the event loop, and needs a live SSL* which is assumed to be a single-threaded object. I don't think that's a good idea, and that we instead somehow need to enforce that this method is called from within the event loop.
What I think we could do is to add an EventLoop field to QuicheQuicConnection, that we could assign in QuicheQuicChannel.attachQuicheConnection if we add an EventLoop parameter to it. For client channels, the ctx.eventLoop() can be passed right in, and for server child-channels we'd have to grab the chosen event loop instance first to pass in, and then use the same event loop for the register(channel) call later in QuicheQuicServerCodec.handleServer.
Maybe @normanmaurer has a different idea.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
0a8b211 to
805aa52
Compare
|
@normanmaurer @chrisvest Sorry for the long silence. I was away for a few months. I am back now, and I made all the requested changes:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
🚨 TestLens detected 1 failed test 🚨Failed Jobs without Test Failures❌ Build PR / linux-x86_64-java11 build Test SummaryTip Inspect all details with the TestLens CLI: Build PR / macos-aarch64-java11-boringssl build > Netty/Transport/Native/KQueue
🏷️ Commit: 805aa52 Test FailuresKQueueETSocketHalfClosedTest > testAllDataReadClosure(TestInfo) (Netty/Transport/Native/KQueue in Build PR / macos-aarch64-java11-boringssl build)Rerun ControlsSelect tests to mute in this pull request:
Reuse successful test results:
Click the checkbox to trigger a rerun:
Learn more about TestLens at testlens.app/docs. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Motivation: There is no way to get exported keying material (RFC 5705, also known as a TLS exporter) from a QUIC connection. Applications use exported keying material for channel binding. For example, a client can sign the exported value with its private key. The signature is then bound to the QUIC connection, and an attacker cannot replay it on a different connection. Modifications: - Add the KeyMaterialExporter interface to netty-handler and mark it with @UnstableApi. Other SSLEngine implementations, for example ReferenceCountedOpenSslEngine, can implement it later. Applications use an instanceof check to find out if an engine supports it. - Implement KeyMaterialExporter in QuicheQuicSslEngine on top of SSL_export_keying_material from BoringSSL, with a new JNI binding. QuicSslEngine does not change. - The caller supplies the output array. Thus the native code does not allocate Java arrays. The native code also clears its temporary buffer before it frees it. - Store the EventLoop of the channel in QuicheQuicConnection. The SSL object is not thread-safe, and the event loop drives it. Thus a call from a different thread throws IllegalStateException. - Map a null context to use_context = 0. Map an empty array to use_context = 1 with zero length. QUIC always uses TLS 1.3, so both give the same keying material. The javadoc documents this. - Throw SSLException if the handshake is not complete, or if the connection is closed. - Add tests. The tests make sure that both peers get the same keying material for the same label and context. They make sure that a different label or context gives different output. They also make sure that an empty context and a null context give the same output, and that an empty output array is permitted. Other tests make sure that a call from a different thread and a call before the handshake throw. Result: Applications can export keying material from a QUIC connection. This makes channel binding and similar use cases possible.
805aa52 to
13d5283
Compare
|
@chrisvest I rebased the branch onto the latest 4.2. The earlier Linux failures came from the outdated SDKMAN installer checksum in the Dockerfiles, and #18135 on 4.2 fixed it. The macOS kqueue failure (KQueueETSocketHalfClosedTest timeout) looks like a flaky test, because this PR doesn't touch transport code. The new workflow runs are waiting for maintainer approval. Could you approve them, please? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.