My objective is,
- To create
sha256
for all the required files(which go into.swu
) - To Sign
sw-description
file withRSA
algorithm.
My .swu
consists:
- kernel Image -
bzImage
- rootfile system -
panther2-usb-panther2.ext4
- software description file -
sw-description
- post install script -
postinstall_swu.sh
I have created a script which generates sha256
and signs sw-description
.
Here is the script:
#!/bin/bash
IMAGES="bzImage panther2-usb-panther2.ext4"
FILES="sw-description sw-description.sig postinstall_swu.sh $IMAGES"
echo "Executing swu signing script..."
cp ../sw-description .
cp ../postinstall_swu.sh .
cp ../../../../../deploy/images/panther2/bzImage .
cp ../../../../../deploy/images/panther2/panther2-usb-panther2.ext4 .
read -d ' ' SHA_ROOTFS < <(sha256sum panther2-usb-panther2.ext4)
read -d ' ' SHA_BZIMAGE < <(sha256sum bzImage)
read -d ' ' SHA_POSTINSTALL < <(sha256sum postinstall_swu.sh)
sed -i ':a;N;$!ba; s/sha256 = "[0-9A-Za-z]*"/sha256 = '"\"${SHA_ROOTFS}"\"'/1' sw-description
sed -i ':a;N;$!ba; s/sha256 = "[0-9A-Za-z]*"/sha256 = '"\"${SHA_BZIMAGE}"\"'/2' sw-description
sed -i ':a;N;$!ba; s/sha256 = "[0-9A-Za-z]*"/sha256 = '"\"${SHA_POSTINSTALL}"\"'/3' sw-description
openssl dgst -sha256 -sign ../priv.pem -passin file:../passphrase sw-description > sw-description.sig
for i in $FILES;do
echo $i;done | cpio -ov -H crc > panther2-swu-$USER-devbuild.swu
cp panther2-swu-$USER-devbuild.swu ../../../../../deploy/images/panther2
Is above approach better?
Is there a way to ask yocto/swupdate layer to generate sha256
for all above files(except sw-description
) and add these generated sha256
into sw-description file?
I can sign sw-description
by defining SWUPDATE_SIGNING
andSWUPDATE_PRIVATE_KEY
variables in my recipe file but
how to generate
sha256
?