From 50d9eeea4abacc1a180c7520f3bd6091c3cf5fa7 Mon Sep 17 00:00:00 2001 From: dev4u Date: Tue, 28 Feb 2023 03:35:57 +0800 Subject: [PATCH 1/2] Hotfix for `iPSK:uPSK`(2022-blake3-*) password checking fail. --- .../com/github/shadowsocks/bg/ProxyInstance.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt b/core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt index 2d623bf0d2..b21dbde1b0 100644 --- a/core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt +++ b/core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt @@ -36,6 +36,7 @@ import org.json.JSONObject import java.io.File import java.net.URI import java.net.URISyntaxException +import java.util.function.Consumer /** * This class sets up environment for ss-local. @@ -50,13 +51,15 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro "cipher ${profile.method} is deprecated." } // check the key format for aead-2022-cipher - require(profile.method !in setOf( - "2022-blake3-aes-128-gcm", - "2022-blake3-aes-256-gcm", - "2022-blake3-chacha20-poly1305", - ) || Base64.decode(profile.password, Base64.DEFAULT).size in arrayOf(16, 32)) { - "The Base64 Key is invalid." - } + profile.password.split(":").forEach(Consumer { + require(profile.method !in setOf( + "2022-blake3-aes-128-gcm", + "2022-blake3-aes-256-gcm", + "2022-blake3-chacha20-poly1305", + ) || Base64.decode(it, Base64.DEFAULT).size in arrayOf(16, 32)) { + "The Base64 Key is invalid." + } + }) } private var configFile: File? = null From 487c89ebf5ab4ae69023992bdc5b6f68b4a2a65e Mon Sep 17 00:00:00 2001 From: dev4u Date: Tue, 28 Feb 2023 23:20:11 +0800 Subject: [PATCH 2/2] Fix password check Fix base64 password check. Update dependencies. --- .../java/com/github/shadowsocks/bg/ProxyInstance.kt | 13 +++++++------ core/src/main/rust/shadowsocks-rust | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt b/core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt index b21dbde1b0..58f1c27b28 100644 --- a/core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt +++ b/core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt @@ -36,7 +36,6 @@ import org.json.JSONObject import java.io.File import java.net.URI import java.net.URISyntaxException -import java.util.function.Consumer /** * This class sets up environment for ss-local. @@ -51,15 +50,17 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro "cipher ${profile.method} is deprecated." } // check the key format for aead-2022-cipher - profile.password.split(":").forEach(Consumer { - require(profile.method !in setOf( + if (profile.method !in setOf( "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305", - ) || Base64.decode(it, Base64.DEFAULT).size in arrayOf(16, 32)) { - "The Base64 Key is invalid." + )) { + for (pwd in profile.password.split(":")) { + require(Base64.decode(pwd, Base64.DEFAULT).size in arrayOf(16, 32)) { + "The Base64 Key is invalid." + } } - }) + } } private var configFile: File? = null diff --git a/core/src/main/rust/shadowsocks-rust b/core/src/main/rust/shadowsocks-rust index 622f01a93c..49df0ebbed 160000 --- a/core/src/main/rust/shadowsocks-rust +++ b/core/src/main/rust/shadowsocks-rust @@ -1 +1 @@ -Subproject commit 622f01a93c0b5c6f6823ff3811cc6b3d244b6368 +Subproject commit 49df0ebbedef68874aac6b984e9c5b1762783691