Skip to content

Commit 9ea9af1

Browse files
committed
tests: Add Bitlocker images for clearkey
1 parent 4fe1601 commit 9ea9af1

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

tests/bitlk-compat-test

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ load_vars()
4949
if echo "$1" | grep -q -e "two-recovery"; then
5050
# 2 extra variables for image with 2 recovery passphrases
5151
num_vars=10
52+
elif echo "$1" | grep -q -e "clearkey"; then
53+
# 1 extra variable for image with clearkey
54+
num_vars=9
5255
else
5356
num_vars=8
5457
fi
@@ -67,7 +70,7 @@ check_dump()
6770

6871
# volume size
6972
dump_size=$(echo "$dump" | grep "Volume size:" | cut -d: -f2 | tr -d "\t\n ")
70-
[ "$dump_size" = "104857600[bytes]" -o "$dump_size" = "134217728[bytes]" -o "$dump_size" = "105906176[bytes]" ] || fail " volume size check from dump failed."
73+
[ "$dump_size" = "104857600[bytes]" -o "$dump_size" = "134217728[bytes]" -o "$dump_size" = "105906176[bytes]" ] || fail " volume size check from dump failed."
7174

7275
# description
7376
dump_desc=$(echo "$dump" | grep Description: | cut -d: -f2 | tr -d "\t\n ")
@@ -95,6 +98,11 @@ check_dump()
9598
# second recovery passphrase protected VMK GUID
9699
dump_rp2_vmk=$(echo "$dump" | grep "VMK protected with recovery passphrase" -B 1 | tail -2 | head -1 | cut -d: -f2 | tr -d "\t ")
97100
[ ! -z "$RP2_VMK_GUID" -a "$dump_rp2_vmk" = "$RP2_VMK_GUID" ] || fail " second recovery passphrase protected VMK GUID check from dump failed."
101+
elif echo "$file" | grep -q -e "clearkey"; then
102+
# clearkey protected VMK GUID
103+
dump_clearkey_guid=$(echo "$dump" | grep "VMK protected with clear key" -B 1 | tail -2 | head -1 | cut -d: -f2 | tr -d "\t ")
104+
[ ! -z "$CLEARKEY_VMK_GUID" -a "$dump_clearkey_guid" = "$CLEARKEY_VMK_GUID" ] || fail " clear key protected VMK GUID check from dump failed."
105+
return
98106
else
99107
# password protected VMK GUID
100108
dump_pw_vmk=$(echo "$dump" | grep "VMK protected with passphrase" -B 1 | head -1 | cut -d: -f2 | tr -d "\t ")
@@ -157,7 +165,7 @@ for file in $(ls $TST_DIR/bitlk-*) ; do
157165
ret=$?
158166
[ $ret -eq 1 ] && ( echo "$file" | grep -q -e "aes-cbc" ) && echo " [N/A]" && continue
159167
[ $ret -eq 1 ] && ( echo "$file" | grep -q -e "aes-cbc-elephant" ) && echo " [N/A]" && continue
160-
[ $ret -eq 1 ] && ( echo "$file" | grep -q -e "clearkey" ) && echo " [N/A]" && continue
168+
[ $ret -eq 1 ] && ( echo "$file" | grep -q -e "partially-encrypted" ) && echo " [N/A]" && continue
161169
[ $ret -eq 1 ] && ( echo "$file" | grep -q -e "eow" ) && echo " [N/A]" && continue
162170
[ $ret -eq 1 ] && ( echo "$file" | grep -q -e "-4k.img" ) && echo " [N/A]" && continue
163171
[ $ret -eq 0 ] || fail " failed to open $file ($ret)"
@@ -184,7 +192,7 @@ for file in $(ls $TST_DIR/bitlk-*) ; do
184192
ret=$?
185193
[ $ret -eq 1 ] && ( echo "$file" | grep -q -e "aes-cbc" ) && echo " [N/A]" && continue
186194
[ $ret -eq 1 ] && ( echo "$file" | grep -q -e "aes-cbc-elephant" ) && echo " [N/A]" && continue
187-
[ $ret -eq 1 ] && ( echo "$file" | grep -q -e "clearkey" ) && echo " [N/A]" && continue
195+
[ $ret -eq 1 ] && ( echo "$file" | grep -q -e "partially-encrypted" ) && echo " [N/A]" && continue
188196
[ $ret -eq 1 ] && ( echo "$file" | grep -q -e "eow" ) && echo " [N/A]" && continue
189197
[ $ret -eq 1 ] && ( echo "$file" | grep -q -e "-4k.img" ) && echo " [N/A]" && continue
190198
[ $ret -eq 0 ] || fail " failed to open $file using volume key ($ret)"
@@ -236,8 +244,27 @@ for file in $(ls $TST_DIR/bitlk-*) ; do
236244
[ "$uuid" = "$UUID" ] || fail " UUID check failed."
237245
[ "$sha256sum" = "$SHA256SUM" ] || fail " SHA256 sum check failed."
238246
echo " [OK]"
247+
fi
239248

249+
# clear key
250+
if echo "$file" | grep -q -e "clearkey"; then
251+
echo -n " $file"
252+
echo $CRYPTSETUP bitlkOpen -r $file --test-passphrase >/dev/null 2>&1
253+
ret=$?
254+
[ $ret -eq 1 ] && echo " [N/A]" && continue
255+
$CRYPTSETUP bitlkOpen -r $file $MAP >/dev/null 2>&1
256+
ret=$?
257+
[ $ret -eq 0 ] || fail " failed to open $file ($ret)"
258+
$CRYPTSETUP status $MAP >/dev/null || fail
259+
$CRYPTSETUP status /dev/mapper/$MAP >/dev/null || fail
260+
uuid=$(blkid -p -o value -s UUID /dev/mapper/$MAP)
261+
sha256sum=$(sha256sum /dev/mapper/$MAP | cut -d" " -f1)
262+
$CRYPTSETUP remove $MAP || fail
263+
[ "$uuid" = "$UUID" ] || fail " UUID check failed."
264+
[ "$sha256sum" = "$SHA256SUM" ] || fail " SHA256 sum check failed."
265+
echo " [OK]"
240266
fi
267+
241268
done
242269

243270
remove_mapping

tests/bitlk-images.tar.xz

20.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)