fix: handle encryption keys with newline in AddKey #145
Merged
talos-bot merged 1 commit intosiderolabs:v2from Feb 19, 2026
Merged
fix: handle encryption keys with newline in AddKey #145talos-bot merged 1 commit intosiderolabs:v2from
talos-bot merged 1 commit intosiderolabs:v2from
Conversation
85de8ad to
fdd8449
Compare
smira
commented
Feb 18, 2026
| "--key-file=-", | ||
| fmt.Sprintf("--keyfile-size=%d", keyfileLen), | ||
| "--new-keyfile=-", | ||
| fmt.Sprintf("--new-keyfile-size=%d", len(newKey.Value)), |
Member
Author
There was a problem hiding this comment.
this is the actual fix (passing the length explicitly stops cryptsetup from trying to look for \n)
There was a problem hiding this comment.
Pull request overview
Fixes LUKS key handling when keys contain newline (\n) characters by ensuring cryptsetup reads the full key from stdin, and updates tests to exercise newline/binary key rotation flows.
Changes:
- Update
luksAddKeyinvocation to pass both old/new keys via stdin with explicit--keyfile-size/--new-keyfile-size. - Add/expand LUKS tests to include newline-containing keys and multi-step key rotation.
- Remove
SetKeyfrom the exportedencryption.Providerinterface and drop the LUKS implementation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| encryption/provider.go | Removes SetKey from the public Provider interface. |
| encryption/luks/luks.go | Adds explicit keyfile sizing flags for AddKey, CheckKey, and RemoveKey cryptsetup calls. |
| encryption/luks/luks_test.go | Updates tests to use newline-containing keys and adds a key-rotation test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fdd8449 to
0baa86a
Compare
Without proper flags to `cryptsetup`, it stops reading the key after the first `\n` which cuts the encryption key (if it contains that character), rendering the key unusable. I dropped the `SetKey` method, as it doesn't seem to be used in Talos, and I can't make `cryptsetup` handle `\n` correctly there. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
0baa86a to
728ca1c
Compare
frezbo
approved these changes
Feb 19, 2026
Member
Author
|
/m |
smira
added a commit
to smira/talos
that referenced
this pull request
Feb 19, 2026
This pulls in a fix siderolabs/go-blockdevice#145 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
smira
added a commit
to smira/talos
that referenced
this pull request
Feb 19, 2026
This pulls in a fix siderolabs/go-blockdevice#145 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
smira
added a commit
to smira/talos
that referenced
this pull request
Feb 19, 2026
This pulls in a fix siderolabs/go-blockdevice#145 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
smira
added a commit
to smira/talos
that referenced
this pull request
Feb 19, 2026
This pulls in a fix siderolabs/go-blockdevice#145 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
smira
added a commit
to smira/talos
that referenced
this pull request
Mar 6, 2026
This pulls in a fix siderolabs/go-blockdevice#145 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com> (cherry picked from commit f018fbe)
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.
Without proper flags to
cryptsetup, it stops reading the key after the first\nwhich cuts the encryption key (if it contains that character), rendering the key unusable.I dropped the
SetKeymethod, as it doesn't seem to be used in Talos, and I can't makecryptsetuphandle\ncorrectly there.