Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fully read "key-file" in "plain" mode
This change should read the complete "key-file", not only up to the first newline character ("\n"). 1. Needs testing: * I faintly remember, that I could not get `-d -` and (equivalent) `--key-file -` working in conjunction with `--type plain`. But that was with a way older Cryptsetup version. Note that for `--type plain`, reading from standard input with `-d -` / `--key-file -` is the only way to apply a hash algorithm to the input (entropy), see [this section of the Cryptsetup man page](https://man7.org/linux/man-pages/man8/cryptsetup.8.html#NOTES_ON_PASSPHRASE_PROCESSING_FOR_PLAIN_MODE) for details. =\> Retry above syntax with Cryptsetup of SFOS 3.2.1 (the currently minimal supported release), and also with the awkward, likely incorrect syntax `--key-file=-` mentioned once (in the whole man page!) in the aforementioned section. * I also believe to remember, that the more elegant input redirection per "`< <key-file>`" (instead of `cat <key-file> |`) did not work: Retry that, too. 2. Users have to convert their old keys for "plain" mode, i.e. cut the content of their key-files for "plain" mode at the first newline character. These commands (untested, yet) should perform this conversion: `devel-su` `for i in /etc/crypto-sdcard/crypto_plain_*.key; do mv "$i" "${i}.old" && sed -n 1P "${i}.old" > "$i"; done`
- Loading branch information
ba3ccce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit text (in Markdown) extended and properly rendered:
This change should read the whole "key"-file, not only up to the first newline character ("\n").
Needs testing
-d -
and (equivalent)--key-file -
working in combination with--type plain
. But that was with a way older Cryptsetup version.Note that for
--type plain
, reading from standard input with-d -
/--key-file -
is the only way to apply a hash algorithm (but only a single round in contrast to LUKS mode) to the input (entropy) without ceasing to read at the first newline character, according to the documentation (see this section of the Cryptsetup man page for details).=> Retry above syntax with Cryptsetup of SFOS 3.2.1 (the minimal supported release, currently), and also with the awkward, likely incorrect syntax
--key-file=-
mentioned once (in the whole man page!) in the aforementioned man page section.Edit (2021-06-02): Works well under SailfishOS 4.0.1 with
-d -
; still have to look up what systemd & Cryptsetup versions that translates to, and if that also works under SFOS 3.2.1.< <key-file>
" (instead of "cat <key-file> |
") did not work: Retry that, too.Edit 2 (2021-06-02): Still open / to do for SailfishOS < 4, where
StandardInput=file:/etc/crypto-sdcard/%I.key
does not seem to work.Edit 1: Ah, that might work better per
StandardInput=file:/etc/crypto-sdcard/%I.key
and no explicit input redirection at all (plus also eliminating the enclosing sub-shell call). Side note: This may be used in conjunction withStandardOutput=journal
, but that should be the default (butinherit
would be dangerous).Implemented in the subsequent commit #c3a0e8c.
Conversion of old "keys" for "plain" mode
Users have to convert their old "key"-files for "plain" mode, i.e. cut the content of these files at the first newline character, in order to be still able to unlock extant "plain" "containers".
These commands (untested, yet) should perform this conversion (and save the old "key"-files for "plain" mode):
Optimised creation of "plain" "containers"
New "plain" DMcrypt "containers" shall be created (since crypto-sdcard 1.3.4) as described below (i.e., with the "
-d -
/--key-file -
/--key-file=-
" option, in order to take advantage of this enhancement), in contrast to the original description in section 4.3.3.b of the "[How-to] Creating partitions on SD-card, optionally encrypted" at TJC (Backup@GitLab):cat /etc/crypto-sdcard/crypto_plain_mmcblk1pX.key | cryptsetup -d - -v -h sha1 -s 256 -c aes-xts-plain --allow-discards --type plain open /dev/mmcblk1pX mmcblk1pX-crypt
# Mind to pick the right partition number three times etc.If you missed that and applied the original statement from the How-To section 4.3.3.b (i.e., without "
-d -
"), just convert the "key"-file used (as described at "Conversion of old "keys" for "plain" mode", above), and it should work fine.