Implement aws_tls_handler_write - #2
Open
azkrishpy wants to merge 1 commit into
Open
Conversation
Add a public API to write plaintext directly to a TLS channel handler and have it encrypted, without needing an upstream handler to feed it. This is useful when using the TLS handler directly for arbitrary data rather than installing additional handlers into the channel. The implementation is a single portable function that dispatches to the handler's existing process_write_message vtable entry, so it works across all TLS backends (s2n, SecureTransport, SecureChannel) and BYO_CRYPTO. Buffers larger than a single channel message are split across multiple messages, and the completion callback fires once the final message has been written. Adds tls_channel_handler_write_test covering the end-to-end encrypt/decrypt path and completion callback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a public
aws_tls_handler_writeAPI that lets callers write plaintext directly to a TLS channel handler and have it encrypted, without installing an upstream handler to feed the TLS handler. This is useful when using the TLS handler directly for arbitrary data.Approach
The implementation is a single portable function in
source/tls_channel_handler.cthat dispatches to the handler's existingprocess_write_messagevtable entry — the same path used to encrypt-and-send-downstream. One implementation therefore covers all TLS backends (s2n, SecureTransport, SecureChannel) and BYO_CRYPTO, reusing the already-tested encryption path rather than duplicating per-platform logic.Details:
on_write_completedcallback is attached only to the final message, so it fires once the whole buffer has been written.process_write_messagefailure the handler does not take ownership of the message, so the message is released and the error is propagated.AWS_IO_TLS_ERROR_NOT_NEGOTIATED.Testing
Adds
tls_channel_handler_write_test, which negotiates a real client/server TLS channel, callsaws_tls_handler_writeon the client TLS handler from the event-loop thread, and asserts:AWS_OP_SUCCESS.Verified locally: clean compile (no new warnings) under both the SecureTransport and s2n configurations; the new test and the existing
tls_channel_echo_and_backpressure_testboth pass end-to-end against the s2n backend.