Skip to content

Commit

Permalink
refactor(decoder): enforce Base64 encoded values to not be empty (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
pixincreate authored Sep 5, 2024
1 parent 6fc056a commit 195fb69
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/exchange.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ function base64_decode() {
local success_status=false
echo -e "\nDecoding keys from base64..."

# Check if any of the KEYS or individual key values are empty
if [ -z "${KEYS[AVB_BASE64]}" ] || [ -z "${KEYS[CERT_OTA_BASE64]}" ] || [ -z "${KEYS[OTA_BASE64]}" ] \
|| [ -z "${KEYS_AVB_BASE64}" ] || [ -z "${KEYS_CERT_OTA_BASE64}" ] || [ -z "${KEYS_OTA_BASE64}" ]; then
echo "Error: One or more BASE64 encoded values are empty. Please ensure all required keys are set."
exit 1
fi

# Continue with the rest of the script if all values are non-empty
echo -e "All KEY values are set. Proceeding with decoding..."

KEYS[AVB_BASE64]="${KEYS_AVB_BASE64:-${KEYS[AVB_BASE64]}}"
KEYS[CERT_OTA_BASE64]="${KEYS_CERT_OTA_BASE64:-${KEYS[CERT_OTA_BASE64]}}"
KEYS[OTA_BASE64]="${KEYS_OTA_BASE64:-${KEYS[OTA_BASE64]}}"
Expand Down

0 comments on commit 195fb69

Please sign in to comment.