Skip to content

Commit

Permalink
修复:bark加密推送,解密失败 pppscn#307 pppscn#314
Browse files Browse the repository at this point in the history
  • Loading branch information
pppscn committed Jun 28, 2023
1 parent ec57b02 commit 65c3246
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,16 @@ class BarkFragment : BaseFragment<FragmentSendersBarkBinding?>(), View.OnClickLi
val title = binding!!.etTitleTemplate.text.toString().trim()
val key = binding!!.etEncryptionKey.text.toString().trim()
val iv = binding!!.etEncryptionIv.text.toString().trim()
if (transformation.startsWith("AES128") && (key.length != 16 || iv.length != 16)) {
if (transformation.startsWith("AES128") && key.length != 16) {
throw Exception(getString(R.string.bark_encryption_key_error1))
} else if (transformation.startsWith("AES192") && (key.length != 24 || iv.length != 24)) {
} else if (transformation.startsWith("AES192") && key.length != 24) {
throw Exception(getString(R.string.bark_encryption_key_error2))
} else if (transformation.startsWith("AES256") && (key.length != 32 || iv.length != 32)) {
} else if (transformation.startsWith("AES256") && key.length != 32) {
throw Exception(getString(R.string.bark_encryption_key_error3))
}
if (transformation.contains("CBC") && iv.length != 16) {
throw Exception(getString(R.string.bark_encryption_key_error4))
}

return BarkSetting(server, group, icon, sound, badge, url, barkLevel, title, transformation, key, iv)
}
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,10 @@
<string name="bark_encryption_iv">AES iv</string>
<string name="bark_encryption_iv_tips">corresponding iv on bark</string>
<string name="bark_encryption_key_regex" formatted="false" tools:ignore="TypographyDashes"><![CDATA[^[a-zA-Z0-9]{16}]]></string>
<string name="bark_encryption_key_error1">AES Key and iv must be 16 characters</string>
<string name="bark_encryption_key_error2">AES Key and iv must be 24 characters</string>
<string name="bark_encryption_key_error3">AES Key and iv must be 32 characters</string>
<string name="bark_encryption_key_error1">AES Key must be 16 characters</string>
<string name="bark_encryption_key_error2">AES Key must be 24 characters</string>
<string name="bark_encryption_key_error3">AES Key must be 32 characters</string>
<string name="bark_encryption_key_error4">AES iv must be 16 characters</string>

<string name="from_email_hint">Fill in the username before @</string>
<string name="from_email_full_hint">Fill in the format: [email protected]</string>
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,10 @@
<string name="bark_encryption_iv">偏移向量</string>
<string name="bark_encryption_iv_tips">对应bark上的iv</string>
<string name="bark_encryption_key_regex" formatted="false" tools:ignore="TypographyDashes"><![CDATA[^([a-zA-Z0-9]{16})? $]]></string>
<string name="bark_encryption_key_error1">加密密钥和偏移向量都必须是16位</string>
<string name="bark_encryption_key_error2">加密密钥和偏移向量都必须是24位</string>
<string name="bark_encryption_key_error3">加密密钥和偏移向量都必须是32位</string>
<string name="bark_encryption_key_error1">加密密钥必须是16位</string>
<string name="bark_encryption_key_error2">加密密钥必须是24位</string>
<string name="bark_encryption_key_error3">加密密钥必须是32位</string>
<string name="bark_encryption_key_error4">偏移向量必须是16位</string>

<string name="from_email_hint">填写 @ 前面的用户名</string>
<string name="from_email_full_hint">填写格式: [email protected]</string>
Expand Down

0 comments on commit 65c3246

Please sign in to comment.