Files
shadowsocks-libev/docs
Max Lv 0fb282245c C++20 port 8/14: allocation-free stream cipher codecs (#3072)
* Add allocation-free C++ stream cipher codecs

src/crypto/stream.hpp implements the legacy stream methods this build
supports (AES CFB/CTR, Camellia CFB, Salsa20, ChaCha20, ChaCha20-IETF)
as value types. The AES and Camellia contexts are held by value through
Mbed TLS's block-cipher APIs instead of an allocated
mbedtls_cipher_context_t, and the libsodium ciphers track their
keystream position, finishing partial 64-byte blocks from a stack block
instead of the padding copies stream.cpp makes.

test_crypto_stream_cpp runs TCP streams (with fragments that split
keystream blocks) and UDP packets between the C and C++
implementations in both directions for all twelve methods and checks
IV replay; alloc_steady_crypto_stream requires zero allocations for new
connections and packets.

* Document the crypto codecs, cache rewrite and allocation progress

* Include <algorithm> for std::min in test_crypto_stream_cpp.cpp

* Do not memcpy from an empty span in the stream decoder

An empty read before the IV arrived passed a null source to memcpy,
which UBSan reports (and the ASan CI job turns into a failure).

* Include C++ headers before crypto.h in test_crypto_stream_cpp.cpp

crypto.h defines min/max macros for the C sources; libstdc++ headers
included after it fail to parse.
2026-10-15 10:00:37 +08:00
..