[PATCH v2 10/10] luks2: Rename source disk variabled named 'disk' to 'source' as in luks.c.

2020-10-03 Thread Glenn Washburn
This makes it more obvious to the reader that the disk referred to is the source disk, as opposed to say the disk holding the cryptodisk. Signed-off-by: Glenn Washburn --- grub-core/disk/luks2.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git

[PATCH v2 07/10] cryptodisk: Replace some literals with constants in grub_cryptodisk_endecrypt.

2020-10-03 Thread Glenn Washburn
This should improve readability of code by providing clues as to what the value represents. Signed-off-by: Glenn Washburn --- grub-core/disk/cryptodisk.c | 12 +++- include/grub/types.h| 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git

[PATCH v2 00/10] Cryptodisk fixes for v2.06 redux

2020-10-03 Thread Glenn Washburn
This is a minor update to fix patch 3, where I missed updating the format string type code. This was causing i386 builds to fail. Rangediff is included. Glenn Washburn (10): luks2: Fix use of incorrect index and some grub_error() messages. luks2: Improve readability in luks2_get_keyslot.

[PATCH v2 09/10] cryptodisk: Rename offset in grub_cryptodisk_t to offset_sectors.

2020-10-03 Thread Glenn Washburn
This makes it clear that the offset represents sectors, not bytes, in order to improve readability. Signed-off-by: Glenn Washburn --- grub-core/disk/cryptodisk.c | 10 +- grub-core/disk/geli.c | 2 +- grub-core/disk/luks.c | 4 ++-- grub-core/disk/luks2.c | 4 ++--

[PATCH v2 06/10] cryptodisk: Properly handle non-512 byte sized sectors.

2020-10-03 Thread Glenn Washburn
By default, dm-crypt internally uses an IV that corresponds to 512-byte sectors, even when a larger sector size is specified. What this means is that when using a larger sector size, the IV is incremented every sector. However, the amount the IV is incremented is the number of 512 byte blocks in a

[PATCH v2 02/10] luks2: Improve readability in luks2_get_keyslot.

2020-10-03 Thread Glenn Washburn
Introduce new variables keyslot_key, digest_key, and segment_key which represent the integer key of the item in the respective associative array when looping over the array items. This replaces using a generically named variable named "idx" used for all three values. The parameter "i" is renamed

[PATCH v2 08/10] cryptodisk: Rename total_length field in grub_cryptodisk_t to total_sectors.

2020-10-03 Thread Glenn Washburn
This makes the creates an alignment with grub_disk_t naming of the same field and is more intuitive as to how it should be used. Signed-off-by: Glenn Washburn --- grub-core/disk/cryptodisk.c | 2 +- grub-core/disk/geli.c | 2 +- grub-core/disk/luks.c | 2 +- grub-core/disk/luks2.c

[PATCH v2 03/10] luks2: Use more intuitive keyslot key instead of index when naming keyslot.

2020-10-03 Thread Glenn Washburn
Use the keyslot key value in the keyslot json array rather than the index of the keyslot in the json array. This is less confusing for the end user. For example, say you have a LUKS2 device with a key in slot 1 and slot 4. When using the password for slot 4 to unlock the device, the messages using

[PATCH v2 01/10] luks2: Fix use of incorrect index and some grub_error() messages.

2020-10-03 Thread Glenn Washburn
When looping over the digests and segments, the loop variable is j, but the variable i is used to index in the the digests and segments json array. The variable i is the keyslot index. Similarly, there are several grub_error() statements using the wrong index in constructing the error string.

[PATCH v2 05/10] cryptodisk: Fix cipher IV mode 'plain64' always being set as 'plain'.

2020-10-03 Thread Glenn Washburn
When setting cipher IV mode, detection is done by prefix matching the cipher IV mode part of the cipher mode string. Since "plain" matches "plain64", we must check for "plain64" first. Otherwise, "plain64" will be detected as "plain". Signed-off-by: Glenn Washburn Reviewed-by: Patrick

[PATCH v2 04/10] luks2: grub_cryptodisk_t->total_length is the max number of device native sectors

2020-10-03 Thread Glenn Washburn
The total_length field is named confusingly because length usually refers to bytes, whereas in this case its really the total number of sectors on the device. Also counter-intuitively, grub_disk_get_size returns the total number of device native sectors sectors. We need to convert the sectors from

Re: [PATCH] error: Do compile-time format string checking on grub_error.

2020-10-03 Thread Glenn Washburn
On Thu, 17 Sep 2020 16:29:23 +0200 Daniel Kiper wrote: > On Fri, Jul 31, 2020 at 09:33:18AM -0500, Glenn Washburn wrote: > > Fix the many issues this uncovered mostly related to incorrect > > length modifiers. > > Did you test the 32-bit and 64-bit builds with this patch? > > Daniel I have

[PATCH 09/10] cryptodisk: Rename offset in grub_cryptodisk_t to offset_sectors.

2020-10-03 Thread Glenn Washburn
This makes it clear that the offset represents sectors, not bytes, in order to improve readability. Signed-off-by: Glenn Washburn --- grub-core/disk/cryptodisk.c | 10 +- grub-core/disk/geli.c | 2 +- grub-core/disk/luks.c | 4 ++-- grub-core/disk/luks2.c | 4 ++--

[PATCH 07/10] cryptodisk: Replace some literals with constants in grub_cryptodisk_endecrypt.

2020-10-03 Thread Glenn Washburn
This should improve readability of code by providing clues as to what the value represents. Signed-off-by: Glenn Washburn --- grub-core/disk/cryptodisk.c | 12 +++- include/grub/types.h| 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git

[PATCH 10/10] luks2: Rename source disk variabled named 'disk' to 'source' as in luks.c.

2020-10-03 Thread Glenn Washburn
This makes it more obvious to the reader that the disk referred to is the source disk, as opposed to say the disk holding the cryptodisk. Signed-off-by: Glenn Washburn --- grub-core/disk/luks2.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git

[PATCH 08/10] cryptodisk: Rename total_length field in grub_cryptodisk_t to total_sectors.

2020-10-03 Thread Glenn Washburn
This makes the creates an alignment with grub_disk_t naming of the same field and is more intuitive as to how it should be used. Signed-off-by: Glenn Washburn --- grub-core/disk/cryptodisk.c | 2 +- grub-core/disk/geli.c | 2 +- grub-core/disk/luks.c | 2 +- grub-core/disk/luks2.c

[PATCH 05/10] cryptodisk: Fix cipher IV mode 'plain64' always being set as 'plain'.

2020-10-03 Thread Glenn Washburn
When setting cipher IV mode, detection is done by prefix matching the cipher IV mode part of the cipher mode string. Since "plain" matches "plain64", we must check for "plain64" first. Otherwise, "plain64" will be detected as "plain". Signed-off-by: Glenn Washburn Reviewed-by: Patrick

[PATCH 03/10] luks2: Use more intuitive keyslot key instead of index when naming keyslot.

2020-10-03 Thread Glenn Washburn
Use the keyslot key value in the keyslot json array rather than the index of the keyslot in the json array. This is less confusing for the end user. For example, say you have a LUKS2 device with a key in slot 1 and slot 4. When using the password for slot 4 to unlock the device, the messages using

[PATCH 06/10] cryptodisk: Properly handle non-512 byte sized sectors.

2020-10-03 Thread Glenn Washburn
By default, dm-crypt internally uses an IV that corresponds to 512-byte sectors, even when a larger sector size is specified. What this means is that when using a larger sector size, the IV is incremented every sector. However, the amount the IV is incremented is the number of 512 byte blocks in a

[PATCH 04/10] luks2: grub_cryptodisk_t->total_length is the max number of device native sectors

2020-10-03 Thread Glenn Washburn
The total_length field is named confusingly because length usually refers to bytes, whereas in this case its really the total number of sectors on the device. Also counter-intuitively, grub_disk_get_size returns the total number of device native sectors sectors. We need to convert the sectors from

[PATCH 02/10] luks2: Improve readability in luks2_get_keyslot.

2020-10-03 Thread Glenn Washburn
Introduce new variables keyslot_key, digest_key, and segment_key which represent the integer key of the item in the respective associative array when looping over the array items. This replaces using a generically named variable named "idx" used for all three values. The parameter "i" is renamed

[PATCH 01/10] luks2: Fix use of incorrect index and some grub_error() messages.

2020-10-03 Thread Glenn Washburn
When looping over the digests and segments, the loop variable is j, but the variable i is used to index in the the digests and segments json array. The variable i is the keyslot index. Similarly, there are several grub_error() statements using the wrong index in constructing the error string.

[PATCH 00/10] Cryptodisk fixes for v2.06 redux

2020-10-03 Thread Glenn Washburn
This series is meant to address concerns Daniel had for patches 3, 4, 8, and 9 of Daniel's series with subject "[PATCH 0/9] Cryptodisk fixes for v2.06". These were patches authored by me and which Daniel handed back for me to take the lead in getting accepted. This series warrants a new thread