diff --git a/src/cryptsetup.c b/src/cryptsetup.c index f52a41b..58b8ab8 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -446,9 +446,13 @@ int main(int argc, char *argv[]) { crypt_get_volume_key_size(cd)*8, argv[3]); - if (key_file) + if (key_file) { k = crypt_activate_by_keyfile(cd, argv[2], CRYPT_ANY_SLOT, key_file, opt_key_size, flags); - else { + + /* No success, so try it again with opt_key_size == 0 */ + if (k < 0) + k = crypt_activate_by_keyfile(cd, argv[2], CRYPT_ANY_SLOT, key_file, 0, flags); + } else { char **p; STRV_FOREACH(p, passwords) {