[systemd-devel] [PATCH 2/3] Fix keysize handling in cryptsetup (bits vs. bytes)
David Härdeman
david at hardeman.nu
Wed Feb 12 14:55:16 PST 2014
The command line key-size is in bits but the libcryptsetup API expects bytes.
---
src/cryptsetup/cryptsetup.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index f72cf9f..e7e8066 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -414,7 +414,7 @@ static int attach_luks_or_plain(struct crypt_device *cd,
/* for CRYPT_PLAIN limit reads
* from keyfile to key length, and
* ignore keyfile-size */
- opt_keyfile_size = opt_key_size / 8;
+ opt_keyfile_size = opt_key_size;
/* In contrast to what the name
* crypt_setup() might suggest this
@@ -577,7 +577,11 @@ int main(int argc, char *argv[]) {
else
until = 0;
- opt_key_size = (opt_key_size > 0 ? opt_key_size : 256);
+ if (opt_key_size % 8) {
+ log_warning("Key size invalid (not a multiple of 8).");
+ goto finish;
+ }
+ opt_key_size = (opt_key_size > 0 ? opt_key_size : 256) / 8;
if (key_file) {
struct stat st;
More information about the systemd-devel
mailing list