mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-28 10:44:43 +08:00
* Add allocation-free C++ AEAD codecs src/crypto/aead.hpp implements the SIP004/SIP007 AEAD ciphers as value types: AeadEngine holds the libsodium or Mbed TLS GCM state by value, AeadTcpEncryptor/AeadTcpDecryptor frame the chunk stream with a fixed reassembly buffer, and aead_udp_seal/open handle packets. HKDF-SHA1 runs on stack SHA-1 state instead of Mbed TLS's allocating HMAC API. The bundled Mbed TLS config now enables MBEDTLS_BLOCK_CIPHER_C, which keeps the AES context inside mbedtls_gcm_context, so GCM key setup no longer allocates. That alone saves the C programs two allocations per connection. test_crypto_aead_cpp checks HKDF against RFC 5869 and crypto_hkdf, runs TCP streams and UDP packets between the C and C++ implementations in both directions for all five AEAD methods, and covers tampering, framing and salt replay. alloc_steady_crypto_aead runs it under the malloc counter and requires zero allocations across 600 new connections and 600 packets (tests/alloc_audit/check_steady.py). ss_strict_warnings() now applies -Wextra per source file so targets mixing new C++ with converted C modules keep the latter at -Wall, and Result gains move assignment. * Include <algorithm> for std::min in test_crypto_aead_cpp.cpp * Build the C++ AEAD codecs against Mbed TLS 2.x Mbed TLS 2 returns void from mbedtls_sha1_starts/update/finish (the int versions are the _ret variants), which the system-library build on Ubuntu (2.28) rejects. crypto/mbedtls_compat.hpp gives one int-returning spelling for both. * Include C++ headers before crypto.h in test_crypto_aead_cpp.cpp crypto.h defines min/max macros for the C sources; libstdc++ headers included after it fail to parse. * Disable the zero-allocation checks with a system Mbed TLS They hold for the bundled Mbed TLS (MBEDTLS_BLOCK_CIPHER_C); a system one may allocate in GCM key setup, as the Debian package build shows.
43 lines
1.9 KiB
YAML
43 lines
1.9 KiB
YAML
# clang-tidy configuration for shadowsocks-c project sources (src/ only).
|
|
# Bundled sources under third_party/ and src/blake3/ are third-party code and
|
|
# are excluded by the file regex used in CI:
|
|
# run-clang-tidy -p build '/(src/(core/|event/|relay/|crypto/|api/)?[^/]+\.(c|cpp)|tests/test_(core_[^/]+|[a-z_]+_cpp)\.cpp)$'
|
|
#
|
|
# The header-only C++ core (src/core/*.hpp) is analysed through the
|
|
# test_core_* translation units that include it.
|
|
#
|
|
# The check set is intentionally conservative: the full clang static analyzer
|
|
# plus the bugprone/cert checks that are actionable for this codebase.
|
|
# Checks disabled below are either stylistic churn (macro-parentheses,
|
|
# reserved-identifier: the codebase uses _prefixed names and vendored
|
|
# uthash.h/generated config.h trip them ~600 times) or produce false
|
|
# positives with the event callback style (casting-through-void,
|
|
# multi-level-implicit-pointer-conversion). dynamic-static-initializers
|
|
# fires on every extern variable declaration in the C headers once they are
|
|
# included from C++; none of them is defined or initialised in a header.
|
|
Checks: >
|
|
clang-analyzer-*,
|
|
bugprone-*,
|
|
cert-*,
|
|
-bugprone-assignment-in-if-condition,
|
|
-bugprone-branch-clone,
|
|
-bugprone-casting-through-void,
|
|
-bugprone-dynamic-static-initializers,
|
|
-bugprone-easily-swappable-parameters,
|
|
-bugprone-inc-dec-in-conditions,
|
|
-bugprone-implicit-widening-of-multiplication-result,
|
|
-bugprone-macro-parentheses,
|
|
-bugprone-multi-level-implicit-pointer-conversion,
|
|
-bugprone-narrowing-conversions,
|
|
-bugprone-reserved-identifier,
|
|
-bugprone-signed-char-misuse,
|
|
-bugprone-switch-missing-default-case,
|
|
-cert-dcl37-c,
|
|
-cert-dcl51-cpp,
|
|
-cert-err33-c,
|
|
-cert-str34-c,
|
|
-clang-analyzer-security.insecureAPI.strcpy,
|
|
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling
|
|
WarningsAsErrors: ''
|
|
HeaderFilterRegex: '.*/src/([^/]+\.h|(core|event|crypto)/[^/]+\.hpp)$'
|