Fix LUKS header checksum reference for reencryption - #3053
Merged
Merged
Conversation
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
self-requested a review
September 21, 2026 08:25
schaefi
approved these changes
Sep 21, 2026
schaefi
left a comment
Collaborator
There was a problem hiding this comment.
Great catch, thanks much 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ).