706
711
@if [ ! -e /tmp/key1 ]; then \
707
712
dd if=/dev/urandom of=/tmp/key1 count=1 bs=32; \
709
@dd if=/dev/zero of=$(IMG) count=20000
714
@bzip2 -cd testing/compatimage.bz2 > $(IMG)
710
715
@-/sbin/losetup -d $(LOOPDEV)
711
716
@/sbin/losetup $(LOOPDEV) $(IMG)
718
@echo Case: open - compat image - acceptance check
719
# Image must not change
720
@cp $(IMG) $(ORIG_IMG)
721
echo "compatkey" | ../src/cryptsetup -v luksOpen $(LOOPDEV) dummy
723
testing/fileDiffer.py $(IMG) $(ORIG_IMG)
724
@-ls -l /dev/mapper/dummy > /dev/null
725
@../src/cryptsetup remove dummy
728
@echo Case: open - compat image - denial check
729
# Image must not change
730
@cp $(IMG) $(ORIG_IMG)
731
echo "wrongkey" | ../src/cryptsetup -v luksOpen $(LOOPDEV) dummy || true
733
testing/fileDiffer.py $(IMG) $(ORIG_IMG)
714
737
# All headers items and first key material section must change
715
738
@cp $(IMG) $(ORIG_IMG)
716
echo "kuh" | ../src/cryptsetup -v -i 1000 -c aes-cbc-essiv:sha256 luksFormat $(LOOPDEV)
739
echo "key0" | ../src/cryptsetup -v -i 1000 -c aes-cbc-essiv:sha256 luksFormat $(LOOPDEV)
718
741
testing/fileDiffer.py $(IMG) $(ORIG_IMG) $(LUKS_HEADER) $(KEY_SLOT0) $(KEY_MATERIAL0)
721
744
# Image must not change
722
745
@cp $(IMG) $(ORIG_IMG)
723
echo "kuh" | ../src/cryptsetup -v luksOpen $(LOOPDEV) dummy
746
echo "key0" | ../src/cryptsetup -v luksOpen $(LOOPDEV) dummy
725
748
testing/fileDiffer.py $(IMG) $(ORIG_IMG)
726
@-ls -l /dev/mapper/dummy > /dev/null && echo "success (1 of 5)"
749
@-ls -l /dev/mapper/dummy > /dev/null
727
750
@../src/cryptsetup remove dummy
730
754
# Key Slot 1 and key material section 1 must change, the rest must not.
731
755
@cp $(IMG) $(ORIG_IMG)
732
@echo -e "kuh\nlala\n" | ../src/cryptsetup -v luksAddKey $(LOOPDEV)
756
echo -e "key0\nkey1" | ../src/cryptsetup -v luksAddKey $(LOOPDEV)
734
758
testing/fileDiffer.py $(IMG) $(ORIG_IMG) $(KEY_SLOT1) $(KEY_MATERIAL1)
735
@echo "lala" | ../src/cryptsetup -v luksOpen $(LOOPDEV) dummy
736
@-ls -l /dev/mapper/dummy > /dev/null && echo "success (2 of 5)"
759
echo "key1" | ../src/cryptsetup -v luksOpen $(LOOPDEV) dummy
760
@-ls -l /dev/mapper/dummy > /dev/null
737
761
@../src/cryptsetup -v remove dummy
764
# Unsuccessful Key Delete - nothing may change
765
@echo Case: unsuccessful delete
766
@cp $(IMG) $(ORIG_IMG)
767
echo "invalid" | ../src/cryptsetup -v luksDelKey $(LOOPDEV) 1 || true
769
testing/fileDiffer.py $(IMG) $(ORIG_IMG)
739
772
# Delete Key Test
740
773
# Key Slot 1 and key material section 1 must change, the rest must not
774
@echo Case: successful delete
741
775
@cp $(IMG) $(ORIG_IMG)
742
@../src/cryptsetup -v luksDelKey $(LOOPDEV) 1
776
../src/cryptsetup -v -q luksDelKey $(LOOPDEV) 1
744
778
testing/fileDiffer.py $(IMG) $(ORIG_IMG) $(KEY_SLOT1) $(KEY_MATERIAL1_EXT)
745
@echo "lala" | ../src/cryptsetup -v luksOpen $(LOOPDEV) dummy 2>/dev/null || echo "success (3 of 4)"
779
echo "key1" | ../src/cryptsetup -v luksOpen $(LOOPDEV) dummy 2>/dev/null || true
780
echo "key0" | ../src/cryptsetup -v luksOpen $(LOOPDEV) dummy 2>/dev/null
781
@../src/cryptsetup -v remove dummy
747
# Add Key Test for Key Files
748
784
# Key Slot 1 and key material section 1 must change, the rest must not
785
@echo Case: add key test for key files
749
786
@cp $(IMG) $(ORIG_IMG)
750
@echo -e "kuh\n" | ../src/cryptsetup -v luksAddKey $(LOOPDEV) /tmp/key1
787
echo "key0" | ../src/cryptsetup -v luksAddKey $(LOOPDEV) /tmp/key1
752
789
testing/fileDiffer.py $(IMG) $(ORIG_IMG) $(KEY_SLOT1) $(KEY_MATERIAL1)
753
@../src/cryptsetup -d /tmp/key1 -v luksOpen $(LOOPDEV) dummy
754
@-ls -l /dev/mapper/dummy > /dev/null && echo "success (4 of 5)"
755
@../src/cryptsetup -v remove dummy
790
../src/cryptsetup -d /tmp/key1 -v luksOpen $(LOOPDEV) dummy
791
@-ls -l /dev/mapper/dummy > /dev/null
792
@../src/cryptsetup -v remove dummy
795
@echo Case: delete key test with /tmp/key1 as remaining key
796
# Key Slot 1 and key material section 1 must change, the rest must not
797
@cp $(IMG) $(ORIG_IMG)
798
../src/cryptsetup -v -d /tmp/key1 luksDelKey $(LOOPDEV) 0
800
testing/fileDiffer.py $(IMG) $(ORIG_IMG) $(KEY_SLOT0) $(KEY_MATERIAL0_EXT)
801
echo "key0" | ../src/cryptsetup -v luksOpen $(LOOPDEV) dummy 2>/dev/null || true
802
../src/cryptsetup -v luksOpen -d /tmp/key1 $(LOOPDEV) dummy 2>/dev/null
803
@../src/cryptsetup -v remove dummy
757
806
# Format test for ESSIV, and some other parameters.
807
@echo Case: parameter variation test
758
808
@dd if=/dev/zero of=$(IMG) count=20000
759
809
@cp $(IMG) $(ORIG_IMG)
760
810
@../src/cryptsetup -q -v -i 1000 -c aes-cbc-essiv:sha256 luksFormat $(LOOPDEV) /tmp/key1
762
812
testing/fileDiffer.py $(IMG) $(ORIG_IMG) $(LUKS_HEADER) $(KEY_SLOT0) $(KEY_MATERIAL0)
763
813
@../src/cryptsetup -d /tmp/key1 -v luksOpen $(LOOPDEV) dummy
764
@-ls -l /dev/mapper/dummy > /dev/null && echo "success (5 of 5)"
814
@-ls -l /dev/mapper/dummy > /dev/null && echo "success"
765
815
@../src/cryptsetup -v remove dummy
766
816
# Tell versions [3.59,3.63) of GNU make to not export all variables.
767
817
# Otherwise a system limit (for SysV at least) may be exceeded.