lukaszzborek opened a new pull request, #3639:
URL: https://github.com/apache/iggy/pull/3639

   Rationale
   
   Encryption previously lived in the publisher/consumer: PublisherEncryption 
allocated a fresh ciphertext array per message (with an Encrypted flag to avoid 
double-encrypting on retry), and the consumer decrypted through the allocating 
byte[] Decrypt(...) — defeating the pooled/rented buffer work on both paths. 
This PR moves encryption to the client at the wire boundary: one encryptor on 
IIggyClient (IggyClientConfigurator.MessageEncryptor) encrypts on send and 
decrypts on poll for the whole connection.
   
   Changes
   
   - TCP send: payloads and headers are encrypted directly into the pooled wire 
buffer during serialization; caller Message instances keep their plaintext, 
retries re-encrypt with a fresh nonce.
   - TCP poll: all payloads/headers decrypt into a single pooled plaintext 
buffer tied to the rental's lifetime (cleared on return). HTTP uses per-message 
encrypted copies (JSON needs standalone arrays).
   - Failure semantics: a decryption failure aborts the batch with 
MessageDecryptionException (offset + partition) surfaced from the receive 
enumerator, instead of a silently skippable DecryptionFailed status. 
Unparseable frames throw MalformedResponseException instead of re-polling 
forever. Auto-commit with an encryptor is rejected (offset would commit before 
decryption; opt out via AllowAutoCommitWithEncryptor).
   - AesMessageEncryptor: per-thread AesGcm reuse instead of one per call; now 
IDisposable — releases cipher contexts and zeroes its key copy.
   
   Breaking
   
   - IMessageEncryptor is now span-based write-into-destination: int 
Encrypt/Decrypt(ReadOnlySpan<byte>, Span<byte>) plus 
GetMaxEncryptedLength/GetMaxDecryptedLength; implementations must be 
thread-safe.
   - Removed: Message.Encrypted, MessageStatus.DecryptionFailed, 
MessageEncryptor on publisher/consumer configs, PublisherEncryption.
   - WithDecryptor renamed to WithEncryptor; on both builders it now configures 
the client the builder creates and throws if an external client is supplied.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to