Skip to content

Fix LUKS header checksum reference for reencryption - #3053

Merged
schaefi merged 1 commit into
OSInside:mainfrom
fcrozat:fix-luks-header-checksum
Sep 21, 2026
Merged

schaefi merged 1 commit into
OSInside:mainfrom
fcrozat:fix-luks-header-checksum

Conversation

@fcrozat

@fcrozat fcrozat commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

There was a regression when implementing sha512 support: header checksum is computed too late and end-up being null.

This is breaking SL Micro 6.2 Encrypted image when booting with FIPS. It is only visible in FIPS environment due to other bugs in fde-tools causing re-encryption to fail if kiwi re-encryption fails in the first place ( openSUSE/fde-tools#54 and openSUSE/fde-tools#57 ).

The origin LUKS header checksum stored in /root/.luks.header is
used by the kiwi dracut code to decide if the initial reencryption
of the root device should happen. The checksum is calculated over
the header backup file which is at the same time the file the
resulting checksum gets written to.

Since the checksum handler returned by get_checksum_handler()
calculates the digest lazily when digest() is called, and the
call happened inside the open(..., 'w') context, the header backup
was already truncated at that point. The stored reference was
therefore always the digest of an empty file
(e3b0c442... for sha256) and could never match the digest
calculated at boot time. As a consequence reencrypt_luks()
silently skipped the reencryption and the image stayed encrypted
with the build time credentials.

Calculate the digest before the file is opened for writing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@schaefi
schaefi self-requested a review September 21, 2026 08:25

@schaefi schaefi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, thanks much 👍

@schaefi
schaefi merged commit 503da37 into OSInside:main Sep 21, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants