Skip to content

Commit ffa7f80

Browse files
lirui34dbkinder
authored andcommitted
doc: Add tutorial to learn to sign binaries of a Clear Linux image.
This tutorial will describe steps to sign binaries of a Clear Linux image that allows user to launch VM throught the secure boot enabled OVMF. Signed-off-by: lirui34 <ruix.li@intel.com>
1 parent be44e13 commit ffa7f80

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

doc/scripts/sign_image.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
# Copyright (C) 2019 Intel Corporation.
3+
# SPDX-License-Identifier: BSD-3-Clause
4+
5+
help() {
6+
echo "==================================================================================================="
7+
echo "Usage:"
8+
echo "$SIGN_SCRIPT param1 param2 param3"
9+
echo " param1: path to clear linux image"
10+
echo " param2: path to the key"
11+
echo " param3: path to the cert"
12+
echo ""
13+
echo "Pre-requisites:"
14+
echo " 1. install sbsigntool: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git/"
15+
echo " 2. download clear linux release for VM and extract the image: https://cdn.download.clearlinux.org/releases/"
16+
echo " 3. run this script with sudo"
17+
echo "==================================================================================================="
18+
}
19+
20+
sign_binaries_under_dir() {
21+
local DIR=$1
22+
for file in $DIR/*
23+
do
24+
if test -f $file
25+
then
26+
echo $file
27+
(sbsign --key $SIGN_KEY --cert $SIGN_CRT --output $file $file) && (echo "sign $file succeed")
28+
else
29+
sign_binaries_under_dir $file
30+
fi
31+
done
32+
}
33+
34+
35+
SIGN_SCRIPT=$0
36+
CLEAR_UOS_IMAGE=$1
37+
SIGN_KEY=$2
38+
SIGN_CRT=$3
39+
BOOT_PART="p1"
40+
MNT_POINT=/mnt
41+
42+
if [[ ! -f $1 || ! -f $2 || ! -f $3 ]]
43+
then
44+
help
45+
exit
46+
fi
47+
48+
if [ "$(id -u)" != "0" ]
49+
then
50+
echo "This script requires root privilege. Please run it with sudo or switch to root user."
51+
exit
52+
fi
53+
54+
CLEAR_UOS_IMAGE_SIGNED=$CLEAR_UOS_IMAGE.signed
55+
56+
cp $CLEAR_UOS_IMAGE $CLEAR_UOS_IMAGE_SIGNED
57+
58+
LOOP_DEV=`losetup -f -P --show $CLEAR_UOS_IMAGE_SIGNED`
59+
60+
if [ ! -d $MNT_POINT ]
61+
then
62+
mkdir $MNT_POINT
63+
fi
64+
65+
(mount $LOOP_DEV$BOOT_PART $MNT_POINT) && (sign_binaries_under_dir $MNT_POINT/EFI)
66+
67+
umount /mnt
68+
sync
69+
losetup -d $LOOP_DEV
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.. _sign_clear_linux_image:
2+
3+
How to sign binaries of the Clear Linux image
4+
#############################################
5+
6+
In this tutorial, you will see how to sign the binaries of a Clear Linux image so that you can
7+
boot it through a secure boot enabled OVMF.
8+
9+
Prerequisites
10+
*************
11+
* Install **sbsigntool** on Ubuntu (Verified on 18.04)::
12+
13+
$ sudo apt install sbsigntool
14+
15+
* Download and extract the Clear Linux image from the `release <https://cdn.download.clearlinux.org/releases/>`_::
16+
17+
$ export https_proxy=<your https proxy>:<port>
18+
$ wget https://cdn.download.clearlinux.org/releases/29880/clear/clear-29880-kvm.img.xz
19+
$ unxz clear-29880-kvm.img.xz
20+
21+
* Download script `sign_image.sh
22+
<https://raw.githubusercontent.com/projectacrn/acrn-hypervisor/master/doc/scripts/>`_ on Ubuntu.
23+
24+
Steps to sign the binaries of the Clear Linux image
25+
***************************************************
26+
#. Follow the `KeyGeneration <https://wiki.ubuntu.com/UEFI/SecureBoot/KeyManagement/KeyGeneration>`_ to generate
27+
the key and certification which will be used to sign the binaries.
28+
29+
#. Get these files from the previous step:
30+
31+
* archive-subkey-private.key
32+
* archive-subkey-public.crt
33+
34+
#. Use the script to sign binaries in the Clear Linux image::
35+
36+
$ sudo sh sign_image.sh $PATH_TO_CLEAR_IMAGE $PATH_TO_KEY $PATH_TO_CERT
37+
38+
#. **clear-xxx-kvm.img.signed** will be generated in the same folder as the original clear-xxx-kvm.img.

0 commit comments

Comments
 (0)