Subject: Enhance luksOpen to make use of key_size parameter In case you want to read your key from a block device (or large file) the normal behavior is to read the whole thing. However if your key is stored at the beginning of that file this patch allows you to specify the -s parameter with luksOpen and just read n bits from that file. Example: cryptsetup luksOpen /dev/sda1 sda1 -d /dev/sdb -s 256 Reads only the first 256 bits from /dev/sdb Not supplying -s option for luksOpen results, as before, in an exhaustive read. Signed-off-by: Stefan Assmann <sassmann@xxxxxxx> --- lib/setup.c | 2 +- src/cryptsetup.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -276,6 +276,7 @@ static int action_luksOpen(int arg) .name = action_argv[1], .device = action_argv[0], .key_file = opt_key_file, + .key_size = (opt_key_size != 0 ? opt_key_size : 0) / 8, .timeout = opt_timeout, .tries = opt_tries, .icb = &cmd_icb, --- a/lib/setup.c +++ b/lib/setup.c @@ -474,7 +474,7 @@ static int __crypt_luks_open(int arg, st start: mk=NULL; - if(get_key("Enter LUKS passphrase: ",&password,&passwordLen, 0, options->key_file, options->passphrase_fd, options->timeout, options->flags)) + if(get_key("Enter LUKS passphrase: ",&password,&passwordLen, options->key_size, options->key_file, options->passphrase_fd, options->timeout, options->flags)) tries--; else tries = 0; Stefan -- Stefan Assmann | SUSE LINUX Products GmbH Software Engineer | Maxfeldstr. 5, D-90409 Nuernberg Mail: sassmann@xxxxxxx | GF: Markus Rex, HRB 16746 (AG Nuernberg) --------------------------------------------------------------------- dm-crypt mailing list - http://www.saout.de/misc/dm-crypt/ To unsubscribe, e-mail: dm-crypt-unsubscribe@xxxxxxxx For additional commands, e-mail: dm-crypt-help@xxxxxxxx