File tree Expand file tree Collapse file tree 3 files changed +39
-8
lines changed Expand file tree Collapse file tree 3 files changed +39
-8
lines changed Original file line number Diff line number Diff line change @@ -334,10 +334,18 @@ clevis_luks_check_valid_key_or_keyfile() {
334
334
local EXISTING_TOKEN_ID=" ${5:- } "
335
335
336
336
[ -z " ${DEV} " ] && return 1
337
- [ -z " ${EXISTING_TOKEN_ID} " ] && [ -z " ${KEYFILE} " ] && [ -z " ${KEY} " ] && return 1
338
337
339
338
local extra_args
340
339
extra_args=" $( [ -n " ${SLT} " ] && printf -- ' --key-slot %s' " ${SLT} " ) "
340
+
341
+ # We have an empty key here.
342
+ if [ -z " ${EXISTING_TOKEN_ID} " ] && [ -z " ${KEYFILE} " ] \
343
+ && [ -z " ${KEY} " ]; then
344
+ echo | cryptsetup open --force-password --test-passphrase " ${DEV} " \
345
+ ${extra_args}
346
+ return
347
+ fi
348
+
341
349
if [ -n " ${KEYFILE} " ]; then
342
350
cryptsetup open --test-passphrase " ${DEV} " --key-file " ${KEYFILE} " \
343
351
${extra_args}
@@ -798,7 +806,6 @@ clevis_luks_add_key() {
798
806
799
807
[ -z " ${DEV} " ] && return 1
800
808
[ -z " ${NEWKEY} " ] && return 1
801
- [ -z " ${EXISTING_TOKEN_ID} " ] && [ -z " ${KEY} " ] && [ -z " ${KEYFILE} " ] && return 1
802
809
803
810
local extra_args=' ' input
804
811
input=" $( printf ' %s\n%s' " ${KEY} " " ${NEWKEY} " ) "
Original file line number Diff line number Diff line change @@ -40,18 +40,30 @@ UUID="cb6e8904-81ff-40da-a84a-07ab9ab5715e"
40
40
new_device " luks1" " ${DEV} "
41
41
42
42
if ! clevis luks bind -f -d " ${DEV} " tang " ${CFG} " <<< " ${DEFAULT_PASS}" ; then
43
- error " ${TEST} : Binding is expected to succeed when given a correct (${DEFAULT_PASS} ) password." >&2
43
+ error " ${TEST} : Binding is expected to succeed when given a correct (${DEFAULT_PASS} ) password."
44
44
fi
45
45
46
46
SLT=1
47
47
if ! read -r _ state uuid < <( luksmeta show -d " ${DEV} " | grep " ^${SLT} *" ) ; then
48
- error " ${TEST} : Error reading LUKSmeta info for slot ${SLT} of ${DEV} ." >&2
48
+ error " ${TEST} : Error reading LUKSmeta info for slot ${SLT} of ${DEV} ."
49
49
fi
50
50
51
51
if [ " ${state} " != " active" ]; then
52
- error " ${TEST} : state (${state} ) is expected to be 'active'." >&2
52
+ error " ${TEST} : state (${state} ) is expected to be 'active'."
53
53
fi
54
54
55
55
if [ " ${uuid} " != " ${UUID} " ]; then
56
- error " ${TEST} : UUID ($uuid ) is expected to be '${UUID} '." >&2
56
+ error " ${TEST} : UUID ($uuid ) is expected to be '${UUID} '."
57
+ fi
58
+
59
+ # Empty password (issue #494)
60
+ DEV=" ${TMP} /luks1-device-empty-pw"
61
+ new_device " luks1" " ${DEV} "
62
+
63
+ # Let's create an empty password.
64
+ printf ' %s\n\n' " ${DEFAULT_PASS} " | cryptsetup luksChangeKey \
65
+ --force-password --batch-mode " ${DEV} "
66
+
67
+ if ! clevis luks bind -f -d " ${DEV} " tang " ${CFG} " <<< " " ; then
68
+ error " ${TEST} : Binding is expected to succeed when the password is empty."
57
69
fi
Original file line number Diff line number Diff line change @@ -45,9 +45,21 @@ TOKEN_ID=5
45
45
new_device " luks2" " ${DEV} "
46
46
47
47
if ! clevis luks bind -d " ${DEV} " -t " $TOKEN_ID " tang " ${CFG} " <<< " ${DEFAULT_PASS}" ; then
48
- error " ${TEST} : Binding is expected to succeed when given a correct (${DEFAULT_PASS} ) password." >&2
48
+ error " ${TEST} : Binding is expected to succeed when given a correct (${DEFAULT_PASS} ) password."
49
49
fi
50
50
51
51
if ! cryptsetup token export --token-id=5 " ${DEV} " ; then
52
- error " ${TEST} : Clevis did not add the LUKS2 token to the correct slot." >&2
52
+ error " ${TEST} : Clevis did not add the LUKS2 token to the correct slot."
53
+ fi
54
+
55
+ # Empty password (issue #494)
56
+ DEV=" ${TMP} /luks2-device-empty-pw"
57
+ new_device " luks2" " ${DEV} "
58
+
59
+ # Let's create an empty password.
60
+ printf ' %s\n\n' " ${DEFAULT_PASS} " | cryptsetup luksChangeKey \
61
+ --force-password --batch-mode " ${DEV} "
62
+
63
+ if ! clevis luks bind -d " ${DEV} " tang " ${CFG} " <<< " " ; then
64
+ error " ${TEST} : Binding is expected to succeed when the password is empty."
53
65
fi
You can’t perform that action at this time.
0 commit comments