2 # FS QA Test generic/396
4 # Test that FS_IOC_SET_ENCRYPTION_POLICY correctly validates the fscrypt_policy
5 # structure that userspace passes to it.
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2016 Google, Inc. All Rights Reserved.
10 # Author: Eric Biggers <ebiggers@google.com>
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
47 # remove previous $seqres.full before test
50 # real QA test starts here
53 _require_scratch_encryption
54 _require_xfs_io_command "set_encpolicy"
56 _scratch_mkfs_encrypted &>> $seqres.full
61 echo -e "\n*** Invalid contents encryption mode ***"
62 $XFS_IO_PROG -c "set_encpolicy -c 0xFF" $dir |& _filter_scratch
64 echo -e "\n*** Invalid filenames encryption mode ***"
65 $XFS_IO_PROG -c "set_encpolicy -n 0xFF" $dir |& _filter_scratch
67 echo -e "\n*** Invalid flags ***"
68 $XFS_IO_PROG -c "set_encpolicy -f 0xFF" $dir |& _filter_scratch
70 echo -e "\n*** Invalid policy version ***"
71 $XFS_IO_PROG -c "set_encpolicy -v 0xFF" $dir |& _filter_scratch
73 # Currently, the only supported combination of modes is AES-256-XTS for contents
74 # and AES-256-CTS for filenames. Nothing else should be accepted.
75 echo -e "\n*** Invalid combinations of modes ***"
76 $XFS_IO_PROG -c "set_encpolicy -c AES-256-CTS -n AES-256-CTS" $dir |& _filter_scratch
77 $XFS_IO_PROG -c "set_encpolicy -c AES-256-CTS -n AES-256-XTS" $dir |& _filter_scratch
78 $XFS_IO_PROG -c "set_encpolicy -c AES-256-XTS -n AES-256-XTS" $dir |& _filter_scratch