Skip to content
Snippets Groups Projects
Commit da75e0a8 authored by Nico Dechesne (Stage)'s avatar Nico Dechesne (Stage)
Browse files

signlk.sh: fix indentation and style


Signed-off-by: default avatarNicolas Dechesne <nicolas.dechesne@linaro.org>
parent 16af7d46
Branches 64bit
No related tags found
No related merge requests found
......@@ -39,73 +39,71 @@ OU=""
set -e
for i in "$@"
do
case $i in
-i=*|--in=*)
INFILE="${i#*=}"
;;
-o=*|--out=*)
OUTFILE="${i#*=}"
;;
-OU=*|-ou=*)
OU="${i#*=}"
;;
-CN=*|-cn=*)
CN="${i#*=}"
;;
--tmpdir=*)
tmpdir="${i#*=}"
mkdir -p $tmpdir
NOCLEAN=1
;;
-d|--debug)
set -x
NOCLEAN=1
;;
-h*|--help*)
echo "signlk -i=input_file_name [-o=output_file_name]"
echo "-i input ELF/MBN file name"
echo "-o output file name, input_file_name with suffix of 'signed' as default "
echo "-cn common name "
echo "-ou organization unit "
echo "--tmpdir specify tmp folder to use"
exit 0
;;
*)
echo "unsupported option" # unknown option
echo "type signlk --help for help"
exit 1
;;
esac
for i in "$@"; do
case $i in
-i=*|--in=*)
INFILE="${i#*=}"
;;
-o=*|--out=*)
OUTFILE="${i#*=}"
;;
-OU=*|-ou=*)
OU="${i#*=}"
;;
-CN=*|-cn=*)
CN="${i#*=}"
;;
--tmpdir=*)
tmpdir="${i#*=}"
mkdir -p $tmpdir
NOCLEAN=1
;;
-d|--debug)
set -x
NOCLEAN=1
;;
-h*|--help*)
echo "signlk -i=input_file_name [-o=output_file_name]"
echo "-i input ELF/MBN file name"
echo "-o output file name, input_file_name with suffix of 'signed' as default "
echo "-cn common name "
echo "-ou organization unit "
echo "--tmpdir specify tmp folder to use"
exit 0
;;
*)
echo "unsupported option" # unknown option
echo "type signlk --help for help"
exit 1
;;
esac
done
if [ "$INFILE" = "" ]; then
echo "signlk -i=input_file_name [-o=output_file_name]"
exit 2
echo "signlk -i=input_file_name [-o=output_file_name]"
exit 2
fi
INFILE_filename=$(echo $INFILE | rev | cut -f 2- -d '.' | rev)
if [ "$OUTFILE" = "" ]; then
OUTFILE=$INFILE_filename"_signed.mbn"
OUTFILE=$INFILE_filename"_signed.mbn"
fi
echo "generating output file $OUTFILE"
[ -z $tmpdir ] && tmpdir=$(mktemp -d)
TMPOUTFILE=$tmpdir/"tmp.elf"
if [ ! "$(openssl version)" ]; then
echo "please install openssl"
exit 6
echo "please install openssl"
exit 6
fi
if [ ! "$(make -v)" ]; then
echo "please install gcc"
exit 7
echo "please install gcc"
exit 7
fi
if [ ! "$(g++ --version)" ]; then
echo "please install g++"
exit 8
echo "please install g++"
exit 8
fi
make -C $DIR/signer
......@@ -121,15 +119,15 @@ openssl sha256 -binary $tmpdir/header > $tmpdir/data
cat $tmpdir/hash>> $tmpdir/data
for f in $tmpdir/segment*; do
openssl sha256 -binary $f >> $tmpdir/data
openssl sha256 -binary $f >> $tmpdir/data
done
openssl sha256 -binary $tmpdir/data > $tmpdir/stp0
cat $tmpdir/Si > $tmpdir/tmpDigest0
cat $tmpdir/stp0 >> $tmpdir/tmpDigest0
cat $tmpdir/stp0 >> $tmpdir/tmpDigest0
openssl sha256 -binary $tmpdir/tmpDigest0 > $tmpdir/stp1
cat $tmpdir/So > $tmpdir/tmpDigest1
cat $tmpdir/stp1 >> $tmpdir/tmpDigest1
cat $tmpdir/stp1 >> $tmpdir/tmpDigest1
openssl sha256 -binary $tmpdir/tmpDigest1 > $tmpdir/dataToSign.bin
DATA=$tmpdir/data
......@@ -173,7 +171,7 @@ dd if=$TMPOUTFILE of=$OUTFILE bs=1 skip=$(($hash_seg_offset+$hash_seg_file_size)
# no cleanup in debug mode
if [ -z $NOCLEAN ]; then
echo rm -rf $tmpdir
rm -rf $tmpdir
fi
echo done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment