-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tegra-helper-scripts: add a helper to wrap l4t_sign_image.sh
Mainly so we can pass the same TEGRA_SIGNING_ARGS options when doing file signing as we use for other signing operations. Signed-off-by: Matt Madison <[email protected]>
- Loading branch information
Showing
2 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
recipes-bsp/tegra-binaries/tegra-helper-scripts/tegra-signimage-helper.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/bin/bash | ||
keyfile= | ||
user_keyfile= | ||
to_remove= | ||
split=True | ||
chip= | ||
encrypting= | ||
|
||
ARGS=$(getopt -n $(basename "$0") -l "user_key:,chip:,nosplit" -o "u:v:" -- "$@") | ||
if [ $? -ne 0 ]; then | ||
echo "Error parsing options" >&2 | ||
exit 1 | ||
fi | ||
eval set -- "$ARGS" | ||
unset ARGS | ||
|
||
while true; do | ||
case "$1" in | ||
--chip) | ||
chip="$2" | ||
shift 2 | ||
;; | ||
--user_key) | ||
user_keyfile="$2" | ||
shift 2 | ||
;; | ||
--nosplit) | ||
split=False | ||
shift | ||
;; | ||
-u) | ||
keyfile="$2" | ||
shift 2 | ||
;; | ||
-v) | ||
# Accepted here to tell us that we need to | ||
# generate an all-zeros user_keyfile | ||
encrypting=yes | ||
shift 2 | ||
;; | ||
--) | ||
shift | ||
break | ||
;; | ||
*) | ||
echo "Error processing options" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [ -z "$chip" ]; then | ||
echo "ERR: --chip option not specified" >&2 | ||
exit 1 | ||
fi | ||
|
||
here=$(readlink -f $(dirname "$0")) | ||
|
||
if [ -x $here/l4t_sign_image.sh ]; then | ||
signimg="$here/l4t_sign_image.sh"; | ||
else | ||
hereparent=$(readlink -f "$here/.." 2>/dev/null) | ||
if [ -n "$hereparent" -a -x "$hereparent/l4t_sign_image.sh" ]; then | ||
signimg="$hereparent/l4t_sign_image.sh" | ||
fi | ||
fi | ||
if [ -z "$signimg" ]; then | ||
echo "ERR: missing l4t_sign_image script" >&2 | ||
exit 1 | ||
fi | ||
|
||
if [ "$keyfile" = "None" ]; then | ||
keyfile="" | ||
fi | ||
|
||
tmpuserkey= | ||
if [ -z "$user_keyfile" -a "$encrypting" = "yes" ]; then | ||
tmpuserkey=$(mktemp) | ||
echo "0x00000000 0x00000000 0x00000000 0x00000000" > "$tmpuserkey" | ||
user_keyfile=$(readlink -f "$tmpuserkey") | ||
echo "Using null key for encryption" >&2 | ||
fi | ||
rc=0 | ||
while [ -n "$1" ]; do | ||
filetosign="$1" | ||
shift | ||
if ! "$signimg" --file "$filetosign" --key "$keyfile" --encrypt_key "$user_keyfile" --chip "$chip" --split $split; then | ||
echo "Error signing $filetosign" >&2 | ||
rc=1 | ||
fi | ||
done | ||
[ -z "$tmpuserkey" ] || rm -f "$tmpuserkey" | ||
exit $rc |