From 5f3b3eb77bd7a338bf287744c16b8bd3e7d872ad Mon Sep 17 00:00:00 2001 From: Dushnilin Date: Thu, 17 Sep 2026 18:44:22 +0300 Subject: [PATCH] fix(test): make crypt4 test resilient without openssl CLI and add openssl-util to docker e2e --- fe-app-tachyon/locales/tachyon.pot | 4 +-- fe-app-tachyon/locales/tachyon.ru.po | 4 +-- luci-app-tachyon/po/ru/tachyon.po | 4 +-- luci-app-tachyon/po/templates/tachyon.pot | 4 +-- tests/docker_e2e_test.sh | 2 +- tests/subscription_happ_crypt4.sh | 40 +++++++++++++++-------- 6 files changed, 35 insertions(+), 23 deletions(-) diff --git a/fe-app-tachyon/locales/tachyon.pot b/fe-app-tachyon/locales/tachyon.pot index 3832abbd..bb324966 100644 --- a/fe-app-tachyon/locales/tachyon.pot +++ b/fe-app-tachyon/locales/tachyon.pot @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: TACHYON\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-17 15:26+0300\n" -"PO-Revision-Date: 2026-09-17 15:26+0300\n" +"POT-Creation-Date: 2026-09-17 15:44+0300\n" +"PO-Revision-Date: 2026-09-17 15:44+0300\n" "Last-Translator: Dushnilin \n" "Language-Team: LANGUAGE \n" "Language: \n" diff --git a/fe-app-tachyon/locales/tachyon.ru.po b/fe-app-tachyon/locales/tachyon.ru.po index 4a5cb8df..634b806c 100644 --- a/fe-app-tachyon/locales/tachyon.ru.po +++ b/fe-app-tachyon/locales/tachyon.ru.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: TACHYON\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-17 18:26+0300\n" -"PO-Revision-Date: 2026-09-17 18:26+0300\n" +"POT-Creation-Date: 2026-09-17 18:44+0300\n" +"PO-Revision-Date: 2026-09-17 18:44+0300\n" "Last-Translator: Dushnilin\n" "Language-Team: none\n" "Language: ru\n" diff --git a/luci-app-tachyon/po/ru/tachyon.po b/luci-app-tachyon/po/ru/tachyon.po index 4a5cb8df..634b806c 100644 --- a/luci-app-tachyon/po/ru/tachyon.po +++ b/luci-app-tachyon/po/ru/tachyon.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: TACHYON\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-17 18:26+0300\n" -"PO-Revision-Date: 2026-09-17 18:26+0300\n" +"POT-Creation-Date: 2026-09-17 18:44+0300\n" +"PO-Revision-Date: 2026-09-17 18:44+0300\n" "Last-Translator: Dushnilin\n" "Language-Team: none\n" "Language: ru\n" diff --git a/luci-app-tachyon/po/templates/tachyon.pot b/luci-app-tachyon/po/templates/tachyon.pot index 3832abbd..bb324966 100644 --- a/luci-app-tachyon/po/templates/tachyon.pot +++ b/luci-app-tachyon/po/templates/tachyon.pot @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: TACHYON\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-09-17 15:26+0300\n" -"PO-Revision-Date: 2026-09-17 15:26+0300\n" +"POT-Creation-Date: 2026-09-17 15:44+0300\n" +"PO-Revision-Date: 2026-09-17 15:44+0300\n" "Last-Translator: Dushnilin \n" "Language-Team: LANGUAGE \n" "Language: \n" diff --git a/tests/docker_e2e_test.sh b/tests/docker_e2e_test.sh index 1bb46f7e..e7d8ca43 100644 --- a/tests/docker_e2e_test.sh +++ b/tests/docker_e2e_test.sh @@ -96,7 +96,7 @@ if ! "$DOCKER_BIN" image inspect "$TEST_IMAGE:latest" >/dev/null 2>&1; then "$DOCKER_BIN" exec "$TEMP_CONTAINER" opkg update && break || sleep 5 done for i in 1 2 3 4 5; do - "$DOCKER_BIN" exec "$TEMP_CONTAINER" opkg install ucode ucode-mod-fs ucode-mod-uci curl ca-bundle bind-dig nftables ip-full coreutils-base64 sing-box bash node git git-http && break || sleep 5 + "$DOCKER_BIN" exec "$TEMP_CONTAINER" opkg install ucode ucode-mod-fs ucode-mod-uci curl ca-bundle bind-dig nftables ip-full coreutils-base64 sing-box bash node git git-http openssl-util && break || sleep 5 done "$DOCKER_BIN" exec "$TEMP_CONTAINER" git config --global --add safe.directory '*' || true diff --git a/tests/subscription_happ_crypt4.sh b/tests/subscription_happ_crypt4.sh index b6d5f4e3..78ac890d 100644 --- a/tests/subscription_happ_crypt4.sh +++ b/tests/subscription_happ_crypt4.sh @@ -4,9 +4,6 @@ set -eo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" TACHYON_LIB="$ROOT_DIR/tachyon/files/usr/lib" CRYPT4="$ROOT_DIR/tachyon/files/usr/lib/subscription/crypt4.uc" -PARSER="$ROOT_DIR/tachyon/files/usr/lib/subscription/parser.uc" -CACHE="$ROOT_DIR/tachyon/files/usr/lib/subscription/cache.uc" -RUNTIME="$ROOT_DIR/tachyon/files/usr/lib/diagnostics/runtime.uc" WORK_DIR="$(mktemp -d)" @@ -35,14 +32,20 @@ fi PLAINTEXT="vless://00000000-0000-4000-8000-000000000001@example.com:443?encryption=none&security=tls&sni=example.com#HappNode" SECRET="my-custom-device-hwid" -KEY_HEX="$(printf '%s' "$SECRET" | sha256sum | awk '{print $1}')" -IV_HEX="000102030405060708090a0b0c0d0e0f" +# Deterministic test vector (or dynamically generated if openssl CLI is present) +B64_PAYLOAD="AAECAwQFBgcICQoLDA0OD0OMKcI1aFmugKQB4r4K4OSN6xxDU5FmUUFRentyDOXfswM3t0kyFovZ5yaTDJ1pva68axdwhD4QWAebC6Jnbv7X5xJKCGOAMMAQ3uRuJe+nXl0Az2QN+xgljgGeQaM8UHM1t3+tX4FlEWyuaaNZ4dZFwJUh0Nitkz26Mfa9//Hn" + +if command -v openssl >/dev/null 2>&1; then + KEY_HEX="$(printf '%s' "$SECRET" | sha256sum | awk '{print $1}')" + IV_HEX="000102030405060708090a0b0c0d0e0f" + printf '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f' >"$WORK_DIR/iv.bin" + printf '%s' "$PLAINTEXT" | openssl enc -aes-256-cbc -K "$KEY_HEX" -iv "$IV_HEX" >"$WORK_DIR/cipher.bin" 2>/dev/null || true + if [ -s "$WORK_DIR/cipher.bin" ]; then + cat "$WORK_DIR/iv.bin" "$WORK_DIR/cipher.bin" >"$WORK_DIR/payload.bin" + B64_PAYLOAD="$(base64 <"$WORK_DIR/payload.bin" | tr -d '\r\n ')" + fi +fi -# Encrypt with OpenSSL using file redirection to preserve null bytes -printf '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f' >"$WORK_DIR/iv.bin" -printf '%s' "$PLAINTEXT" | openssl enc -aes-256-cbc -K "$KEY_HEX" -iv "$IV_HEX" >"$WORK_DIR/cipher.bin" 2>/dev/null -cat "$WORK_DIR/iv.bin" "$WORK_DIR/cipher.bin" >"$WORK_DIR/payload.bin" -B64_PAYLOAD="$(base64 <"$WORK_DIR/payload.bin" | tr -d '\r\n ')" CRYPT4_URL="happ://crypt4/${B64_PAYLOAD}" # Decrypt using crypt4 CLI @@ -50,10 +53,19 @@ DECRYPTED="$(ucode_run "$CRYPT4" decrypt "$CRYPT4_URL" "$SECRET")" [ "$DECRYPTED" = "$PLAINTEXT" ] || fail "Decrypted plaintext mismatch: got '$DECRYPTED', expected '$PLAINTEXT'" # 3. Default salt decryption ("HappDefaultSalt") -SALT_HEX="$(printf '%s' "HappDefaultSalt" | sha256sum | awk '{print $1}')" -printf '%s' "$PLAINTEXT" | openssl enc -aes-256-cbc -K "$SALT_HEX" -iv "$IV_HEX" >"$WORK_DIR/salt_cipher.bin" 2>/dev/null -cat "$WORK_DIR/iv.bin" "$WORK_DIR/salt_cipher.bin" >"$WORK_DIR/salt_payload.bin" -SALT_B64="$(base64 <"$WORK_DIR/salt_payload.bin" | tr -d '\r\n ')" +SALT_B64="AAECAwQFBgcICQoLDA0OD6K0gDGOn/K3and0NuhjH6rDKR/ov8Xn8ESMdCk4+0rUkXQVLyUBpJTUyCagj1wCUWkMyOczDnAbhwthZ6HsuitMrPx4PnOGQypFH9+MdCQhZ+5mIkkO4g8+S5p4LTTqzA3H6U2wT6s21QmtkYxCmI8+0flp6JHnnm3Lp6krqaWq" + +if command -v openssl >/dev/null 2>&1; then + SALT_HEX="$(printf '%s' "HappDefaultSalt" | sha256sum | awk '{print $1}')" + IV_HEX="000102030405060708090a0b0c0d0e0f" + printf '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f' >"$WORK_DIR/iv.bin" + printf '%s' "$PLAINTEXT" | openssl enc -aes-256-cbc -K "$SALT_HEX" -iv "$IV_HEX" >"$WORK_DIR/salt_cipher.bin" 2>/dev/null || true + if [ -s "$WORK_DIR/salt_cipher.bin" ]; then + cat "$WORK_DIR/iv.bin" "$WORK_DIR/salt_cipher.bin" >"$WORK_DIR/salt_payload.bin" + SALT_B64="$(base64 <"$WORK_DIR/salt_payload.bin" | tr -d '\r\n ')" + fi +fi + SALT_CRYPT4_URL="crypt4/${SALT_B64}" SALT_DECRYPTED="$(ucode_run "$CRYPT4" decrypt "$SALT_CRYPT4_URL")"