code.posterity.life/ece (go): Package ece provides support for reading and writing streams encoded using ECE (Encrypted-Content-Encoding) for HTTP, as defined in RFC8188.  Reader can read and decipher encrypted data, while Writer can be used to write a cipher into an underlying io.Writer.  Client is an HTTP client capable of encrypting requests before they're sent, and decrypting responses as they're received.  Handler is an HTTP middleware capable of transparently decrypting incoming requests and encrypting outgoing responses for clients that support it.  While RFC8188 only mentions AES-128-GCM, this implementation extends it with support for 256-bit encryption (i.e. AES-256-GCM).  Use 32-byte keys for AES-256-GCM, and 16-byte ones for AES-128-GCM.  ECE encrypts data in chunks of predetermined length. The value can be anything above 17 characters, which corresponds to the AES-GCM tag length (16 bytes), plus a block-delimiter (1 byte).  The ideal value depends on your use case. Smaller values create longer ciphers but require less memory to be decrypted, while larger values generate shorter ciphers, but require more memory for decryption.  RFC8188 recommends using multiples of 16.
Keywords: aes|cryptography|encryption|golang|http