SecureBootSignTool,
ShimBootloader,
Verb,
+ Verity,
Vmm,
cat_config,
format_bytes,
"Secure boot certificate source and expected PCR signatures certificate source have to be the same" # noqa: E501
) # fmt: skip
- if config.verity == ConfigFeature.enabled and not config.verity_key:
+ if config.verity == Verity.signed and not config.verity_key:
die(
"Verity= is enabled but no verity key is configured",
hint="Run mkosi genkey to generate a key/certificate pair",
)
- if config.verity == ConfigFeature.enabled and not config.verity_certificate:
+ if config.verity == Verity.signed and not config.verity_certificate:
die(
"Verity= is enabled but no verity certificate is configured",
hint="Run mkosi genkey to generate a key/certificate pair",
partitions = [Partition.from_dict(d) for d in output]
arch = context.config.architecture
- if context.config.verity == ConfigFeature.enabled and not any(
+ if context.config.verity == Verity.signed and not any(
p.type.startswith(f"usr-{arch}-verity-sig") or p.type.startswith(f"root-{arch}-verity-sig")
for p in partitions
):
def want_verity(config: Config) -> bool:
- return config.verity == ConfigFeature.enabled or bool(
- config.verity == ConfigFeature.auto and config.verity_key and config.verity_certificate
+ return config.verity == Verity.signed or bool(
+ config.verity == Verity.auto and config.verity_key and config.verity_certificate
)
def make_extension_or_portable_image(context: Context, output: Path) -> None:
- unsigned = "-unsigned" if not want_verity(context.config) else ""
+ if want_verity(context.config) or context.config.verity == Verity.signed:
+ unsigned = ""
+ else:
+ unsigned = "-unsigned"
+
r = context.resources / f"repart/definitions/{context.config.output_format}{unsigned}.repart.d"
cmdline: list[PathString] = [
if ArtifactOutput.partitions in context.config.split_artifacts:
cmdline += ["--split=yes"]
+ verity = [
+ f"root-{context.config.architecture}-verity-sig",
+ f"usr-{context.config.architecture}-verity-sig",
+ ]
+ if context.config.verity == Verity.hash:
+ cmdline += [f"--exclude-partitions={','.join(verity)}"]
+
with complete_step(f"Building {context.config.output_format} extension image"):
j = json.loads(
run_systemd_sign_tool(
if not keyutil:
return
- if config.verity != ConfigFeature.disabled and config.verity_certificate and config.verity_key:
+ if config.verity != Verity.disabled and config.verity_certificate and config.verity_key:
run_systemd_sign_tool(
config,
cmdline=[keyutil, "validate"],
return self != BuildSourcesEphemeral.no
+class Verity(StrEnum):
+ disabled = enum.auto()
+ hash = enum.auto()
+ signed = enum.auto()
+ auto = enum.auto()
+
+
class Architecture(StrEnum):
alpha = enum.auto()
arc = enum.auto()
secure_boot_certificate: Optional[Path]
secure_boot_certificate_source: CertificateSource
secure_boot_sign_tool: SecureBootSignTool
- verity: ConfigFeature
+ verity: Verity
verity_key: Optional[Path]
verity_key_source: KeySource
verity_certificate: Optional[Path]
dest="verity",
section="Validation",
metavar="FEATURE",
- parse=config_parse_feature,
+ parse=config_make_enum_parser_with_boolean(Verity, yes=Verity.signed, no=Verity.disabled),
+ default=Verity.auto,
+ choices=Verity.values(),
help="Configure whether to enforce or disable verity partitions for disk images",
),
ConfigSetting(
list[ArtifactOutput]: enum_list_transformer,
CertificateSource: certificate_source_transformer,
ConsoleMode: enum_transformer,
+ Verity: enum_transformer,
}
def json_transformer(key: str, val: Any) -> Any:
available, with **systemd-sbsign** being preferred.
`Verity=`, `--verity=`
-: Whether to enforce or disable signed verity for extension images.
- Takes a boolean value or `auto`. If enabled, a verity key and
- certificate must be present and the build will fail if we don't
- detect any verity partitions in the disk image produced by
- **systemd-repart**. If disabled, verity partitions will be excluded from
- the extension images produced by **systemd-repart**. If set to `auto` and
- a verity key and certificate are present, **mkosi** will pass them to **systemd-repart**
- and expects the generated disk image to contain verity partitions,
- but the build won't fail if no verity partitions are found in the
- disk image produced by **systemd-repart**.
-
- Note that explicitly disabling signed verity is not yet implemented
- for the `disk` output and only works for extension images at the
+: Whether to enforce or disable verity for extension images. Takes one of
+ `signed`, `hash`, `auto` or a boolean value. If set to `signed`,
+ a verity key and certificate must be present and the build will fail if
+ we don't detect any verity partitions in the disk image produced by
+ **systemd-repart**. If disabled, verity partitions will be excluded
+ from the extension images produced by **systemd-repart**. If set to
+ `hash`, **mkosi** configures **systemd-repart** to create a verity hash
+ partition, but no signature partition. If set to `auto` and a verity key
+ and certificate are present, **mkosi** will pass them to **systemd-repart** and
+ expects the generated disk image to contain verity partitions, but the build
+ won't fail if no verity partitions are found in the disk image produced by
+ **systemd-repart**.
+
+ Note that explicitly disabling verity signature and/or hash is not yet
+ implemented for the `disk` output and only works for extension images at the
moment.
`VerityKey=`, `--verity-key=`
# mkosi Changelog
+## v26
+
+- Teach `--verity` a new `hash` value, which skips the verity signature
+ partition for extension / portable images. To align the possible values,
+ `yes` is renamed to `signed`.
+
## v25
- Instead of using bubblewrap, sandboxing is now done with a new tool
ShimBootloader,
UKIProfile,
Verb,
+ Verity,
Vmm,
VsockCID,
)
"UseSubvolumes": "auto",
"VSock": "enabled",
"VSockCID": -2,
- "Verity": "enabled",
+ "Verity": "signed",
"VerityCertificate": "/path/to/cert",
"VerityCertificateSource": {
"Source": "",
verity_certificate=Path("/path/to/cert"),
verity_key_source=KeySource(type=KeySourceType.file),
verity_key=None,
- verity=ConfigFeature.enabled,
+ verity=Verity.signed,
vmm=Vmm.qemu,
volatile_package_directories=[Path("def")],
volatile_packages=["abc"],