| 1 |
<?xml version="1.0"?> |
| 2 |
<!--*-nxml-*--> |
| 3 |
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
| 4 |
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
| 5 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 6 |
<refentry id="systemd-measure" xmlns:xi="http://www.w3.org/2001/XInclude" conditional='HAVE_TPM2 HAVE_BLKID HAVE_OPENSSL'> |
| 7 |
|
| 8 |
<refentryinfo> |
| 9 |
<title>systemd-measure</title> |
| 10 |
<productname>systemd</productname> |
| 11 |
</refentryinfo> |
| 12 |
|
| 13 |
<refmeta> |
| 14 |
<refentrytitle>systemd-measure</refentrytitle> |
| 15 |
<manvolnum>1</manvolnum> |
| 16 |
</refmeta> |
| 17 |
|
| 18 |
<refnamediv> |
| 19 |
<refname>systemd-measure</refname> |
| 20 |
<refpurpose>Pre-calculate and sign expected TPM2 PCR 11 values for booted unified kernel images</refpurpose> |
| 21 |
</refnamediv> |
| 22 |
|
| 23 |
<refsynopsisdiv> |
| 24 |
<cmdsynopsis> |
| 25 |
<command>/usr/lib/systemd/systemd-measure</command> <arg choice="opt" rep="repeat">OPTIONS</arg> |
| 26 |
</cmdsynopsis> |
| 27 |
</refsynopsisdiv> |
| 28 |
|
| 29 |
<refsect1> |
| 30 |
<title>Description</title> |
| 31 |
|
| 32 |
<para>Note: this command is experimental for now. While it is likely to become a regular component of |
| 33 |
systemd, it might still change in behaviour and interface.</para> |
| 34 |
|
| 35 |
<para><command>systemd-measure</command> is a tool that may be used to pre-calculate and sign the |
| 36 |
expected TPM2 PCR 11 values that should be seen when a Linux <ulink |
| 37 |
url="https://uapi-group.org/specifications/specs/unified_kernel_image/">UAPI.5 Unified Kernel Image |
| 38 |
(UKI)</ulink> based on |
| 39 |
<citerefentry><refentrytitle>systemd-stub</refentrytitle><manvolnum>7</manvolnum></citerefentry> is |
| 40 |
booted up. It accepts paths to the ELF kernel image file, initrd image file, devicetree file, kernel |
| 41 |
command line file, |
| 42 |
<citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> file, boot |
| 43 |
splash file, and TPM2 PCR PEM public key file that make up the unified kernel image, and determines the |
| 44 |
PCR values expected to be in place after booting the image. Calculation starts with a zero-initialized |
| 45 |
PCR 11, and is executed in a fashion compatible with what <filename>systemd-stub</filename> does at boot. |
| 46 |
The result may optionally be signed cryptographically, to allow TPM2 policies that can only be unlocked |
| 47 |
if a certain set of kernels is booted, for which such a PCR signature can be provided.</para> |
| 48 |
|
| 49 |
<para>It usually does not make sense to call this tool directly when constructing a UKI. Instead, |
| 50 |
<citerefentry><refentrytitle>ukify</refentrytitle><manvolnum>1</manvolnum></citerefentry> should be used; |
| 51 |
it will invoke <command>systemd-measure</command> and take care of embedding the resulting measurements |
| 52 |
into the UKI.</para> |
| 53 |
</refsect1> |
| 54 |
|
| 55 |
<refsect1> |
| 56 |
<title>Commands</title> |
| 57 |
|
| 58 |
<para>The following commands are understood:</para> |
| 59 |
|
| 60 |
<variablelist> |
| 61 |
<varlistentry> |
| 62 |
<term><command>status</command></term> |
| 63 |
|
| 64 |
<listitem><para>This is the default command if none is specified. This queries the local system's |
| 65 |
TPM2 PCR 11 values and displays them. The data is written in a similar format as the |
| 66 |
<command>calculate</command> command below, and may be used to quickly compare expectation with |
| 67 |
reality.</para> |
| 68 |
|
| 69 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 70 |
</varlistentry> |
| 71 |
|
| 72 |
<varlistentry> |
| 73 |
<term><command>calculate</command></term> |
| 74 |
|
| 75 |
<listitem><para>Pre-calculate the expected values seen in PCR register 11 after boot-up of a unified |
| 76 |
kernel image consisting of the components specified with <option>--linux=</option>, |
| 77 |
<option>--osrel=</option>, <option>--cmdline=</option>, <option>--initrd=</option>, |
| 78 |
<option>--ucode=</option>, <option>--splash=</option>, <option>--dtb=</option>, |
| 79 |
<option>--uname=</option>, <option>--sbat=</option>, <option>--pcrpkey=</option>, |
| 80 |
<option>--profile=</option>, <option>--dtbauto=</option>, <option>--hwids=</option>, see below. Only <option>--linux=</option> is mandatory. (Alternatively, |
| 81 |
specify <option>--current</option> to use the current values of PCR register 11 instead.)</para> |
| 82 |
|
| 83 |
<xi:include href="version-info.xml" xpointer="v252"/> |
| 84 |
</listitem> |
| 85 |
</varlistentry> |
| 86 |
|
| 87 |
<varlistentry> |
| 88 |
<term><command>sign</command></term> |
| 89 |
|
| 90 |
<listitem><para>As with the <command>calculate</command> command, pre-calculate the expected value |
| 91 |
seen in TPM2 PCR register 11 after boot-up of a unified kernel image. Then, cryptographically sign |
| 92 |
the resulting values with the private/public key pair (RSA) configured via |
| 93 |
<option>--private-key=</option> and <option>--public-key=</option>. This will write a JSON object to |
| 94 |
standard output that contains signatures for all specified PCR banks (see the |
| 95 |
<option>--bank=</option> option below), which may be used to unlock encrypted credentials (see |
| 96 |
<citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry>) or |
| 97 |
LUKS volumes (see |
| 98 |
<citerefentry><refentrytitle>[email protected]</refentrytitle><manvolnum>8</manvolnum></citerefentry>). |
| 99 |
This allows binding secrets to a set of kernels for which such PCR 11 signatures can be |
| 100 |
provided.</para> |
| 101 |
|
| 102 |
<para>Note that a TPM2 device must be available for this signing to take place, even though the |
| 103 |
result is not tied to any TPM2 device or its state.</para> |
| 104 |
|
| 105 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 106 |
</varlistentry> |
| 107 |
|
| 108 |
<varlistentry> |
| 109 |
<term><command>policy-digest</command></term> |
| 110 |
|
| 111 |
<listitem><para>As with the <command>sign</command> command, pre-calculate the expected value |
| 112 |
seen in TPM2 PCR register 11 after boot-up of a unified kernel image. Then, compute the resulting |
| 113 |
TPM2 policy and print its digest. This will write a JSON object to standard output that contains |
| 114 |
the policy digests for all specified PCR banks (see the <option>--bank=</option> option below), |
| 115 |
so that it may be signed offline, for the cases where the private key is not directly accessible. |
| 116 |
If <option>--public-key=</option> or <option>--certificate=</option> are specified, the JSON object |
| 117 |
will also contain the key fingerprint.</para> |
| 118 |
|
| 119 |
<xi:include href="version-info.xml" xpointer="v258"/></listitem> |
| 120 |
</varlistentry> |
| 121 |
</variablelist> |
| 122 |
</refsect1> |
| 123 |
|
| 124 |
<refsect1> |
| 125 |
<title>Options</title> |
| 126 |
|
| 127 |
<para>The following options are understood:</para> |
| 128 |
|
| 129 |
<variablelist> |
| 130 |
<varlistentry> |
| 131 |
<term><option>--linux=<replaceable>PATH</replaceable></option></term> |
| 132 |
<term><option>--osrel=<replaceable>PATH</replaceable></option></term> |
| 133 |
<term><option>--cmdline=<replaceable>PATH</replaceable></option></term> |
| 134 |
<term><option>--initrd=<replaceable>PATH</replaceable></option></term> |
| 135 |
<term><option>--ucode=<replaceable>PATH</replaceable></option></term> |
| 136 |
<term><option>--splash=<replaceable>PATH</replaceable></option></term> |
| 137 |
<term><option>--dtb=<replaceable>PATH</replaceable></option></term> |
| 138 |
<term><option>--uname=<replaceable>PATH</replaceable></option></term> |
| 139 |
<term><option>--sbat=<replaceable>PATH</replaceable></option></term> |
| 140 |
<term><option>--pcrpkey=<replaceable>PATH</replaceable></option></term> |
| 141 |
<term><option>--profile=<replaceable>PATH</replaceable></option></term> |
| 142 |
<term><option>--dtbauto=<replaceable>PATH</replaceable></option></term> |
| 143 |
<term><option>--hwids=<replaceable>PATH</replaceable></option></term> |
| 144 |
|
| 145 |
<listitem><para>When used with the <command>calculate</command> or <command>sign</command> verb, |
| 146 |
configures the files to read the unified kernel image components from. Each option corresponds with |
| 147 |
the equally named section in the unified kernel PE file. The <option>--linux=</option> switch expects |
| 148 |
the path to the ELF kernel file that the unified PE kernel will wrap. All switches except |
| 149 |
<option>--linux=</option> are optional. Each option may be used at most once.</para> |
| 150 |
|
| 151 |
<xi:include href="version-info.xml" xpointer="v252"/> |
| 152 |
|
| 153 |
<para id="v257">With the exception of <option>--profile=</option>, <option>--dtbauto=</option> and <option>--hwids=</option>, which have been added in version |
| 154 |
257.</para></listitem> |
| 155 |
</varlistentry> |
| 156 |
|
| 157 |
<varlistentry> |
| 158 |
<term><option>--current</option></term> |
| 159 |
<listitem><para>When used with the <command>calculate</command> or <command>sign</command> verb, |
| 160 |
takes the PCR 11 values currently in effect for the system (which should typically reflect the hashes |
| 161 |
of the currently booted kernel). This can be used in place of <option>--linux=</option> and the other |
| 162 |
switches listed above.</para> |
| 163 |
|
| 164 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 165 |
</varlistentry> |
| 166 |
|
| 167 |
<varlistentry> |
| 168 |
<term><option>--bank=<replaceable>DIGEST</replaceable></option></term> |
| 169 |
|
| 170 |
<listitem><para>Controls the PCR banks to pre-calculate the PCR values for – in case |
| 171 |
<command>calculate</command> or <command>sign</command> is invoked –, or the banks to show in the |
| 172 |
<command>status</command> output. May be used more then once to specify multiple banks. If not |
| 173 |
specified, defaults to the four banks <literal>sha1</literal>, <literal>sha256</literal>, |
| 174 |
<literal>sha384</literal>, <literal>sha512</literal>.</para> |
| 175 |
|
| 176 |
<para>Note that some operating systems disable support for SHA1-based signatures, in which case this |
| 177 |
operation will fail. Please consult your OS' documentation for details on how to override the OS |
| 178 |
security policy around this.</para> |
| 179 |
|
| 180 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 181 |
</varlistentry> |
| 182 |
|
| 183 |
<varlistentry> |
| 184 |
<term><option>--private-key=<replaceable>PATH</replaceable></option></term> |
| 185 |
<term><option>--public-key=<replaceable>PATH</replaceable></option></term> |
| 186 |
<term><option>--certificate=<replaceable>PATH</replaceable></option></term> |
| 187 |
|
| 188 |
<listitem><para>These switches take paths to a pair of PEM encoded RSA key files, for use with |
| 189 |
the <command>sign</command> command.</para> |
| 190 |
|
| 191 |
<para>Note the difference between the <option>--pcrpkey=</option> and <option>--public-key=</option> |
| 192 |
switches. The former selects the data to include in the <literal>.pcrpkey</literal> PE section of the |
| 193 |
unified kernel image, the latter picks the public key of the key pair used to sign the resulting PCR |
| 194 |
11 values. The former is the key that the booted system will likely use to lock disk and credential |
| 195 |
encryption to, the latter is the key used for unlocking such resources again. Hence, typically the |
| 196 |
same PEM key should be supplied in both cases.</para> |
| 197 |
|
| 198 |
<para>If the <option>--public-key=</option> is not specified but <option>--private-key=</option> is |
| 199 |
specified, the public key is automatically derived from the private key.</para> |
| 200 |
|
| 201 |
<para><option>--certificate=</option> can be used to specify an X.509 certificate as an alternative |
| 202 |
to <option>--public-key=</option> since v256.</para> |
| 203 |
|
| 204 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 205 |
</varlistentry> |
| 206 |
|
| 207 |
<varlistentry> |
| 208 |
<term><option>--private-key=<replaceable>PATH/URI</replaceable></option></term> |
| 209 |
<term><option>--private-key-source=<replaceable>TYPE</replaceable>[:<replaceable>NAME</replaceable>]</option></term> |
| 210 |
<term><option>--certificate=<replaceable>PATH/URI</replaceable></option></term> |
| 211 |
<term><option>--certificate-source=<replaceable>TYPE</replaceable>[:<replaceable>NAME</replaceable>]</option></term> |
| 212 |
|
| 213 |
<listitem><para>As an alternative to <option>--public-key=</option> for the |
| 214 |
<command>sign</command> command, these switches can be used to sign with an hardware token. The |
| 215 |
private key option can take a path or a URI that will be passed to the OpenSSL engine or |
| 216 |
provider, as specified by <option>--private-key-source=</option> as a type:name tuple, such as |
| 217 |
engine:pkcs11. The specified OpenSSL signing engine or provider will be used to sign.</para> |
| 218 |
|
| 219 |
<para>The <option>--certificate=</option> option also takes a path or a URI that will be passed to |
| 220 |
the OpenSSL provider, as specified by <option>--certificate-source=</option> as a |
| 221 |
<literal>type:name</literal> tuple, such as <literal>provider:pkcs11</literal>. Note that unlike |
| 222 |
<option>--private-key-source=</option> this option only supports providers and not engines.</para> |
| 223 |
|
| 224 |
<xi:include href="version-info.xml" xpointer="v256"/></listitem> |
| 225 |
</varlistentry> |
| 226 |
|
| 227 |
<varlistentry> |
| 228 |
<term><option>--tpm2-device=<replaceable>PATH</replaceable></option></term> |
| 229 |
|
| 230 |
<listitem><para>Controls which TPM2 device to use. Expects a device node path referring to the TPM2 |
| 231 |
chip (e.g. <filename>/dev/tpmrm0</filename>). Alternatively the special value <literal>auto</literal> |
| 232 |
may be specified, in order to automatically determine the device node of a suitable TPM2 device (of |
| 233 |
which there must be exactly one). The special value <literal>list</literal> may be used to enumerate |
| 234 |
all suitable TPM2 devices currently discovered.</para> |
| 235 |
|
| 236 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 237 |
</varlistentry> |
| 238 |
|
| 239 |
<varlistentry> |
| 240 |
<term><option>--phase=<replaceable>PHASE</replaceable></option></term> |
| 241 |
|
| 242 |
<listitem><para>Controls which boot phases to calculate expected PCR 11 values for. This takes a |
| 243 |
series of colon-separated strings that encode boot "paths" for entering a specific phase of the boot |
| 244 |
process. Each of the specified strings is measured by the |
| 245 |
<filename>systemd-pcrphase-initrd.service</filename>, |
| 246 |
<filename>systemd-pcrphase-sysinit.service</filename>, and |
| 247 |
<citerefentry><refentrytitle>systemd-pcrphase.service</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
| 248 |
into PCR 11 during different milestones of the boot process. This switch may be specified multiple |
| 249 |
times to calculate PCR values for multiple boot phases at once. If not used defaults to |
| 250 |
<literal>enter-initrd</literal>, <literal>enter-initrd:leave-initrd</literal>, |
| 251 |
<literal>enter-initrd:leave-initrd:sysinit</literal>, |
| 252 |
<literal>enter-initrd:leave-initrd:sysinit:ready</literal>, i.e. calculates expected PCR values for |
| 253 |
the boot phase in the initrd, during early boot, during later boot, and during system runtime, but |
| 254 |
excluding the phases before the initrd or when shutting down. This setting is honoured both by |
| 255 |
<command>calculate</command> and <command>sign</command>. When used with the latter it is particularly |
| 256 |
useful for generating PCR signatures that can only be used for unlocking resources during specific |
| 257 |
parts of the boot process.</para> |
| 258 |
|
| 259 |
<para>For further details about PCR boot phases, see |
| 260 |
<citerefentry><refentrytitle>systemd-pcrphase.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para> |
| 261 |
|
| 262 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 263 |
</varlistentry> |
| 264 |
|
| 265 |
<varlistentry> |
| 266 |
<term><option>--append=<replaceable>PATH</replaceable></option></term> |
| 267 |
|
| 268 |
<listitem><para>When generating a PCR JSON signature (via the <command>sign</command> command), |
| 269 |
combine it with a previously generated PCR JSON signature, and output it as one. The specified path |
| 270 |
must refer to a regular file that contains a valid JSON PCR signature object. The specified file is |
| 271 |
not modified. It will be read first, then the newly generated signature appended to it, and the |
| 272 |
resulting object is written to standard output. Use this to generate a single JSON object consisting |
| 273 |
from signatures made with a number of signing keys (for example, to have one key per boot phase). The |
| 274 |
command will suppress duplicates: if a specific signature is already included in a JSON signature |
| 275 |
object it is not added a second time.</para> |
| 276 |
|
| 277 |
<xi:include href="version-info.xml" xpointer="v253"/></listitem> |
| 278 |
</varlistentry> |
| 279 |
|
| 280 |
<xi:include href="standard-options.xml" xpointer="json" /> |
| 281 |
<xi:include href="standard-options.xml" xpointer="no-pager" /> |
| 282 |
<xi:include href="standard-options.xml" xpointer="help" /> |
| 283 |
<xi:include href="standard-options.xml" xpointer="version" /> |
| 284 |
</variablelist> |
| 285 |
</refsect1> |
| 286 |
|
| 287 |
<refsect1> |
| 288 |
<title>Examples</title> |
| 289 |
|
| 290 |
<example> |
| 291 |
<title>Generate a unified kernel image, and calculate the expected TPM PCR 11 value</title> |
| 292 |
|
| 293 |
<programlisting>$ ukify build \ |
| 294 |
--linux=vmlinux \ |
| 295 |
--initrd=initrd.cpio \ |
| 296 |
[email protected] \ |
| 297 |
[email protected] \ |
| 298 |
--splash=splash.bmp \ |
| 299 |
--devicetree=devicetree.dtb \ |
| 300 |
--measure \ |
| 301 |
--output=vmlinux.efi |
| 302 |
11:sha1=d775a7b4482450ac77e03ee19bda90bd792d6ec7 |
| 303 |
11:sha256=bc6170f9ce28eb051ab465cd62be8cf63985276766cf9faf527ffefb66f45651 |
| 304 |
11:sha384=1cf67dff4757e61e5...7f49ad720be02fd07263e1f93061243aec599d1ee4b4 |
| 305 |
11:sha512=8e79acd3ddbbc8282...0c3e8ec0c714821032038f525f744960bcd082d937da |
| 306 |
</programlisting> |
| 307 |
|
| 308 |
<para><citerefentry><refentrytitle>ukify</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 309 |
internally calls <command>systemd-measure</command>. The output with hashes is from |
| 310 |
<command>systemd-measure</command>.</para> |
| 311 |
</example> |
| 312 |
|
| 313 |
<example> |
| 314 |
<title>Generate a private/public key pair, a unified kernel image, and a TPM PCR 11 signature for |
| 315 |
it, and embed the signature and the public key in the image</title> |
| 316 |
|
| 317 |
<programlisting>$ openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out tpm2-pcr-private-key.pem |
| 318 |
..+.+++++++++......+.........+......+.......+....+.....+.+...+.......... |
| 319 |
$ openssl rsa -pubout -in tpm2-pcr-private-key.pem -out tpm2-pcr-public-key.pem |
| 320 |
$ systemd-measure sign \ |
| 321 |
--linux=vmlinux \ |
| 322 |
--osrel=os-release.txt \ |
| 323 |
--cmdline=cmdline.txt \ |
| 324 |
--initrd=initrd.cpio \ |
| 325 |
--splash=splash.bmp \ |
| 326 |
--dtb=devicetree.dtb \ |
| 327 |
--pcrpkey=tpm2-pcr-public-key.pem \ |
| 328 |
--bank=sha1 \ |
| 329 |
--bank=sha256 \ |
| 330 |
--private-key=tpm2-pcr-private-key.pem \ |
| 331 |
--public-key=tpm2-pcr-public-key.pem >tpm2-pcr-signature.json |
| 332 |
$ ukify build \ |
| 333 |
--linux=vmlinux \ |
| 334 |
--initrd=initrd.cpio \ |
| 335 |
[email protected] \ |
| 336 |
[email protected] \ |
| 337 |
--splash=splash.bmp \ |
| 338 |
--devicetree=devicetree.dtb \ |
| 339 |
--pcr-private-key=tpm2-pcr-private-key.pem \ |
| 340 |
--pcr-public-key=tpm2-pcr-public-key.pem \ |
| 341 |
--pcr-banks=sha1,sha256 \ |
| 342 |
--output=vmlinuz.efi</programlisting> |
| 343 |
|
| 344 |
<para>Later on, enroll the signed PCR policy on a LUKS volume:</para> |
| 345 |
|
| 346 |
<programlisting># systemd-cryptenroll --tpm2-device=auto \ |
| 347 |
--tpm2-public-key=tpm2-pcr-public-key.pem \ |
| 348 |
--tpm2-signature=tpm2-pcr-signature.json \ |
| 349 |
/dev/sda5</programlisting> |
| 350 |
|
| 351 |
<para>And then unlock the device with the signature:</para> |
| 352 |
|
| 353 |
<programlisting># systemd-cryptsetup attach \ |
| 354 |
volume5 /dev/sda5 - \ |
| 355 |
tpm2-device=auto,tpm2-signature=/path/to/tpm2-pcr-signature.json</programlisting> |
| 356 |
|
| 357 |
<para>Note that when the generated unified kernel image <filename>vmlinux.efi</filename> is booted, the |
| 358 |
signature and public key files will be placed at locations <command>systemd-cryptenroll</command> and |
| 359 |
<command>systemd-cryptsetup</command> will look for anyway, and thus these paths do not actually need to |
| 360 |
be specified.</para> |
| 361 |
</example> |
| 362 |
|
| 363 |
<example> |
| 364 |
<title>Introduce a second public key, signing the same kernel PCR measurements, but only for the initrd boot phase</title> |
| 365 |
|
| 366 |
<para>This example extends the previous one, but we now introduce a second signing key that is only |
| 367 |
used to sign PCR policies restricted to the initrd boot phase. This can be used to lock down root |
| 368 |
volumes in a way that they can only be unlocked before the transition to the host system. Thus we have |
| 369 |
two classes of secrets or credentials: one that can be unlocked during the entire runtime, and the |
| 370 |
other that can only be used in the initrd.</para> |
| 371 |
|
| 372 |
<programlisting>$ openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out tpm2-pcr-private-key.pem |
| 373 |
.+........+.+........+.......+...+...+........+....+......+..+.......... |
| 374 |
$ openssl rsa -pubout -in tpm2-pcr-private-key.pem -out tpm2-pcr-public-key.pem |
| 375 |
$ openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out tpm2-pcr-initrd-private-key.pem |
| 376 |
..+.......++........+........+......+........+....+.....+.+..+.......... |
| 377 |
$ openssl rsa -pubout -in tpm2-pcr-initrd-private-key.pem -out tpm2-pcr-initrd-public-key.pem |
| 378 |
$ ukify build \ |
| 379 |
--linux=vmlinux-1.2.3 \ |
| 380 |
--initrd=initrd.cpio \ |
| 381 |
[email protected] \ |
| 382 |
[email protected] \ |
| 383 |
--splash=splash.bmp \ |
| 384 |
--devicetree=devicetree.dtb \ |
| 385 |
--pcr-private-key=tpm2-pcr-private-key.pem \ |
| 386 |
--pcr-public-key=tpm2-pcr-public-key.pem \ |
| 387 |
--phases=enter-initrd,enter-initrd:leave-initrd,enter-initrd:leave-initrd:sysinit,enter-initrd:leave-initrd:sysinit:ready \ |
| 388 |
--pcr-banks=sha1,sha256 \ |
| 389 |
--pcr-private-key=tpm2-pcr-initrd-private-key.pem \ |
| 390 |
--pcr-public-key=tpm2-pcr-initrd-public-key.pem \ |
| 391 |
--phases=enter-initrd \ |
| 392 |
--uname=1.2.3 \ |
| 393 |
--output=vmlinux-1.2.3.efi |
| 394 |
+ /usr/lib/systemd/systemd-measure sign --linux=vmlinux-1.2.3 \ |
| 395 |
--osrel=os-release.txt --cmdline=cmdline.txt --dtb=devicetree.dtb \ |
| 396 |
--splash=splash.bmp --initrd=initrd.cpio --bank=sha1 --bank=sha256 \ |
| 397 |
--private-key=tpm2-pcr-private-key.pem --public-key=tpm2-pcr-public-key.pem \ |
| 398 |
--phase=enter-initrd --phase=enter-initrd:leave-initrd \ |
| 399 |
--phase=enter-initrd:leave-initrd:sysinit \ |
| 400 |
--phase=enter-initrd:leave-initrd:sysinit:ready |
| 401 |
+ /usr/lib/systemd/systemd-measure sign --linux=vmlinux-1.2.3 \ |
| 402 |
--osrel=os-release.txt --cmdline=cmdline.txt --dtb=devicetree.dtb \ |
| 403 |
--splash=splash.bmp --initrd=initrd.cpio --bank=sha1 --bank=sha256 \ |
| 404 |
--private-key=tpm2-pcr-initrd-private-key.pem \ |
| 405 |
--public-key=tpm2-pcr-initrd-public-key.pem \ |
| 406 |
--phase=enter-initrd |
| 407 |
Wrote unsigned vmlinux-1.2.3.efi |
| 408 |
</programlisting> |
| 409 |
|
| 410 |
<para><command>ukify</command> prints out both invocations of <command>systemd-measure</command> as |
| 411 |
informative output (the lines starting with <literal>+</literal>); this allows us to see how |
| 412 |
<command>systemd-measure</command> is called. It then merges the output of both invocations into the |
| 413 |
<literal>.pcrsig</literal> section. <command>systemd-measure</command> may also do this merge itself |
| 414 |
using the <option>--append=</option> option.</para> |
| 415 |
|
| 416 |
<para>Note that in this example the <literal>.pcrpkey</literal> PE section contains the key specified |
| 417 |
by the first <option>--pcr-private-key=</option> option, covering all boot phases. The |
| 418 |
<literal>.pcrpkey</literal> section is used in the default policies of |
| 419 |
<command>systemd-cryptenroll</command> and <command>systemd-creds</command>. To use the stricter policy |
| 420 |
bound to <filename>tpm2-pcr-initrd-public-key.pem</filename>, specify |
| 421 |
<option>--tpm2-public-key=</option> on the command line of those tools.</para> |
| 422 |
</example> |
| 423 |
</refsect1> |
| 424 |
|
| 425 |
<refsect1> |
| 426 |
<title>Exit status</title> |
| 427 |
|
| 428 |
<para>On success, 0 is returned, a non-zero failure code otherwise.</para> |
| 429 |
</refsect1> |
| 430 |
|
| 431 |
<refsect1> |
| 432 |
<title>See Also</title> |
| 433 |
<para><simplelist type="inline"> |
| 434 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 435 |
<member><citerefentry><refentrytitle>systemd-stub</refentrytitle><manvolnum>7</manvolnum></citerefentry></member> |
| 436 |
<member><citerefentry><refentrytitle>ukify</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 437 |
<member><citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 438 |
<member><citerefentry><refentrytitle>[email protected]</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> |
| 439 |
<member><citerefentry><refentrytitle>systemd-pcrphase.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> |
| 440 |
</simplelist></para> |
| 441 |
</refsect1> |
| 442 |
|
| 443 |
</refentry> |