mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-13 11:50:10 +01:00
Should fix Issue 5.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@49 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
20
lib/setup.c
20
lib/setup.c
@@ -256,13 +256,13 @@ static int parse_into_name_and_mode(const char *nameAndMode, char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Select free keyslot or verifies that the one specified is empty */
|
/* Select free keyslot or verifies that the one specified is empty */
|
||||||
static int keyslot_from_option(int keySlotOption, struct luks_phdr *hdr) {
|
static int keyslot_from_option(int keySlotOption, struct luks_phdr *hdr, struct crypt_options *options) {
|
||||||
if(keySlotOption != -1) {
|
if(keySlotOption >= 0) {
|
||||||
if(keySlotOption >= LUKS_NUMKEYS) {
|
if(keySlotOption >= LUKS_NUMKEYS) {
|
||||||
set_error("slot %d too high, please pick between 0 and %d", keySlotOption, LUKS_NUMKEYS);
|
logger(options,CRYPT_LOG_ERROR,"slot %d too high, please pick between 0 and %d", keySlotOption, LUKS_NUMKEYS);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
} else if(hdr->keyblock[keySlotOption].active != LUKS_KEY_DISABLED) {
|
} else if(hdr->keyblock[keySlotOption].active != LUKS_KEY_DISABLED) {
|
||||||
set_error("slot %d full, please pick another one", keySlotOption);
|
logger(options,CRYPT_LOG_ERROR,"slot %d full, please pick another one", keySlotOption);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
} else {
|
} else {
|
||||||
return keySlotOption;
|
return keySlotOption;
|
||||||
@@ -274,7 +274,7 @@ static int keyslot_from_option(int keySlotOption, struct luks_phdr *hdr) {
|
|||||||
if(hdr->keyblock[i].active == LUKS_KEY_DISABLED) break;
|
if(hdr->keyblock[i].active == LUKS_KEY_DISABLED) break;
|
||||||
}
|
}
|
||||||
if(i==LUKS_NUMKEYS) {
|
if(i==LUKS_NUMKEYS) {
|
||||||
set_error("All slots full");
|
logger(options,CRYPT_LOG_ERROR,"All slots full");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
@@ -475,7 +475,10 @@ static int __crypt_luks_format(int arg, struct setup_backend *backend, struct cr
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyIndex = keyslot_from_option(options->key_slot, &header);
|
keyIndex = keyslot_from_option(options->key_slot, &header, options);
|
||||||
|
if(keyIndex == -EINVAL) {
|
||||||
|
r = -EINVAL; goto out;
|
||||||
|
}
|
||||||
|
|
||||||
PBKDF2perSecond = LUKS_benchmarkt_iterations();
|
PBKDF2perSecond = LUKS_benchmarkt_iterations();
|
||||||
header.keyblock[keyIndex].passwordIterations = at_least_one(PBKDF2perSecond * ((float)options->iteration_time / 1000.0));
|
header.keyblock[keyIndex].passwordIterations = at_least_one(PBKDF2perSecond * ((float)options->iteration_time / 1000.0));
|
||||||
@@ -608,7 +611,10 @@ static int __crypt_luks_add_key(int arg, struct setup_backend *backend, struct c
|
|||||||
if(r < 0) return r;
|
if(r < 0) return r;
|
||||||
|
|
||||||
|
|
||||||
keyIndex = keyslot_from_option(options->key_slot, &hdr);
|
keyIndex = keyslot_from_option(options->key_slot, &hdr, options);
|
||||||
|
if(keyIndex == -EINVAL) {
|
||||||
|
r = -EINVAL; goto out;
|
||||||
|
}
|
||||||
|
|
||||||
get_key("Enter any LUKS passphrase: ",
|
get_key("Enter any LUKS passphrase: ",
|
||||||
&password,
|
&password,
|
||||||
|
|||||||
Reference in New Issue
Block a user