#!/bin/sh
ret=0
p=/tmp/update
target=$(cat $p/certificate.info | grep "Target" | cut -d":" -f2)
openssl rsautl -decrypt -in $p/keysuit.enc -inkey "$1" -out $p/keysuit || ret=1


eval $(cat $p/keysuit)
openssl aes-256-cbc -k $key -iv $iv -S $salt -d -in $p/$target.aes -out "$2" || ret=1
chmod u+x $2
exit $ret