1
0
mirror of https://github.com/5im-0n/sshenc.sh.git synced 2025-08-02 11:20:05 +02:00

Fixes "no valid decryption key supplied" issue when encrypted text/key is longer in length

More information can be found at https://stackoverflow.com/questions/35289912/openssl-enc-base64-d-does-not-decode-strings-after-a-certain-length
This commit is contained in:
Shahzaib Sheikh
2019-11-22 03:39:46 +05:00
parent ba04e9f548
commit f4127b7282

View File

@@ -67,7 +67,7 @@ if [[ "${#public_key[@]}" > 0 ]]; then
echo "-- /keys" echo "-- /keys"
if cat | openssl enc -aes-256-cbc -salt -pass file:"$temp_file_key" > "$temp_file"; then if cat | openssl enc -aes-256-cbc -salt -pass file:"$temp_file_key" > "$temp_file"; then
openssl base64 < "$temp_file" openssl base64 -A < "$temp_file"
fi fi
#decrypt #decrypt
@@ -90,8 +90,8 @@ elif [[ -e "$private_key" ]]; then
decrypted=false decrypted=false
for key in "${keys[@]}" for key in "${keys[@]}"
do do
if ((echo "$key" | openssl base64 -d | openssl rsautl -decrypt -ssl -inkey "$private_key" > "$temp_file") > /dev/null 2>&1); then if ((echo "$key" | openssl base64 -d -A | openssl rsautl -decrypt -ssl -inkey "$private_key" > "$temp_file") > /dev/null 2>&1); then
if echo "$cypher" | openssl base64 -d | openssl aes-256-cbc -d -pass file:"$temp_file"; then if echo "$cypher" | openssl base64 -d -A | openssl aes-256-cbc -d -pass file:"$temp_file"; then
decrypted=true decrypted=true
fi fi
fi fi