1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
|
#!/usr/bin/env bats
luksy=${LUKSY:-${BATS_TEST_DIRNAME}/../luksy}
function multiple_passwords() {
dd if=/dev/urandom bs=1M count=64 of=${BATS_TEST_TMPDIR}/plaintext status=none
local passwords
echo -n short > ${BATS_TEST_TMPDIR}/short
echo -n morethaneight > ${BATS_TEST_TMPDIR}/morethaneight
echo -n morethansixteenchars > ${BATS_TEST_TMPDIR}/morethansixteenchars
${luksy} encrypt --password-file ${BATS_TEST_TMPDIR}/short --password-file ${BATS_TEST_TMPDIR}/morethaneight --password-file ${BATS_TEST_TMPDIR}/morethansixteenchars "$@" ${BATS_TEST_TMPDIR}/plaintext ${BATS_TEST_TMPDIR}/encrypted
for password in short morethaneight morethansixteenchars ; do
echo testing password: "${password}"
echo -n "${password}" | cryptsetup -q --test-passphrase --key-file - luksOpen ${BATS_TEST_TMPDIR}/encrypted
echo password: "${password}" ok
done
rm -f ${BATS_TEST_TMPDIR}/encrypted
rm -f ${BATS_TEST_TMPDIR}/plaintext
}
@test multiple-passwords-defaults-luks1 {
multiple_passwords --luks1
}
@test multiple-passwords-defaults-luks2 {
multiple_passwords
}
function passwords() {
dd if=/dev/urandom bs=1M count=64 of=${BATS_TEST_TMPDIR}/plaintext status=none
for password in short morethaneight morethansixteenchars ; do
echo testing password: "${password}"
echo -n "${password}" | ${luksy} encrypt --password-fd 0 "$@" ${BATS_TEST_TMPDIR}/plaintext ${BATS_TEST_TMPDIR}/encrypted
echo -n "${password}" | cryptsetup -q --test-passphrase --key-file - luksOpen ${BATS_TEST_TMPDIR}/encrypted
echo password: "${password}" ok
rm -f ${BATS_TEST_TMPDIR}/encrypted
done
rm -f ${BATS_TEST_TMPDIR}/plaintext
}
@test passwords-defaults-luks1 {
passwords --luks1
}
@test passwords-defaults-luks2 {
passwords
}
@test passwords-defaults-luks2-512 {
passwords --sector-size 512
}
@test passwords-aes-xts-plain32-luks1 {
passwords --cipher aes-xts-plain --luks1
}
@test passwords-aes-xts-plain32-luks2 {
passwords --cipher aes-xts-plain
}
@test passwords-aes-xts-plain32-luks2-512 {
passwords --cipher aes-xts-plain --sector-size 512
}
@test passwords-aes-xts-plain64-luks1 {
passwords --cipher aes-xts-plain64 --luks1
}
@test passwords-aes-xts-plain64-luks2 {
passwords --cipher aes-xts-plain64
}
@test passwords-aes-xts-plain64-luks2-512 {
passwords --cipher aes-xts-plain64 --sector-size 512
}
@test passwords-serpent-xts-plain64-luks1 {
passwords --cipher serpent-xts-plain64 --luks1
}
@test passwords-serpent-xts-plain64-luks2 {
passwords --cipher serpent-xts-plain64
}
@test passwords-serpent-xts-plain64-luks2-512 {
passwords --cipher serpent-xts-plain64 --sector-size 512
}
@test passwords-twofish-xts-plain64-luks1 {
passwords --cipher twofish-xts-plain64 --luks1
}
@test passwords-twofish-xts-plain64-luks2 {
passwords --cipher twofish-xts-plain64
}
@test passwords-twofish-xts-plain64-luks2-512 {
passwords --cipher twofish-xts-plain64 --sector-size 512
}
@test passwords-aes-cbc-plain32-luks1 {
passwords --cipher aes-cbc-plain --luks1
}
@test passwords-aes-cbc-plain32-luks2 {
passwords --cipher aes-cbc-plain
}
@test passwords-aes-cbc-plain32-luks2-512 {
passwords --cipher aes-cbc-plain --sector-size 512
}
@test passwords-aes-cbc-plain64-luks1 {
passwords --cipher aes-cbc-plain64 --luks1
}
@test passwords-aes-cbc-plain64-luks2 {
passwords --cipher aes-cbc-plain64
}
@test passwords-aes-cbc-plain64-luks2-512 {
passwords --cipher aes-cbc-plain64 --sector-size 512
}
@test passwords-aes-cbc-essiv:sha256-luks1 {
passwords --cipher aes-cbc-essiv:sha256 --luks1
}
@test passwords-aes-cbc-essiv:sha256-luks2 {
passwords --cipher aes-cbc-essiv:sha256
}
@test passwords-aes-cbc-essiv:sha256-luks2-512 {
passwords --cipher aes-cbc-essiv:sha256 --sector-size 512
}
function multiple_passwords_cryptsetup() {
dd if=/dev/urandom bs=1M count=64 of=${BATS_TEST_TMPDIR}/plaintext status=none
local passwords
fallocate -l 1G ${BATS_TEST_TMPDIR}/encrypted
echo -n short | cryptsetup luksFormat -q "$@" ${BATS_TEST_TMPDIR}/encrypted -
echo -n morethaneight > ${BATS_TEST_TMPDIR}/new-key
echo -n short | cryptsetup luksAddKey ${BATS_TEST_TMPDIR}/encrypted ${BATS_TEST_TMPDIR}/new-key
echo -n morethansixteenchars > ${BATS_TEST_TMPDIR}/new-key
echo -n short | cryptsetup luksAddKey ${BATS_TEST_TMPDIR}/encrypted ${BATS_TEST_TMPDIR}/new-key
for password in short morethaneight morethansixteenchars; do
echo testing password: "${password}"
echo -n "${password}" | ${luksy} decrypt --password-fd 0 ${BATS_TEST_TMPDIR}/encrypted
echo password: "${password}" ok
done
rm -f ${BATS_TEST_TMPDIR}/encrypted
rm -f ${BATS_TEST_TMPDIR}/plaintext
}
@test multiple-passwords-cryptsetup-defaults-luks1 {
multiple_passwords_cryptsetup --type luks1
}
@test multiple-passwords-cryptsetup-defaults-luks2 {
multiple_passwords_cryptsetup --type luks2
}
function passwords_cryptsetup() {
dd if=/dev/urandom bs=1M count=64 of=${BATS_TEST_TMPDIR}/plaintext status=none
for password in short morethaneight morethansixteenchars ; do
echo testing password: "${password}"
fallocate -l 1G ${BATS_TEST_TMPDIR}/encrypted
echo -n "${password}" | cryptsetup luksFormat -q "$@" ${BATS_TEST_TMPDIR}/encrypted -
echo -n "${password}" | ${luksy} decrypt --password-fd 0 ${BATS_TEST_TMPDIR}/encrypted
rm -f ${BATS_TEST_TMPDIR}/encrypted
echo password: "${password}" ok
done
rm -f ${BATS_TEST_TMPDIR}/plaintext
}
@test passwords-cryptsetup-defaults-luks1 {
passwords_cryptsetup --type luks1
}
@test passwords-cryptsetup-defaults-luks2 {
passwords_cryptsetup --type luks2
}
@test passwords-cryptsetup-aes-xts-plain32-luks1 {
passwords_cryptsetup --cipher aes-xts-plain --type luks1
}
@test passwords-cryptsetup-aes-xts-plain32-luks2 {
passwords_cryptsetup --cipher aes-xts-plain --type luks2
}
@test passwords-cryptsetup-aes-xts-plain64-luks1 {
passwords_cryptsetup --cipher aes-xts-plain64 --type luks1
}
@test passwords-cryptsetup-aes-xts-plain64-luks2 {
passwords_cryptsetup --cipher aes-xts-plain64 --type luks2
}
@test passwords-cryptsetup-serpent-xts-plain64-luks1 {
passwords_cryptsetup --cipher serpent-xts-plain64 --type luks1
}
@test passwords-cryptsetup-serpent-xts-plain64-luks2 {
passwords_cryptsetup --cipher serpent-xts-plain64 --type luks2
}
@test passwords-cryptsetup-twofish-xts-plain64-luks1 {
passwords_cryptsetup --cipher twofish-xts-plain64 --type luks1
}
@test passwords-cryptsetup-twofish-xts-plain64-luks2 {
passwords_cryptsetup --cipher twofish-xts-plain64 --type luks2
}
@test passwords-cryptsetup-aes-cbc-plain32-luks1 {
passwords_cryptsetup --cipher aes-cbc-plain --type luks1
}
@test passwords-cryptsetup-aes-cbc-plain32-luks2 {
passwords_cryptsetup --cipher aes-cbc-plain --type luks2
}
@test passwords-cryptsetup-aes-cbc-plain64-luks1 {
passwords_cryptsetup --cipher aes-cbc-plain64 --type luks1
}
@test passwords-cryptsetup-aes-cbc-plain64-luks2 {
passwords_cryptsetup --cipher aes-cbc-plain64 --type luks2
}
@test passwords-cryptsetup-aes-cbc-essiv:sha256-luks1 {
passwords_cryptsetup --cipher aes-cbc-essiv:sha256 --type luks1
}
@test passwords-cryptsetup-aes-cbc-essiv:sha256-luks2 {
passwords_cryptsetup --cipher aes-cbc-essiv:sha256 --type luks2
}
|