Skip to content

Commit

Permalink
Hotfix for password checking fail (#3027)
Browse files Browse the repository at this point in the history
* Hotfix for `iPSK:uPSK`(2022-blake3-*) password checking fail.

* Fix password check

Fix base64 password check.
Update dependencies.
  • Loading branch information
dev4u authored Mar 19, 2023
1 parent 5359cb5 commit 0c710e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ 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."
if (profile.method !in setOf(
"2022-blake3-aes-128-gcm",
"2022-blake3-aes-256-gcm",
"2022-blake3-chacha20-poly1305",
)) {
for (pwd in profile.password.split(":")) {
require(Base64.decode(pwd, Base64.DEFAULT).size in arrayOf(16, 32)) {
"The Base64 Key is invalid."
}
}
}
}

Expand Down

0 comments on commit 0c710e2

Please sign in to comment.