[GH-ISSUE #186] Decryption Failed #168

Closed
opened 2026-03-03 11:37:40 +03:00 by kerem · 10 comments
Owner

Originally created by @fraee on GitHub (Mar 9, 2023).
Original GitHub issue: https://github.com/Finb/Bark/issues/186

感谢加入推送加密这个好功能,实际使用有点小问题:

使用手机端的示例bash脚本

#!/usr/bin/env bash

# Documentation: https://bark.day.app/#/encryption

set -e

# bark key
deviceKey='EpLgt4Z******4GTSmG'
# push payload
json='{"body": "test", "sound": "birdsong"}'

# must be 16 bit long
key='hgffbiytrc4686gj'
iv='gggvjkoptdaz5806'

# openssl requires Hex encoding of manual keys and IVs, not ASCII encoding.
key=$(printf $key | xxd -ps -c 200)
iv=$(printf $iv | xxd -ps -c 200)

ciphertext=$(echo -n $json | openssl enc -aes-128-cbc -K $key -iv $iv | base64)

# The console will print "A2kZdi2g2HUiV*************tzm3E4yA3RM=" 
echo $ciphertext

curl --data-urlencode "ciphertext=$ciphertext" https://api.day.app/$deviceKey

echo加密信息为:

/Q4Bwvvlv0IL5gAhgxEN1ard2*************mjyoX//LfwBtTlP4+YLXWtUEd

手机端收到的推送信息为:Decryption Failed

脚本执行环境:Macos 13.2.1

是我操作不当还是有其他问题,谢谢!

Originally created by @fraee on GitHub (Mar 9, 2023). Original GitHub issue: https://github.com/Finb/Bark/issues/186 感谢加入推送加密这个好功能,实际使用有点小问题: 使用手机端的示例bash脚本 ``` #!/usr/bin/env bash # Documentation: https://bark.day.app/#/encryption set -e # bark key deviceKey='EpLgt4Z******4GTSmG' # push payload json='{"body": "test", "sound": "birdsong"}' # must be 16 bit long key='hgffbiytrc4686gj' iv='gggvjkoptdaz5806' # openssl requires Hex encoding of manual keys and IVs, not ASCII encoding. key=$(printf $key | xxd -ps -c 200) iv=$(printf $iv | xxd -ps -c 200) ciphertext=$(echo -n $json | openssl enc -aes-128-cbc -K $key -iv $iv | base64) # The console will print "A2kZdi2g2HUiV*************tzm3E4yA3RM=" echo $ciphertext curl --data-urlencode "ciphertext=$ciphertext" https://api.day.app/$deviceKey ``` echo加密信息为: /Q4Bwvvlv0IL5gAhgxEN1ard2*************mjyoX//LfwBtTlP4+YLXWtUEd 手机端收到的推送信息为:Decryption Failed 脚本执行环境:Macos 13.2.1 是我操作不当还是有其他问题,谢谢!
kerem closed this issue 2026-03-03 11:37:40 +03:00
Author
Owner

@Finb commented on GitHub (Mar 9, 2023):

用这个key加密的密文应该是 “A2kZdi2g2HUiV*************tzm3E4yA3RM=”,好像是加密出错了
我用macOS 13.2 测试相同的key能正常发送, 你重新设置下key试试?

<!-- gh-comment-id:1461198039 --> @Finb commented on GitHub (Mar 9, 2023): 用这个key加密的密文应该是 “A2kZdi2g2HUiV*************tzm3E4yA3RM=”,好像是加密出错了 我用macOS 13.2 测试相同的key能正常发送, 你重新设置下key试试?
Author
Owner

@Finb commented on GitHub (Mar 9, 2023):

你执行下

openssl enc -h

echo "/Q4Bwvvlv0IL5gAhgxEN1ard2*************mjyoX//LfwBtTlP4+YLXWtUEd" | base64 -d

看看返回

<!-- gh-comment-id:1461198815 --> @Finb commented on GitHub (Mar 9, 2023): 你执行下 ```sh openssl enc -h ``` 和 ```sh echo "/Q4Bwvvlv0IL5gAhgxEN1ard2*************mjyoX//LfwBtTlP4+YLXWtUEd" | base64 -d ``` 看看返回
Author
Owner

@fraee commented on GitHub (Mar 9, 2023):

openssl enc -h

usage: enc -ciphername [-AadePp] [-base64] [-bufsize number] [-debug]
    [-in file] [-iter iterations] [-iv IV] [-K key] [-k password]
    [-kfile file] [-md digest] [-none] [-nopad] [-nosalt]
    [-out file] [-pass source] [-pbkdf2] [-S salt] [-salt]

 -A                 Process base64 data on one line (requires -a)
 -a                 Perform base64 encoding/decoding (alias -base64)
 -bufsize size      Specify the buffer size to use for I/O
 -d                 Decrypt the input data
 -debug             Print debugging information
 -e                 Encrypt the input data (default)
 -in file           Input file to read from (default stdin)
 -iter iterations   Specify iteration count and force use of PBKDF2
 -iv IV             IV to use, specified as a hexadecimal string
 -K key             Key to use, specified as a hexadecimal string
 -md digest         Digest to use to create a key from the passphrase
 -none              Use NULL cipher (no encryption or decryption)
 -nopad             Disable standard block padding
 -out file          Output file to write to (default stdout)
 -P                 Print out the salt, key and IV used, then exit
                      (no encryption or decryption is performed)
 -p                 Print out the salt, key and IV used
 -pass source       Password source
 -pbkdf2            Use the pbkdf2 key derivation function
 -S salt            Salt to use, specified as a hexadecimal string
 -salt              Use a salt in the key derivation routines (default)
 -v                 Verbose

Valid ciphername values:

 -aes-128-cbc              -aes-128-ccm              -aes-128-cfb             
 -aes-128-cfb1             -aes-128-cfb8             -aes-128-ctr             
 -aes-128-ecb              -aes-128-gcm              -aes-128-ofb             
 -aes-128-xts              -aes-192-cbc              -aes-192-ccm             
 -aes-192-cfb              -aes-192-cfb1             -aes-192-cfb8            
 -aes-192-ctr              -aes-192-ecb              -aes-192-gcm             
 -aes-192-ofb              -aes-256-cbc              -aes-256-ccm             
 -aes-256-cfb              -aes-256-cfb1             -aes-256-cfb8            
 -aes-256-ctr              -aes-256-ecb              -aes-256-gcm             
 -aes-256-ofb              -aes-256-xts              -aes128                  
 -aes192                   -aes256                   -bf                      
 -bf-cbc                   -bf-cfb                   -bf-ecb                  
 -bf-ofb                   -blowfish                 -camellia-128-cbc        
 -camellia-128-cfb         -camellia-128-cfb1        -camellia-128-cfb8       
 -camellia-128-ecb         -camellia-128-ofb         -camellia-192-cbc        
 -camellia-192-cfb         -camellia-192-cfb1        -camellia-192-cfb8       
 -camellia-192-ecb         -camellia-192-ofb         -camellia-256-cbc        
 -camellia-256-cfb         -camellia-256-cfb1        -camellia-256-cfb8       
 -camellia-256-ecb         -camellia-256-ofb         -camellia128             
 -camellia192              -camellia256              -cast                    
 -cast-cbc                 -cast5-cbc                -cast5-cfb               
 -cast5-ecb                -cast5-ofb                -chacha                  
 -des                      -des-cbc                  -des-cfb                 
 -des-cfb1                 -des-cfb8                 -des-ecb                 
 -des-ede                  -des-ede-cbc              -des-ede-cfb             
 -des-ede-ofb              -des-ede3                 -des-ede3-cbc            
 -des-ede3-cfb             -des-ede3-cfb1            -des-ede3-cfb8           
 -des-ede3-ofb             -des-ofb                  -des3                    
 -desx                     -desx-cbc                 -gost89                  
 -gost89-cnt               -gost89-ecb               -id-aes128-CCM           
 -id-aes128-GCM            -id-aes128-wrap           -id-aes192-CCM           
 -id-aes192-GCM            -id-aes192-wrap           -id-aes256-CCM           
 -id-aes256-GCM            -id-aes256-wrap           -rc2                     
 -rc2-40-cbc               -rc2-64-cbc               -rc2-cbc                 
 -rc2-cfb                  -rc2-ecb                  -rc2-ofb                 
 -rc4                      -rc4-40                   -rc4-hmac-md5            
 -sm4                      -sm4-cbc                  -sm4-cfb                 
 -sm4-ctr                  -sm4-ecb                  -sm4-ofb  

echo "/Q4Bwvvlv0IL5gAhgxEN1ard2SnNDk0dwerjIMEmjyoX//LfwBtTlP4+YLXWtUEd" | base64 -d

????B
ժ??)?M??? ?&?*??????>`?ֵA
<!-- gh-comment-id:1461205933 --> @fraee commented on GitHub (Mar 9, 2023): openssl enc -h ``` usage: enc -ciphername [-AadePp] [-base64] [-bufsize number] [-debug] [-in file] [-iter iterations] [-iv IV] [-K key] [-k password] [-kfile file] [-md digest] [-none] [-nopad] [-nosalt] [-out file] [-pass source] [-pbkdf2] [-S salt] [-salt] -A Process base64 data on one line (requires -a) -a Perform base64 encoding/decoding (alias -base64) -bufsize size Specify the buffer size to use for I/O -d Decrypt the input data -debug Print debugging information -e Encrypt the input data (default) -in file Input file to read from (default stdin) -iter iterations Specify iteration count and force use of PBKDF2 -iv IV IV to use, specified as a hexadecimal string -K key Key to use, specified as a hexadecimal string -md digest Digest to use to create a key from the passphrase -none Use NULL cipher (no encryption or decryption) -nopad Disable standard block padding -out file Output file to write to (default stdout) -P Print out the salt, key and IV used, then exit (no encryption or decryption is performed) -p Print out the salt, key and IV used -pass source Password source -pbkdf2 Use the pbkdf2 key derivation function -S salt Salt to use, specified as a hexadecimal string -salt Use a salt in the key derivation routines (default) -v Verbose Valid ciphername values: -aes-128-cbc -aes-128-ccm -aes-128-cfb -aes-128-cfb1 -aes-128-cfb8 -aes-128-ctr -aes-128-ecb -aes-128-gcm -aes-128-ofb -aes-128-xts -aes-192-cbc -aes-192-ccm -aes-192-cfb -aes-192-cfb1 -aes-192-cfb8 -aes-192-ctr -aes-192-ecb -aes-192-gcm -aes-192-ofb -aes-256-cbc -aes-256-ccm -aes-256-cfb -aes-256-cfb1 -aes-256-cfb8 -aes-256-ctr -aes-256-ecb -aes-256-gcm -aes-256-ofb -aes-256-xts -aes128 -aes192 -aes256 -bf -bf-cbc -bf-cfb -bf-ecb -bf-ofb -blowfish -camellia-128-cbc -camellia-128-cfb -camellia-128-cfb1 -camellia-128-cfb8 -camellia-128-ecb -camellia-128-ofb -camellia-192-cbc -camellia-192-cfb -camellia-192-cfb1 -camellia-192-cfb8 -camellia-192-ecb -camellia-192-ofb -camellia-256-cbc -camellia-256-cfb -camellia-256-cfb1 -camellia-256-cfb8 -camellia-256-ecb -camellia-256-ofb -camellia128 -camellia192 -camellia256 -cast -cast-cbc -cast5-cbc -cast5-cfb -cast5-ecb -cast5-ofb -chacha -des -des-cbc -des-cfb -des-cfb1 -des-cfb8 -des-ecb -des-ede -des-ede-cbc -des-ede-cfb -des-ede-ofb -des-ede3 -des-ede3-cbc -des-ede3-cfb -des-ede3-cfb1 -des-ede3-cfb8 -des-ede3-ofb -des-ofb -des3 -desx -desx-cbc -gost89 -gost89-cnt -gost89-ecb -id-aes128-CCM -id-aes128-GCM -id-aes128-wrap -id-aes192-CCM -id-aes192-GCM -id-aes192-wrap -id-aes256-CCM -id-aes256-GCM -id-aes256-wrap -rc2 -rc2-40-cbc -rc2-64-cbc -rc2-cbc -rc2-cfb -rc2-ecb -rc2-ofb -rc4 -rc4-40 -rc4-hmac-md5 -sm4 -sm4-cbc -sm4-cfb -sm4-ctr -sm4-ecb -sm4-ofb ``` echo "/Q4Bwvvlv0IL5gAhgxEN1ard2SnNDk0dwerjIMEmjyoX//LfwBtTlP4+YLXWtUEd" | base64 -d ``` ????B ժ??)?M??? ?&?*??????>`?ֵA ```
Author
Owner

@Finb commented on GitHub (Mar 9, 2023):

脚本有修改么?还是复制后原样执行的

<!-- gh-comment-id:1461239570 --> @Finb commented on GitHub (Mar 9, 2023): 脚本有修改么?还是复制后原样执行的
Author
Owner

@fraee commented on GitHub (Mar 9, 2023):

脚本有修改么?还是复制后原样执行的

没做任何修改 复制后保存为x.sh 使用sh x.sh 执行的

<!-- gh-comment-id:1461241504 --> @fraee commented on GitHub (Mar 9, 2023): > 脚本有修改么?还是复制后原样执行的 没做任何修改 复制后保存为x.sh 使用sh x.sh 执行的
Author
Owner

@Finb commented on GitHub (Mar 9, 2023):

能将app中复制的脚本原样发我么? 可以隐藏掉 deviceKey

<!-- gh-comment-id:1461258290 --> @Finb commented on GitHub (Mar 9, 2023): 能将app中复制的脚本原样发我么? 可以隐藏掉 deviceKey
Author
Owner

@fraee commented on GitHub (Mar 9, 2023):

能将app中复制的脚本原样发我么? 可以隐藏掉 deviceKey

好的

#!/usr/bin/env bash

# Documentation: https://bark.day.app/#/encryption

set -e

# bark key
deviceKey='EpLgt4Z3****4GTSmG'
# push payload
json='{"body": "test", "sound": "birdsong"}'

# must be 16 bit long
key='hgffbiytrc4686gj'
iv='gggvjkoptdaz5806'

# openssl requires Hex encoding of manual keys and IVs, not ASCII encoding.
key=$(printf $key | xxd -ps -c 200)
iv=$(printf $iv | xxd -ps -c 200)

ciphertext=$(echo -n $json | openssl enc -aes-128-cbc -K $key -iv $iv | base64)

# The console will print "A2kZdi2g2HUiVAEhQ1d80i5Xbg4b1cdBtzm3E4yA3RM="
echo $ciphertext

curl --data-urlencode "ciphertext=$ciphertext" https://api.day.app/$deviceKey
<!-- gh-comment-id:1461328975 --> @fraee commented on GitHub (Mar 9, 2023): > 能将app中复制的脚本原样发我么? 可以隐藏掉 deviceKey 好的 ``` #!/usr/bin/env bash # Documentation: https://bark.day.app/#/encryption set -e # bark key deviceKey='EpLgt4Z3****4GTSmG' # push payload json='{"body": "test", "sound": "birdsong"}' # must be 16 bit long key='hgffbiytrc4686gj' iv='gggvjkoptdaz5806' # openssl requires Hex encoding of manual keys and IVs, not ASCII encoding. key=$(printf $key | xxd -ps -c 200) iv=$(printf $iv | xxd -ps -c 200) ciphertext=$(echo -n $json | openssl enc -aes-128-cbc -K $key -iv $iv | base64) # The console will print "A2kZdi2g2HUiVAEhQ1d80i5Xbg4b1cdBtzm3E4yA3RM=" echo $ciphertext curl --data-urlencode "ciphertext=$ciphertext" https://api.day.app/$deviceKey ```
Author
Owner

@Finb commented on GitHub (Mar 9, 2023):

我用你提供的脚本,在 macOS 13.2 和 Ubuntu 20.04 上打印的 ciphertext 。用相同的key,在 windows 11 、Chrome、Edge上打印的值都是:
”du82KA6U/qfw+j1fPcQwUI6PKWB/sPYhJ07m6WePG9MADxFg34Q39ECAEOzNG6zx“

不是:
"/Q4Bwvvlv0IL5gAhgxEN1ard2*************mjyoX//LfwBtTlP4+YLXWtUEd"

应该是你执行环境有问题,只能你自己排查下看看是哪的问题, ciphertext 要打印的是上面这个才能对上。

<!-- gh-comment-id:1461364002 --> @Finb commented on GitHub (Mar 9, 2023): 我用你提供的脚本,在 macOS 13.2 和 Ubuntu 20.04 上打印的 ciphertext 。用相同的key,在 windows 11 、Chrome、Edge上打印的值都是: ”du82KA6U/qfw+j1fPcQwUI6PKWB/sPYhJ07m6WePG9MADxFg34Q39ECAEOzNG6zx“ 不是: "/Q4Bwvvlv0IL5gAhgxEN1ard2*************mjyoX//LfwBtTlP4+YLXWtUEd" 应该是你执行环境有问题,只能你自己排查下看看是哪的问题, ciphertext 要打印的是上面这个才能对上。
Author
Owner

@Finb commented on GitHub (Mar 9, 2023):

”A2kZdi2g2HUiVAEhQ1d80i5Xbg4b1cdBtzm3E4yA3RM“ 这个忽略,这是APP的一个BUG,这其实是 '{"body": "test"}'的密文,app 拼示例时没有改过来。

du82KA6U/qfw+j1fPcQwUI6PKWB/sPYhJ07m6WePG9MADxFg34Q39ECAEOzNG6zx 是 '{"body": "test", "sound": "birdsong"}' 的密文

<!-- gh-comment-id:1461367259 --> @Finb commented on GitHub (Mar 9, 2023): ”A2kZdi2g2HUiVAEhQ1d80i5Xbg4b1cdBtzm3E4yA3RM“ 这个忽略,这是APP的一个BUG,这其实是 '{"body": "test"}'的密文,app 拼示例时没有改过来。 du82KA6U/qfw+j1fPcQwUI6PKWB/sPYhJ07m6WePG9MADxFg34Q39ECAEOzNG6zx 是 '{"body": "test", "sound": "birdsong"}' 的密文
Author
Owner

@fraee commented on GitHub (Mar 9, 2023):

我用你提供的脚本,在 macOS 13.2 和 Ubuntu 20.04 上打印的 ciphertext 。用相同的key,在 windows 11 、Chrome、Edge上打印的值都是: ”du82KA6U/qfw+j1fPcQwUI6PKWB/sPYhJ07m6WePG9MADxFg34Q39ECAEOzNG6zx“

不是: "/Q4Bwvvlv0IL5gAhgxEN1ard2*************mjyoX//LfwBtTlP4+YLXWtUEd"

应该是你执行环境有问题,只能你自己排查下看看是哪的问题, ciphertext 要打印的是上面这个才能对上。

的确,在两台linux上实验都能正常收到解密后的信息,唯独macbook pro m1加密后的信息对不上。

用的是homebrew安装的官方commandline,和加密相关的只安装过gpg,按理说不应该有不同的加密结果。。。

既然是个例我就自行处理吧,还是谢谢!

<!-- gh-comment-id:1461485245 --> @fraee commented on GitHub (Mar 9, 2023): > 我用你提供的脚本,在 macOS 13.2 和 Ubuntu 20.04 上打印的 ciphertext 。用相同的key,在 windows 11 、Chrome、Edge上打印的值都是: ”du82KA6U/qfw+j1fPcQwUI6PKWB/sPYhJ07m6WePG9MADxFg34Q39ECAEOzNG6zx“ > > 不是: "/Q4Bwvvlv0IL5gAhgxEN1ard2*************mjyoX//LfwBtTlP4+YLXWtUEd" > > 应该是你执行环境有问题,只能你自己排查下看看是哪的问题, ciphertext 要打印的是上面这个才能对上。 的确,在两台linux上实验都能正常收到解密后的信息,唯独macbook pro m1加密后的信息对不上。 用的是homebrew安装的官方commandline,和加密相关的只安装过gpg,按理说不应该有不同的加密结果。。。 既然是个例我就自行处理吧,还是谢谢!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Bark#168
No description provided.